diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-10-05 18:51:21 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-10-05 18:51:21 +0200 |
| commit | dcdcf53831aa477b575c9e6ab37eb64f14317c74 (patch) | |
| tree | 43b742ddbcb623254d8d6e6e65d2c432cb7509e8 /tests/typ/elements | |
| parent | 5e06941c63425ab10e08e4d533939c7309cfe6ce (diff) | |
Rename insert/ to elements/
Diffstat (limited to 'tests/typ/elements')
| -rw-r--r-- | tests/typ/elements/circle.typ | 48 | ||||
| -rw-r--r-- | tests/typ/elements/ellipse.typ | 17 | ||||
| -rw-r--r-- | tests/typ/elements/image.typ | 44 | ||||
| -rw-r--r-- | tests/typ/elements/rect.typ | 27 | ||||
| -rw-r--r-- | tests/typ/elements/square.typ | 34 |
5 files changed, 170 insertions, 0 deletions
diff --git a/tests/typ/elements/circle.typ b/tests/typ/elements/circle.typ new file mode 100644 index 00000000..c46d37e4 --- /dev/null +++ b/tests/typ/elements/circle.typ @@ -0,0 +1,48 @@ +// Test the `circle` function. + +--- +// Test auto sizing. + +Auto-sized circle. \ +#circle(fill: rgb("eb5278"))[ + #align(center, center) + But, soft! +] + +Center-aligned rect in auto-sized circle. +#circle(fill: forest)[ + #align(center, center) + #rect(fill: conifer, pad(5pt)[ + But, soft! + ]) +] + +100%-width rect in auto-sized circle. \ +#circle(fill: forest, + rect(width: 100%, fill: conifer)[ + But, soft! what light through yonder window breaks? + ] +) + +Expanded by height. +#circle(fill: conifer)[A \ B \ C] + +--- +// Test relative sizing. +#rect(width: 100%, height: 50pt, fill: rgb("aaa"))[ + #align(center, center) + #font(fill: white) + #circle(radius: 10pt, fill: eastern)[A] + #circle(height: 60%, fill: eastern)[B] + #circle(width: 20% + 20pt, fill: eastern)[C] +] + +--- +// Radius wins over width and height. +// Error: 23-34 unexpected argument +#circle(radius: 10pt, width: 50pt, height: 100pt, fill: eastern) + +--- +// Width wins over height. +// Error: 9-21 unexpected argument +#circle(height: 50pt, width: 20pt, fill: eastern) diff --git a/tests/typ/elements/ellipse.typ b/tests/typ/elements/ellipse.typ new file mode 100644 index 00000000..33ba727f --- /dev/null +++ b/tests/typ/elements/ellipse.typ @@ -0,0 +1,17 @@ +// Test the `ellipse` function. + +--- +100% rect in 100% ellipse in fixed rect. \ +#rect(width: 3cm, height: 2cm, fill: rgb("2a631a"), + ellipse(width: 100%, height: 100%, fill: forest, + rect(width: 100%, height: 100%, fill: conifer)[ + #align(center, center) + Stuff inside an ellipse! + ] + ) +) + +Auto-sized ellipse. \ +#ellipse(fill: conifer)[ + But, soft! what light through yonder window breaks? +] diff --git a/tests/typ/elements/image.typ b/tests/typ/elements/image.typ new file mode 100644 index 00000000..6359c4bb --- /dev/null +++ b/tests/typ/elements/image.typ @@ -0,0 +1,44 @@ +// Test the `image` function. + +--- +// Test loading different image formats. + +// Load an RGBA PNG image. +#image("../../res/rhino.png") +#pagebreak() + +// Load an RGB JPEG image. +#image("../../res/tiger.jpg") + +--- +// Test configuring the size and fitting behaviour of images. + +// Fit to width of page. +#image("../../res/rhino.png") + +// Fit to height of page. +[ + #page(height: 40pt) + #image("../../res/rhino.png") +] + +// Set width explicitly. +#image("../../res/rhino.png", width: 50pt) + +// Set height explicitly. +#image("../../res/rhino.png", height: 50pt) + +// Set width and height explicitly and force stretching. +#image("../../res/rhino.png", width: 25pt, height: 50pt) + +// Make sure the bounding-box of the image is correct. +#align(bottom, right) +#image("../../res/tiger.jpg", width: 60pt) + +--- +// Error: 8-29 file not found +#image("path/does/not/exist") + +--- +// Error: 8-21 failed to load image (unknown image format) +#image("./image.typ") diff --git a/tests/typ/elements/rect.typ b/tests/typ/elements/rect.typ new file mode 100644 index 00000000..4824095a --- /dev/null +++ b/tests/typ/elements/rect.typ @@ -0,0 +1,27 @@ +// Test shapes. + +--- +// Test the `rect` function. + +#page(width: 150pt) + +// Fit to text. +#rect(fill: conifer)[Textbox] + +// Empty with fixed width and height. +#rect(width: 3cm, height: 12pt, fill: rgb("CB4CED")) + +// Fixed width, text height. +#rect(width: 2cm, fill: rgb("9650D6"), pad(5pt)[Fixed and padded]) + +// Page width, fixed height. +#rect(height: 1cm, width: 100%, fill: rgb("734CED"))[Topleft] + +// Not visible, but creates a gap between the boxes above and below +// due to line spacing. +#rect(width: 1in, fill: rgb("ff0000")) + +// These are in a row! +#rect(width: 0.5in, height: 10pt, fill: rgb("D6CD67")) +#rect(width: 0.5in, height: 10pt, fill: rgb("EDD466")) +#rect(width: 0.5in, height: 10pt, fill: rgb("E3BE62")) diff --git a/tests/typ/elements/square.typ b/tests/typ/elements/square.typ new file mode 100644 index 00000000..07dce4be --- /dev/null +++ b/tests/typ/elements/square.typ @@ -0,0 +1,34 @@ +// Test the `square` function. + +--- +// Test auto-sized square. +#square(fill: eastern)[ + #font(fill: white, weight: bold) + #align(center) + #pad(5pt)[Typst] +] +--- +// Test relative-sized child. +#square(fill: eastern)[ + #rect(width: 10pt, height: 5pt, fill: conifer) \ + #rect(width: 40%, height: 5pt, fill: conifer) +] + +--- +// Test height overflow. +#page(width: 75pt, height: 100pt) +#square(fill: conifer)[ + But, soft! what light through yonder window breaks? +] + +--- +// Test width overflow. +#page(width: 100pt, height: 75pt) +#square(fill: conifer)[ + But, soft! what light through yonder window breaks? +] + +--- +// Length wins over width and height. +// Error: 09-20 unexpected argument +#square(width: 10cm, height: 20cm, length: 1cm, fill: rgb("eb5278")) |
