summaryrefslogtreecommitdiff
path: root/tests/typ/elements/image.typ
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2022-02-28 15:50:48 +0100
committerLaurenz <laurmaedje@gmail.com>2022-02-28 23:54:34 +0100
commit3ca5b238238e1128aa7bbfbd5db9e632045d8600 (patch)
tree2471f4b340a15695b7f4d518c0b39fabaea676c4 /tests/typ/elements/image.typ
parentb63c21c91d99a1554a019dc275f955d3e6a34271 (diff)
Reorganize library
Diffstat (limited to 'tests/typ/elements/image.typ')
-rw-r--r--tests/typ/elements/image.typ59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/typ/elements/image.typ b/tests/typ/elements/image.typ
new file mode 100644
index 00000000..8817713f
--- /dev/null
+++ b/tests/typ/elements/image.typ
@@ -0,0 +1,59 @@
+// Test the `image` function.
+
+---
+// Test loading different image formats.
+
+// Load an RGBA PNG image.
+#image("../../res/rhino.png")
+
+// Load an RGB JPEG image.
+#set page(height: 60pt)
+#image("../../res/tiger.jpg")
+
+---
+// Test configuring the size and fitting behaviour of images.
+
+// Set width and height explicitly.
+#image("../../res/rhino.png", width: 30pt)
+#image("../../res/rhino.png", height: 30pt)
+
+// Set width and height explicitly and force stretching.
+#image("../../res/monkey.svg", width: 100%, height: 20pt, fit: "stretch")
+
+// Make sure the bounding-box of the image is correct.
+#align(bottom + right, image("../../res/tiger.jpg", width: 40pt))
+
+---
+// Test all three fit modes.
+#set page(height: 50pt, margins: 0pt)
+#grid(
+ columns: (1fr, 1fr, 1fr),
+ rows: 100%,
+ gutter: 3pt,
+ image("../../res/tiger.jpg", width: 100%, height: 100%, fit: "contain"),
+ image("../../res/tiger.jpg", width: 100%, height: 100%, fit: "cover"),
+ image("../../res/monkey.svg", width: 100%, height: 100%, fit: "stretch"),
+)
+
+---
+// Does not fit to remaining height of page.
+#set page(height: 60pt)
+Stuff \
+Stuff
+#image("../../res/rhino.png")
+
+---
+// Test baseline.
+A #image("../../res/tiger.jpg", height: 1cm, width: 80%) B
+
+---
+// Test advanced SVG features.
+#image("../../res/pattern.svg")
+
+---
+// Error: 8-29 file not found
+#image("path/does/not/exist")
+
+---
+// Error: 8-21 failed to load image (unknown image format)
+#image("./image.typ")