From 89f2e71852e96062ea9b756bf92fbf4e894871b1 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Wed, 17 Nov 2021 17:09:19 +0100 Subject: Align node --- tests/typ/elements/circle.typ | 21 ++++++++++++--------- tests/typ/elements/ellipse.typ | 9 +++++---- tests/typ/elements/image.typ | 3 +-- tests/typ/elements/square.typ | 3 +-- 4 files changed, 19 insertions(+), 17 deletions(-) (limited to 'tests/typ/elements') 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. @@ -30,15 +29,19 @@ Rect in auto-sized circle. \ 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]) ] --- -- cgit v1.2.3