summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEmmanuel Lesueur <48604057+Emm54321@users.noreply.github.com>2024-12-18 16:58:57 +0100
committerGitHub <noreply@github.com>2024-12-18 15:58:57 +0000
commit257764181e52332a00079b9e3af03823fde1a15d (patch)
tree203378b303f1969e684b26dbefb77f7a5979ec9f /tests
parent24c08a7ec0aaf87d6dc2e1a2c47b7beb6d5ad2a4 (diff)
New `curve` element that supersedes `path` (#5323)
Co-authored-by: Laurenz <laurmaedje@gmail.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/curve-close-intersection.pngbin0 -> 683 bytes
-rw-r--r--tests/ref/curve-close-smooth.pngbin0 -> 1306 bytes
-rw-r--r--tests/ref/curve-close-straight.pngbin0 -> 1121 bytes
-rw-r--r--tests/ref/curve-cubic-inflection.pngbin0 -> 1552 bytes
-rw-r--r--tests/ref/curve-cubic-mirror.pngbin0 -> 482 bytes
-rw-r--r--tests/ref/curve-fill-rule.pngbin0 -> 570 bytes
-rw-r--r--tests/ref/curve-line.pngbin0 -> 244 bytes
-rw-r--r--tests/ref/curve-move-multiple-even-odd.pngbin0 -> 301 bytes
-rw-r--r--tests/ref/curve-move-multiple-non-zero.pngbin0 -> 297 bytes
-rw-r--r--tests/ref/curve-move-single.pngbin0 -> 262 bytes
-rw-r--r--tests/ref/curve-quad-mirror.pngbin0 -> 490 bytes
-rw-r--r--tests/ref/curve-stroke-gradient.pngbin0 -> 2136 bytes
-rw-r--r--tests/ref/issue-curve-in-sized-container.pngbin0 -> 135 bytes
-rw-r--r--tests/ref/stroke-zero-thickness.pngbin620 -> 631 bytes
-rw-r--r--tests/suite/visualize/curve.typ163
-rw-r--r--tests/suite/visualize/stroke.typ24
-rw-r--r--tests/suite/visualize/tiling.typ6
17 files changed, 176 insertions, 17 deletions
diff --git a/tests/ref/curve-close-intersection.png b/tests/ref/curve-close-intersection.png
new file mode 100644
index 00000000..18951a5f
--- /dev/null
+++ b/tests/ref/curve-close-intersection.png
Binary files differ
diff --git a/tests/ref/curve-close-smooth.png b/tests/ref/curve-close-smooth.png
new file mode 100644
index 00000000..64b81261
--- /dev/null
+++ b/tests/ref/curve-close-smooth.png
Binary files differ
diff --git a/tests/ref/curve-close-straight.png b/tests/ref/curve-close-straight.png
new file mode 100644
index 00000000..c9497a86
--- /dev/null
+++ b/tests/ref/curve-close-straight.png
Binary files differ
diff --git a/tests/ref/curve-cubic-inflection.png b/tests/ref/curve-cubic-inflection.png
new file mode 100644
index 00000000..eef6cce2
--- /dev/null
+++ b/tests/ref/curve-cubic-inflection.png
Binary files differ
diff --git a/tests/ref/curve-cubic-mirror.png b/tests/ref/curve-cubic-mirror.png
new file mode 100644
index 00000000..f5ad53df
--- /dev/null
+++ b/tests/ref/curve-cubic-mirror.png
Binary files differ
diff --git a/tests/ref/curve-fill-rule.png b/tests/ref/curve-fill-rule.png
new file mode 100644
index 00000000..b547ff31
--- /dev/null
+++ b/tests/ref/curve-fill-rule.png
Binary files differ
diff --git a/tests/ref/curve-line.png b/tests/ref/curve-line.png
new file mode 100644
index 00000000..2e5eaecc
--- /dev/null
+++ b/tests/ref/curve-line.png
Binary files differ
diff --git a/tests/ref/curve-move-multiple-even-odd.png b/tests/ref/curve-move-multiple-even-odd.png
new file mode 100644
index 00000000..f21a2885
--- /dev/null
+++ b/tests/ref/curve-move-multiple-even-odd.png
Binary files differ
diff --git a/tests/ref/curve-move-multiple-non-zero.png b/tests/ref/curve-move-multiple-non-zero.png
new file mode 100644
index 00000000..4dc4ae6c
--- /dev/null
+++ b/tests/ref/curve-move-multiple-non-zero.png
Binary files differ
diff --git a/tests/ref/curve-move-single.png b/tests/ref/curve-move-single.png
new file mode 100644
index 00000000..d02d33a2
--- /dev/null
+++ b/tests/ref/curve-move-single.png
Binary files differ
diff --git a/tests/ref/curve-quad-mirror.png b/tests/ref/curve-quad-mirror.png
new file mode 100644
index 00000000..4b13a9db
--- /dev/null
+++ b/tests/ref/curve-quad-mirror.png
Binary files differ
diff --git a/tests/ref/curve-stroke-gradient.png b/tests/ref/curve-stroke-gradient.png
new file mode 100644
index 00000000..042f540a
--- /dev/null
+++ b/tests/ref/curve-stroke-gradient.png
Binary files differ
diff --git a/tests/ref/issue-curve-in-sized-container.png b/tests/ref/issue-curve-in-sized-container.png
new file mode 100644
index 00000000..7f1624ff
--- /dev/null
+++ b/tests/ref/issue-curve-in-sized-container.png
Binary files differ
diff --git a/tests/ref/stroke-zero-thickness.png b/tests/ref/stroke-zero-thickness.png
index f8c41d1b..5a8024fa 100644
--- a/tests/ref/stroke-zero-thickness.png
+++ b/tests/ref/stroke-zero-thickness.png
Binary files differ
diff --git a/tests/suite/visualize/curve.typ b/tests/suite/visualize/curve.typ
new file mode 100644
index 00000000..f98f634a
--- /dev/null
+++ b/tests/suite/visualize/curve.typ
@@ -0,0 +1,163 @@
+// Test curves.
+
+--- curve-move-single ---
+#curve(
+ stroke: 5pt,
+ curve.move((0pt, 30pt)),
+ curve.line((30pt, 30pt)),
+ curve.line((15pt, 0pt)),
+ curve.close()
+)
+
+--- curve-move-multiple-even-odd ---
+#curve(
+ fill: yellow,
+ stroke: yellow.darken(20%),
+ fill-rule: "even-odd",
+ curve.move((10pt, 10pt)),
+ curve.line((20pt, 10pt)),
+ curve.line((20pt, 20pt)),
+ curve.close(),
+ curve.move((0pt, 5pt)),
+ curve.line((25pt, 5pt)),
+ curve.line((25pt, 30pt)),
+ curve.close(mode: "smooth"),
+)
+
+--- curve-move-multiple-non-zero ---
+#curve(
+ fill: yellow,
+ stroke: yellow.darken(20%),
+ curve.move((10pt, 10pt)),
+ curve.line((20pt, 10pt)),
+ curve.line((20pt, 20pt)),
+ curve.close(),
+ curve.move((0pt, 5pt)),
+ curve.line((25pt, 5pt)),
+ curve.line((25pt, 30pt)),
+ curve.close(mode: "smooth"),
+)
+
+--- curve-line ---
+#curve(
+ fill: purple,
+ stroke: 3pt + purple.lighten(50%),
+ curve.move((0pt, 0pt)),
+ curve.line((30pt, 30pt)),
+ curve.line((0pt, 30pt)),
+ curve.line((30pt, 0pt)),
+)
+
+--- curve-quad-mirror ---
+#curve(
+ stroke: 2pt,
+ curve.quad((20pt, 40pt), (40pt, 40pt), relative: true),
+ curve.quad(auto, (40pt, -40pt), relative: true),
+)
+
+--- curve-cubic-mirror ---
+#set page(height: 100pt)
+#curve(
+ fill: red,
+ curve.move((0%, 0%)),
+ curve.cubic((-4%, 4%), (54%, 46%), (50%, 50%)),
+ curve.cubic(auto, (4%, 54%), (0%, 50%)),
+ curve.cubic(auto, (54%, 4%), (50%, 0%)),
+ curve.close(),
+)
+
+--- curve-cubic-inflection ---
+#set page(height: 120pt)
+#curve(
+ fill: blue.lighten(80%),
+ stroke: blue,
+ curve.move((30%, 0%)),
+ curve.cubic((10%, 0%), (10%, 60%), (30%, 60%)),
+ curve.cubic(none, (110%, 0%), (50%, 30%)),
+ curve.cubic((110%, 30%), (65%, 30%), (30%, 0%)),
+ curve.close(mode: "straight")
+)
+
+--- curve-close-smooth ---
+#curve(
+ fill: blue.lighten(80%),
+ stroke: blue,
+ curve.move((0pt, 40pt)),
+ curve.cubic((0pt, 70pt), (10pt, 80pt), (40pt, 80pt)),
+ curve.cubic(auto, (80pt, 70pt), (80pt, 40pt)),
+ curve.cubic(auto, (70pt, 0pt), (40pt, 0pt)),
+ curve.close(mode: "smooth")
+)
+
+--- curve-close-straight ---
+#curve(
+ fill: blue.lighten(80%),
+ stroke: blue,
+ curve.move((0pt, 40pt)),
+ curve.cubic((0pt, 70pt), (10pt, 80pt), (40pt, 80pt)),
+ curve.cubic(auto, (80pt, 70pt), (80pt, 40pt)),
+ curve.cubic(auto, (70pt, 0pt), (40pt, 0pt)),
+ curve.close(mode: "straight")
+)
+
+--- curve-close-intersection ---
+#curve(
+ fill: yellow,
+ stroke: black,
+ curve.move((10pt, 10pt)),
+ curve.cubic((5pt, 20pt), (15pt, 20pt), (20pt, 0pt), relative: true),
+ curve.cubic(auto, (15pt, -10pt), (20pt, 0pt), relative: true),
+ curve.close(mode: "straight")
+)
+
+--- curve-stroke-gradient ---
+#set page(width: auto)
+#let down = curve.line((40pt, 40pt), relative: true)
+#let up = curve.line((40pt, -40pt), relative: true)
+
+#curve(
+ stroke: 4pt + gradient.linear(red, blue),
+ down, up, down, up, down,
+)
+
+--- curve-fill-rule ---
+#stack(
+ dir: ltr,
+ curve(
+ fill: red,
+ fill-rule: "non-zero",
+ curve.move((25pt, 0pt)),
+ curve.line((10pt, 50pt)),
+ curve.line((50pt, 20pt)),
+ curve.line((0pt, 20pt)),
+ curve.line((40pt, 50pt)),
+ curve.close()
+ ),
+ curve(
+ fill: red,
+ fill-rule: "even-odd",
+ curve.move((25pt, 0pt)),
+ curve.line((10pt, 50pt)),
+ curve.line((50pt, 20pt)),
+ curve.line((0pt, 20pt)),
+ curve.line((40pt, 50pt)),
+ curve.close()
+ )
+)
+
+--- curve-infinite-length ---
+// Error: 2-67 cannot create curve with infinite size
+#curve(curve.move((0pt, 0pt)), curve.line((float.inf * 1pt, 0pt)))
+
+--- issue-curve-in-sized-container ---
+// Curves/Paths used to implement `LayoutMultiple` rather than `LayoutSingle`
+// without fulfilling the necessary contract of respecting region expansion.
+#block(
+ fill: aqua,
+ width: 20pt,
+ height: 15pt,
+ curve(
+ curve.move((0pt, 0pt)),
+ curve.line((10pt, 10pt)),
+ ),
+)
diff --git a/tests/suite/visualize/stroke.typ b/tests/suite/visualize/stroke.typ
index 387e88cb..3fb492bb 100644
--- a/tests/suite/visualize/stroke.typ
+++ b/tests/suite/visualize/stroke.typ
@@ -59,24 +59,20 @@
#table(columns: 2, stroke: none)[A][B]
#table(columns: 2, stroke: 0pt)[A][B]
-#path(
- fill: red,
+#curve(
stroke: none,
- closed: true,
- ((0%, 0%), (4%, -4%)),
- ((50%, 50%), (4%, -4%)),
- ((0%, 50%), (4%, 4%)),
- ((50%, 0%), (4%, 4%)),
+ curve.move((0pt, 30pt)),
+ curve.line((30pt, 30pt)),
+ curve.line((15pt, 0pt)),
+ curve.close()
)
-#path(
- fill: red,
+#curve(
stroke: 0pt,
- closed: true,
- ((0%, 0%), (4%, -4%)),
- ((50%, 50%), (4%, -4%)),
- ((0%, 50%), (4%, 4%)),
- ((50%, 0%), (4%, 4%)),
+ curve.move((0pt, 30pt)),
+ curve.line((30pt, 30pt)),
+ curve.line((15pt, 0pt)),
+ curve.close()
)
--- stroke-text ---
diff --git a/tests/suite/visualize/tiling.typ b/tests/suite/visualize/tiling.typ
index 5272328d..5e61aa43 100644
--- a/tests/suite/visualize/tiling.typ
+++ b/tests/suite/visualize/tiling.typ
@@ -61,9 +61,9 @@
)
--- tiling-zero-sized ---
-// Error: 15-51 tile size must be non-zero
-// Hint: 15-51 try setting the size manually
-#line(stroke: tiling(path((0pt, 0pt), (1em, 0pt))))
+// Error: 15-52 tile size must be non-zero
+// Hint: 15-52 try setting the size manually
+#line(stroke: tiling(curve(curve.move((1em, 0pt)))))
--- tiling-spacing-negative ---
// Test with spacing set to `(-10pt, -10pt)`