1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
// Test the `square` function.
--- square ---
// Default square.
#box(square())
#box(square[hey!])
--- square-auto-sized ---
// Test auto-sized square.
#square(fill: eastern)[
#set text(fill: white, weight: "bold")
Typst
]
--- square-relatively-sized-child ---
// Test relative-sized child.
#square(fill: eastern)[
#rect(width: 10pt, height: 5pt, fill: conifer)
#rect(width: 40%, height: 5pt, stroke: conifer)
]
--- square-contents-overflow ---
// Test text overflowing height.
#set page(width: 75pt, height: 100pt)
#square(fill: conifer)[
But, soft! what light through yonder window breaks?
]
--- square-height-limited ---
// Test that square does not overflow page.
#set page(width: 100pt, height: 75pt)
#square(fill: conifer)[
But, soft! what light through yonder window breaks?
]
--- square-size-width-and-height ---
// Size wins over width and height.
// Error: 09-20 unexpected argument: width
#square(width: 10cm, height: 20cm, size: 1cm, fill: rgb("eb5278"))
--- square-relative-size ---
// Test relative width and height and size that is smaller
// than default size.
#set page(width: 120pt, height: 70pt)
#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])
),
)
--- square-circle-alignment ---
// Test alignment in automatically sized square and circle.
#set text(8pt)
#box(square(inset: 4pt)[
Hey there, #align(center + bottom, rotate(180deg, [you!]))
])
#box(circle(align(center + horizon, [Hey.])))
--- square-circle-overspecified ---
// 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: 40pt),
)
--- square-height-limited-stack ---
// Test square that is limited by region size.
#set page(width: 20pt, height: 10pt, margin: 0pt)
#stack(dir: ltr, square(fill: forest), square(fill: conifer))
--- square-overflow ---
// 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]
--- square-size-relative-invalid ---
// Size cannot be relative because we wouldn't know
// relative to which axis.
// Error: 15-18 expected length or auto, found ratio
#square(size: 50%)
--- square-rect-rounded ---
#set square(size: 20pt, stroke: 4pt)
// no radius for non-rounded corners
#stack(
dir: ltr,
square(),
h(10pt),
square(radius: 0pt),
h(10pt),
square(radius: -10pt),
)
#stack(
dir: ltr,
square(),
h(10pt),
square(radius: 0%),
h(10pt),
square(radius: -10%),
)
// small values for small radius
#stack(
dir: ltr,
square(radius: 1pt),
h(10pt),
square(radius: 5%),
h(10pt),
square(radius: 2pt),
)
// large values for large radius or circle
#stack(
dir: ltr,
square(radius: 8pt),
h(10pt),
square(radius: 10pt),
h(10pt),
square(radius: 12pt),
)
#stack(
dir: ltr,
square(radius: 45%),
h(10pt),
square(radius: 50%),
h(10pt),
square(radius: 55%),
)
--- square-base ---
// Test that square sets correct base for its content.
#set page(height: 80pt)
#square(width: 40%, rect(width: 60%, height: 80%))
|