diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-11-17 17:09:19 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-11-17 17:09:19 +0100 |
| commit | 89f2e71852e96062ea9b756bf92fbf4e894871b1 (patch) | |
| tree | 836099ebd17adf30a24fc62464dfdd3d9c248480 /tests/typ/elements | |
| parent | 9a800daa82833c57eee04e92c701ca9a05a67d3b (diff) | |
Align node
Diffstat (limited to 'tests/typ/elements')
| -rw-r--r-- | tests/typ/elements/circle.typ | 21 | ||||
| -rw-r--r-- | tests/typ/elements/ellipse.typ | 9 | ||||
| -rw-r--r-- | tests/typ/elements/image.typ | 3 | ||||
| -rw-r--r-- | tests/typ/elements/square.typ | 3 |
4 files changed, 19 insertions, 17 deletions
diff --git a/tests/typ/elements/circle.typ b/tests/typ/elements/circle.typ index 4413d0d9..5be9cf56 100644 --- a/tests/typ/elements/circle.typ +++ b/tests/typ/elements/circle.typ @@ -9,8 +9,7 @@ Auto-sized circle. \ #circle(fill: rgb("eb5278"))[ - #align(center, center) - But, soft! + #align(center, center)[But, soft!] ] Center-aligned rect in auto-sized circle. @@ -31,14 +30,18 @@ Expanded by height. #circle(fill: conifer)[A \ B \ C] --- +// Ensure circle directly in rect works. +#rect(width: 40pt, height: 30pt, circle(fill: forest)) + +--- // Test relative sizing. -#rect(width: 100pt, height: 50pt, fill: rgb("aaa"))[ - #align(center, center) - #font(fill: white) - #circle(radius: 10pt, fill: eastern)[A] // D=20pt - #circle(height: 60%, fill: eastern)[B] // D=30pt - #circle(width: 20% + 20pt, fill: eastern)[C] // D=40pt -] +#let centered(body) = align(center, center, body) +#font(fill: white) +#rect(width: 100pt, height: 50pt, fill: rgb("aaa"), centered[ + #circle(radius: 10pt, fill: eastern, centered[A]) // D=20pt + #circle(height: 60%, fill: eastern, centered[B]) // D=30pt + #circle(width: 20% + 20pt, fill: eastern, centered[C]) // D=40pt +]) --- // Radius wins over width and height. diff --git a/tests/typ/elements/ellipse.typ b/tests/typ/elements/ellipse.typ index 3c8572b1..9c36fb1c 100644 --- a/tests/typ/elements/ellipse.typ +++ b/tests/typ/elements/ellipse.typ @@ -8,10 +8,11 @@ Rect in ellipse in fixed rect. \ #rect(width: 3cm, height: 2cm, fill: rgb("2a631a"), ellipse(fill: forest, - rect(fill: conifer)[ - #align(center, center) - Stuff inside an ellipse! - ] + rect(fill: conifer, + align(center, center)[ + Stuff inside an ellipse! + ] + ) ) ) diff --git a/tests/typ/elements/image.typ b/tests/typ/elements/image.typ index 43f93baf..84260a28 100644 --- a/tests/typ/elements/image.typ +++ b/tests/typ/elements/image.typ @@ -21,8 +21,7 @@ #image("../../res/tiger.jpg", 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) +#align(bottom, right, image("../../res/tiger.jpg", width: 40pt)) --- // Test all three fit modes. diff --git a/tests/typ/elements/square.typ b/tests/typ/elements/square.typ index 3686debb..3163f872 100644 --- a/tests/typ/elements/square.typ +++ b/tests/typ/elements/square.typ @@ -9,8 +9,7 @@ // Test auto-sized square. #square(fill: eastern)[ #font(fill: white, weight: "bold") - #align(center) - #pad(5pt)[Typst] + #align(center, pad(5pt)[Typst]) ] --- |
