summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSébastien d'Herbais de Thun <sebastien.d.herbais@gmail.com>2023-10-06 16:47:20 +0200
committerGitHub <noreply@github.com>2023-10-06 16:47:20 +0200
commite7443abfe681a27ee47993d192f8a82953d43b73 (patch)
tree03446e4bfe9ab9aae96f151c7c228d3e26bdc89d /tests
parentbced71b250225e30efa2fd0341bf825bf685a376 (diff)
Gradient Part 3 - Radial gradients (#2312)
Diffstat (limited to 'tests')
-rw-r--r--tests/ref/visualize/gradient-radial.pngbin0 -> 56014 bytes
-rw-r--r--tests/ref/visualize/gradient-relative-linear.png (renamed from tests/ref/visualize/gradient-relative.png)bin485209 -> 485209 bytes
-rw-r--r--tests/ref/visualize/gradient-relative-radial.pngbin0 -> 403617 bytes
-rw-r--r--tests/ref/visualize/gradient-sharp.pngbin45753 -> 89427 bytes
-rw-r--r--tests/ref/visualize/gradient-stroke.pngbin15995 -> 11463 bytes
-rw-r--r--tests/typ/visualize/gradient-radial.typ49
-rw-r--r--tests/typ/visualize/gradient-relative-linear.typ (renamed from tests/typ/visualize/gradient-relative.typ)3
-rw-r--r--tests/typ/visualize/gradient-relative-radial.typ29
-rw-r--r--tests/typ/visualize/gradient-sharp.typ8
-rw-r--r--tests/typ/visualize/gradient-stroke.typ12
10 files changed, 97 insertions, 4 deletions
diff --git a/tests/ref/visualize/gradient-radial.png b/tests/ref/visualize/gradient-radial.png
new file mode 100644
index 00000000..2e8e9af3
--- /dev/null
+++ b/tests/ref/visualize/gradient-radial.png
Binary files differ
diff --git a/tests/ref/visualize/gradient-relative.png b/tests/ref/visualize/gradient-relative-linear.png
index 56e46119..56e46119 100644
--- a/tests/ref/visualize/gradient-relative.png
+++ b/tests/ref/visualize/gradient-relative-linear.png
Binary files differ
diff --git a/tests/ref/visualize/gradient-relative-radial.png b/tests/ref/visualize/gradient-relative-radial.png
new file mode 100644
index 00000000..210ea7b0
--- /dev/null
+++ b/tests/ref/visualize/gradient-relative-radial.png
Binary files differ
diff --git a/tests/ref/visualize/gradient-sharp.png b/tests/ref/visualize/gradient-sharp.png
index 30e6fb66..a01cf08f 100644
--- a/tests/ref/visualize/gradient-sharp.png
+++ b/tests/ref/visualize/gradient-sharp.png
Binary files differ
diff --git a/tests/ref/visualize/gradient-stroke.png b/tests/ref/visualize/gradient-stroke.png
index 75f37c51..c7bc765b 100644
--- a/tests/ref/visualize/gradient-stroke.png
+++ b/tests/ref/visualize/gradient-stroke.png
Binary files differ
diff --git a/tests/typ/visualize/gradient-radial.typ b/tests/typ/visualize/gradient-radial.typ
new file mode 100644
index 00000000..5d83e71f
--- /dev/null
+++ b/tests/typ/visualize/gradient-radial.typ
@@ -0,0 +1,49 @@
+// Test the different radial gradient features.
+---
+
+#square(
+ size: 100pt,
+ fill: gradient.radial(..color.map.rainbow, space: color.hsl),
+)
+---
+
+#grid(
+ columns: 2,
+ square(
+ size: 50pt,
+ fill: gradient.radial(..color.map.rainbow, space: color.hsl, center: (0%, 0%)),
+ ),
+ square(
+ size: 50pt,
+ fill: gradient.radial(..color.map.rainbow, space: color.hsl, center: (0%, 100%)),
+ ),
+ square(
+ size: 50pt,
+ fill: gradient.radial(..color.map.rainbow, space: color.hsl, center: (100%, 0%)),
+ ),
+ square(
+ size: 50pt,
+ fill: gradient.radial(..color.map.rainbow, space: color.hsl, center: (100%, 100%)),
+ ),
+)
+
+---
+
+#square(
+ size: 50pt,
+ fill: gradient.radial(..color.map.rainbow, space: color.hsl, radius: 10%),
+)
+#square(
+ size: 50pt,
+ fill: gradient.radial(..color.map.rainbow, space: color.hsl, radius: 72%),
+)
+
+---
+#circle(
+ radius: 25pt,
+ fill: gradient.radial(white, rgb("#8fbc8f"), focal-center: (35%, 35%), focal-radius: 5%),
+)
+#circle(
+ radius: 25pt,
+ fill: gradient.radial(white, rgb("#8fbc8f"), focal-center: (75%, 35%), focal-radius: 5%),
+) \ No newline at end of file
diff --git a/tests/typ/visualize/gradient-relative.typ b/tests/typ/visualize/gradient-relative-linear.typ
index 549a05b4..8e1d04dc 100644
--- a/tests/typ/visualize/gradient-relative.typ
+++ b/tests/typ/visualize/gradient-relative-linear.typ
@@ -1,5 +1,4 @@
-// Test whether `relative: "parent"` works correctly.
-
+// Test whether `relative: "parent"` works correctly on linear gradients.
---
// The image should look as if there is a single gradient that is being used for
diff --git a/tests/typ/visualize/gradient-relative-radial.typ b/tests/typ/visualize/gradient-relative-radial.typ
new file mode 100644
index 00000000..87686896
--- /dev/null
+++ b/tests/typ/visualize/gradient-relative-radial.typ
@@ -0,0 +1,29 @@
+// Test whether `relative: "parent"` works correctly on radial gradients.
+
+---
+// The image should look as if there is a single gradient that is being used for
+// both the page and the rectangles.
+#let grad = gradient.radial(red, blue, green, purple, relative: "parent");
+#let my-rect = rect(width: 50%, height: 50%, fill: grad)
+#set page(
+ height: 200pt,
+ width: 200pt,
+ fill: grad,
+ background: place(top + left, my-rect),
+)
+#place(top + right, my-rect)
+#place(bottom + center, rotate(45deg, my-rect))
+
+---
+// The image should look as if there are multiple gradients, one for each
+// rectangle.
+#let grad = gradient.radial(red, blue, green, purple, relative: "self");
+#let my-rect = rect(width: 50%, height: 50%, fill: grad)
+#set page(
+ height: 200pt,
+ width: 200pt,
+ fill: grad,
+ background: place(top + left, my-rect),
+)
+#place(top + right, my-rect)
+#place(bottom + center, rotate(45deg, my-rect))
diff --git a/tests/typ/visualize/gradient-sharp.typ b/tests/typ/visualize/gradient-sharp.typ
index 424beb8b..1f090f7e 100644
--- a/tests/typ/visualize/gradient-sharp.typ
+++ b/tests/typ/visualize/gradient-sharp.typ
@@ -5,9 +5,17 @@
size: 100pt,
fill: gradient.linear(..color.map.rainbow, space: color.hsl).sharp(10),
)
+#square(
+ size: 100pt,
+ fill: gradient.radial(..color.map.rainbow, space: color.hsl).sharp(10),
+)
---
#square(
size: 100pt,
fill: gradient.linear(..color.map.rainbow, space: color.hsl).sharp(10, smoothness: 40%),
)
+#square(
+ size: 100pt,
+ fill: gradient.radial(..color.map.rainbow, space: color.hsl).sharp(10, smoothness: 40%),
+)
diff --git a/tests/typ/visualize/gradient-stroke.typ b/tests/typ/visualize/gradient-stroke.typ
index a156dde7..01616fe3 100644
--- a/tests/typ/visualize/gradient-stroke.typ
+++ b/tests/typ/visualize/gradient-stroke.typ
@@ -1,8 +1,16 @@
// Test gradients on strokes.
---
-#set page(width: 100pt, height: 100pt)
-#align(center + horizon, square(size: 50pt, fill: black, stroke: 5pt + gradient.linear(red, blue)))
+#set page(width: 100pt, height: auto, margin: 10pt)
+#align(center + top, square(size: 50pt, fill: black, stroke: 5pt + gradient.linear(red, blue)))
+#align(
+ center + bottom,
+ square(
+ size: 50pt,
+ fill: gradient.radial(red, blue, radius: 70.7%, focal-center: (10%, 10%)),
+ stroke: 10pt + gradient.radial(red, blue, radius: 70.7%, focal-center: (10%, 10%))
+ )
+)
---
// Test gradient on lines