summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBirk Tjelmeland <git@birktj.no>2023-04-13 16:05:56 +0200
committerGitHub <noreply@github.com>2023-04-13 16:05:56 +0200
commitd1cd814ef8149cbac6e59c81e074aa59c930eed3 (patch)
tree02b9a8afed4d121b34d89669452f91cda19df8e2 /tests
parent46ce9c94e3f615751989d3cba5aa1599e0ba5913 (diff)
Add support for more complex strokes (#505)
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/visualize/stroke.pngbin0 -> 14835 bytes
-rw-r--r--tests/typ/visualize/shape-rect.typ2
-rw-r--r--tests/typ/visualize/stroke.typ71
3 files changed, 72 insertions, 1 deletions
diff --git a/tests/ref/visualize/stroke.png b/tests/ref/visualize/stroke.png
new file mode 100644
index 00000000..312eabec
--- /dev/null
+++ b/tests/ref/visualize/stroke.png
Binary files differ
diff --git a/tests/typ/visualize/shape-rect.typ b/tests/typ/visualize/shape-rect.typ
index a95f2750..951d5bea 100644
--- a/tests/typ/visualize/shape-rect.typ
+++ b/tests/typ/visualize/shape-rect.typ
@@ -51,5 +51,5 @@
#rect(radius: (left: 10pt, cake: 5pt))
---
-// Error: 15-21 expected length, color, stroke, none, dictionary, or auto, found array
+// Error: 15-21 expected length, color, dictionary, stroke, none, or auto, found array
#rect(stroke: (1, 2))
diff --git a/tests/typ/visualize/stroke.typ b/tests/typ/visualize/stroke.typ
new file mode 100644
index 00000000..2443d27a
--- /dev/null
+++ b/tests/typ/visualize/stroke.typ
@@ -0,0 +1,71 @@
+// Test lines.
+
+---
+// Some simple test lines
+
+#line(length: 60pt, stroke: red)
+#v(3pt)
+#line(length: 60pt, stroke: 2pt)
+#v(3pt)
+#line(length: 60pt, stroke: blue + 1.5pt)
+#v(3pt)
+#line(length: 60pt, stroke: (color: red, thickness: 1pt, dash: "dashed"))
+#v(3pt)
+#line(length: 60pt, stroke: (color: red, thickness: 4pt, cap: "round"))
+
+---
+// Set rules with stroke
+
+#set line(stroke: (color: red, thickness: 1pt, cap: "butt", dash: "dashdotted"))
+
+#line(length: 60pt)
+#v(3pt)
+#line(length: 60pt, stroke: blue)
+#v(3pt)
+#line(length: 60pt, stroke: (dash: none))
+
+---
+// Rectangle strokes
+
+#rect(width: 20pt, height: 20pt, stroke: red)
+#v(3pt)
+#rect(width: 20pt, height: 20pt, stroke: (rest: red, top: (color: blue, dash: "dashed")))
+#v(3pt)
+#rect(width: 20pt, height: 20pt, stroke: (thickness: 5pt, join: "round"))
+
+---
+// Dashing
+#line(length: 60pt, stroke: (color: red, thickness: 1pt, dash: ("dot", 1pt)))
+#v(3pt)
+#line(length: 60pt, stroke: (color: red, thickness: 1pt, dash: ("dot", 1pt, 4pt, 2pt)))
+#v(3pt)
+#line(length: 60pt, stroke: (color: red, thickness: 1pt, dash: (array: ("dot", 1pt, 4pt, 2pt), phase: 5pt)))
+#v(3pt)
+#line(length: 60pt, stroke: (color: red, thickness: 1pt, dash: ()))
+#v(3pt)
+#line(length: 60pt, stroke: (color: red, thickness: 1pt, dash: (1pt, 3pt, 9pt)))
+
+---
+// Line joins
+#stack(dir: ltr,
+ polygon(stroke: (thickness: 4pt, color: blue, join: "round"),
+ (0pt, 20pt), (15pt, 0pt), (0pt, 40pt), (15pt, 45pt)),
+ h(1em),
+ polygon(stroke: (thickness: 4pt, color: blue, join: "bevel"),
+ (0pt, 20pt), (15pt, 0pt), (0pt, 40pt), (15pt, 45pt)),
+ h(1em),
+ polygon(stroke: (thickness: 4pt, color: blue, join: "miter"),
+ (0pt, 20pt), (15pt, 0pt), (0pt, 40pt), (15pt, 45pt)),
+ h(1em),
+ polygon(stroke: (thickness: 4pt, color: blue, join: "miter", miter-limit: 20.0),
+ (0pt, 20pt), (15pt, 0pt), (0pt, 40pt), (15pt, 45pt)),
+)
+---
+
+// Error: 29-56 unexpected key "thicknes", valid keys are "color", "thickness", "cap", "join", "dash", and "miter-limit"
+#line(length: 60pt, stroke: (color: red, thicknes: 1pt))
+
+---
+
+// Error: 29-55 expected "solid", "dotted", "densely-dotted", "loosely-dotted", "dashed", "densely-dashed", "loosely-dashed", "dashdotted", "densely-dashdotted", "loosely-dashdotted", array, dictionary, dash pattern, or none
+#line(length: 60pt, stroke: (color: red, dash: "dash"))