diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-02-12 18:58:39 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-02-12 19:57:28 +0100 |
| commit | 3ffa7393f0632d9ee5dd9c821685a1a033d5c0ab (patch) | |
| tree | af09b0683352c4028436a2e5251dce54cf41d4aa /tests/typ/visualize | |
| parent | f4856c18b9cf3f6952276cc61b557aebeb2fa651 (diff) | |
Make all nodes block-level
Diffstat (limited to 'tests/typ/visualize')
| -rw-r--r-- | tests/typ/visualize/image.typ | 7 | ||||
| -rw-r--r-- | tests/typ/visualize/line.typ | 3 | ||||
| -rw-r--r-- | tests/typ/visualize/shape-aspect.typ | 55 | ||||
| -rw-r--r-- | tests/typ/visualize/shape-circle.typ | 25 | ||||
| -rw-r--r-- | tests/typ/visualize/shape-ellipse.typ | 8 | ||||
| -rw-r--r-- | tests/typ/visualize/shape-fill-stroke.typ | 2 | ||||
| -rw-r--r-- | tests/typ/visualize/shape-rect.typ | 26 | ||||
| -rw-r--r-- | tests/typ/visualize/shape-square.typ | 6 |
8 files changed, 77 insertions, 55 deletions
diff --git a/tests/typ/visualize/image.typ b/tests/typ/visualize/image.typ index 89381955..4b3d390f 100644 --- a/tests/typ/visualize/image.typ +++ b/tests/typ/visualize/image.typ @@ -14,8 +14,8 @@ // Test configuring the size and fitting behaviour of images. // Set width and height explicitly. -#image("/rhino.png", width: 30pt) -#image("/rhino.png", height: 30pt) +#box(image("/rhino.png", width: 30pt)) +#box(image("/rhino.png", height: 30pt)) // Set width and height explicitly and force stretching. #image("/monkey.svg", width: 100%, height: 20pt, fit: "stretch") @@ -38,13 +38,12 @@ --- // Does not fit to remaining height of page. #set page(height: 60pt) -Stuff #parbreak() Stuff #image("/rhino.png") --- // Test baseline. -A #image("/tiger.jpg", height: 1cm, width: 80%) B +A #box(image("/tiger.jpg", height: 1cm, width: 80%)) B --- // Test advanced SVG features. diff --git a/tests/typ/visualize/line.typ b/tests/typ/visualize/line.typ index a7bca613..8c405932 100644 --- a/tests/typ/visualize/line.typ +++ b/tests/typ/visualize/line.typ @@ -7,8 +7,7 @@ place(line(end: (0.4em, 0pt))) place(line(start: (0pt, 0.4em), end: (0pt, 0pt))) line(end: (0.6em, 0.6em)) -}) -Hello #line()! +}) Hello #box(line(length: 1cm))! #line(end: (70%, 50%)) diff --git a/tests/typ/visualize/shape-aspect.typ b/tests/typ/visualize/shape-aspect.typ index d2dc1140..d3606808 100644 --- a/tests/typ/visualize/shape-aspect.typ +++ b/tests/typ/visualize/shape-aspect.typ @@ -4,26 +4,35 @@ // Test relative width and height and size that is smaller // than default size. #set page(width: 120pt, height: 70pt) -#set align(center + horizon) -#square(width: 50%, [A]) -#square(height: 50%) -#box(stack( - square(size: 10pt), - square(size: 20pt, [B]) -)) +#set align(bottom) +#let centered = align.with(center + horizon) +#stack( + dir: ltr, + spacing: 1fr, + square(width: 50%, centered[A]), + square(height: 50%), + stack( + square(size: 10pt), + square(size: 20pt, centered[B]) + ), +) --- // Test alignment in automatically sized square and circle. #set text(8pt) -#square(inset: 4pt)[ +#box(square(inset: 4pt)[ Hey there, #align(center + bottom, rotate(180deg, [you!])) -] -#circle(align(center + horizon, [Hey.])) +]) +#box(circle(align(center + horizon, [Hey.]))) --- -// Test that maximum wins if both width and height are given. -#square(width: 10pt, height: 20pt) -#circle(width: 20%, height: 10pt) +// Test that minimum wins if both width and height are given. +#stack( + dir: ltr, + spacing: 2pt, + square(width: 20pt, height: 40pt), + circle(width: 20%, height: 100pt), +) --- // Test square that is limited by region size. @@ -33,18 +42,22 @@ --- // Test different ways of sizing. #set page(width: 120pt, height: 40pt) -#circle(radius: 5pt) -#circle(width: 10%) -#circle(height: 50%) +#stack( + dir: ltr, + spacing: 2pt, + circle(radius: 5pt), + circle(width: 10%), + circle(height: 50%), +) --- -// Test square that is overflowing due to its aspect ratio. -#set page(width: 40pt, height: 20pt, margin: 5pt) -#square(width: 100%) #parbreak() -#square(width: 100%)[Hey] +// Test that square doesn't overflow due to its aspect ratio. +#set page(width: 40pt, height: 25pt, margin: 5pt) +#square(width: 100%) +#square(width: 100%)[Hello there] --- // Size cannot be relative because we wouldn't know // relative to which axis. -// Error: 15-18 expected length, found ratio +// Error: 15-18 expected length or auto, found ratio #square(size: 50%) diff --git a/tests/typ/visualize/shape-circle.typ b/tests/typ/visualize/shape-circle.typ index 23c6fcbd..94facdeb 100644 --- a/tests/typ/visualize/shape-circle.typ +++ b/tests/typ/visualize/shape-circle.typ @@ -2,14 +2,14 @@ --- // Default circle. -#circle() -#circle[Hey] +#box(circle()) +#box(circle[Hey]) --- // Test auto sizing. #set circle(inset: 0pt) -Auto-sized circle. \ +Auto-sized circle. #circle(fill: rgb("eb5278"), stroke: 2pt + black, align(center + horizon)[But, soft!] ) @@ -21,7 +21,7 @@ Center-aligned rect in auto-sized circle. ) ) -Rect in auto-sized circle. \ +Rect in auto-sized circle. #circle(fill: forest, rect(fill: conifer, stroke: white, inset: 4pt)[ #set text(8pt) @@ -39,13 +39,18 @@ Expanded by height. --- // Test relative sizing. -#let centered(body) = align(center + horizon, body) #set text(fill: white) -#rect(width: 100pt, height: 50pt, inset: 0pt, 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 -]) +#show rect.with(width: 100pt, height: 50pt, inset: 0pt, fill: rgb("aaa")) +#set align(center + horizon) +#stack( + dir: ltr, + spacing: 1fr, + 1fr, + 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 + 1fr, +) --- // Radius wins over width and height. diff --git a/tests/typ/visualize/shape-ellipse.typ b/tests/typ/visualize/shape-ellipse.typ index 6447d1d0..2fd4acd9 100644 --- a/tests/typ/visualize/shape-ellipse.typ +++ b/tests/typ/visualize/shape-ellipse.typ @@ -8,7 +8,7 @@ #set rect(inset: 0pt) #set ellipse(inset: 0pt) -Rect in ellipse in fixed rect. \ +Rect in ellipse in fixed rect. #rect(width: 3cm, height: 2cm, fill: rgb("2a631a"), ellipse(fill: forest, width: 100%, height: 100%, rect(fill: conifer, width: 100%, height: 100%, @@ -19,11 +19,13 @@ Rect in ellipse in fixed rect. \ ) ) -Auto-sized ellipse. \ +Auto-sized ellipse. #ellipse(fill: conifer, stroke: 3pt + forest, inset: 3pt)[ #set text(8pt) But, soft! what light through yonder window breaks? ] -An inline #ellipse(width: 8pt, height: 6pt, outset: (top: 3pt, rest: 5.5pt)) ellipse. +An inline +#box(ellipse(width: 8pt, height: 6pt, outset: (top: 3pt, rest: 5.5pt))) +ellipse. diff --git a/tests/typ/visualize/shape-fill-stroke.typ b/tests/typ/visualize/shape-fill-stroke.typ index 8820a9fd..0edbd551 100644 --- a/tests/typ/visualize/shape-fill-stroke.typ +++ b/tests/typ/visualize/shape-fill-stroke.typ @@ -27,7 +27,7 @@ --- // Test stroke folding. -#let sq = square.with(size: 10pt) +#let sq(..args) = box(square(size: 10pt, ..args)) #set square(stroke: none) #sq() diff --git a/tests/typ/visualize/shape-rect.typ b/tests/typ/visualize/shape-rect.typ index ff80dfb9..a95f2750 100644 --- a/tests/typ/visualize/shape-rect.typ +++ b/tests/typ/visualize/shape-rect.typ @@ -24,19 +24,23 @@ #rect(height: 1cm, width: 100%, fill: rgb("734ced"))[Topleft] // These are inline with text. -{#rect(width: 0.5in, height: 7pt, fill: rgb("d6cd67")) - #rect(width: 0.5in, height: 7pt, fill: rgb("edd466")) - #rect(width: 0.5in, height: 7pt, fill: rgb("e3be62"))} +{#box(rect(width: 0.5in, height: 7pt, fill: rgb("d6cd67"))) + #box(rect(width: 0.5in, height: 7pt, fill: rgb("edd466"))) + #box(rect(width: 0.5in, height: 7pt, fill: rgb("e3be62")))} // Rounded corners. -#rect(width: 2cm, radius: 60%) -#rect(width: 1cm, radius: (left: 10pt, right: 5pt)) -#rect(width: 1.25cm, radius: ( - top-left: 2pt, - top-right: 5pt, - bottom-right: 8pt, - bottom-left: 11pt -)) +#stack( + dir: ltr, + spacing: 1fr, + rect(width: 2cm, radius: 60%), + rect(width: 1cm, radius: (left: 10pt, right: 5pt)), + rect(width: 1.25cm, radius: ( + top-left: 2pt, + top-right: 5pt, + bottom-right: 8pt, + bottom-left: 11pt + )), +) // Different strokes. #set rect(stroke: (right: red)) diff --git a/tests/typ/visualize/shape-square.typ b/tests/typ/visualize/shape-square.typ index 8ac9001f..cb6552e4 100644 --- a/tests/typ/visualize/shape-square.typ +++ b/tests/typ/visualize/shape-square.typ @@ -2,8 +2,8 @@ --- // Default square. -#square() -#square[hey!] +#box(square()) +#box(square[hey!]) --- // Test auto-sized square. @@ -15,7 +15,7 @@ --- // Test relative-sized child. #square(fill: eastern)[ - #rect(width: 10pt, height: 5pt, fill: conifer) \ + #rect(width: 10pt, height: 5pt, fill: conifer) #rect(width: 40%, height: 5pt, stroke: conifer) ] |
