Skip to content

Commit 4d75db0

Browse files
smartart: Cycles tests and curved arrows bugfix (#141)
2 parents 3106b1d + 8edaa57 commit 4d75db0

File tree

6 files changed

+227
-1
lines changed

6 files changed

+227
-1
lines changed

src/smartart/common.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@
373373
}
374374
draw.group(name: name, ctx => {
375375
let pre-end-angle = end-angle - arrow-angle
376-
let mid-angle = start-angle + angle-range / 2
376+
let mid-angle = start-angle + (angle-range - arrow-angle) / 2
377377
let radius-int = radius - h4
378378
let radius-ext = radius + h4
379379
let radius-int2 = radius - h2

tests/smartart/cycle/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# generated by tytanic, do not edit
2+
3+
diff/**
4+
out/**

tests/smartart/cycle/ref/1.png

32.8 KB
Loading

tests/smartart/cycle/ref/2.png

61.2 KB
Loading

tests/smartart/cycle/ref/3.png

137 KB
Loading

tests/smartart/cycle/test.typ

Lines changed: 222 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,222 @@
1+
#set page(width: auto, height: auto)
2+
#import "/src/cetz.typ": *
3+
#import "/src/lib.typ": *
4+
#import smartart: cycle
5+
#import "/tests/helper.typ": *
6+
7+
#let colors = gradient.linear(rgb("FFCCE5"), rgb("660033"))
8+
9+
// Gradient + variable number of steps
10+
#let make-test-case(func, min: 2, max: 5) = test-case(
11+
func,
12+
args: range(min, max + 1).map(i => (
13+
steps: range(1, i + 1).map(str)
14+
))
15+
)
16+
17+
// Default
18+
#make-test-case(args => {
19+
import draw: *
20+
cycle.basic(args.steps)
21+
}, max: 6)
22+
23+
#pagebreak()
24+
25+
#let steps = ([A], [B], [C], [D], [E])
26+
27+
#let defaults() = draw.set-style(
28+
cycle-basic: (
29+
steps: (
30+
fill: rgb("#156082"),
31+
stroke: none
32+
),
33+
arrows: (
34+
fill: rgb("#156082"),
35+
stroke: rgb("#156082")
36+
)
37+
)
38+
)
39+
// Thin curved
40+
#test-case({
41+
defaults()
42+
smartart.cycle.basic(
43+
steps,
44+
arrows: (
45+
thickness: none
46+
),
47+
step-style: none
48+
)
49+
})
50+
51+
// No frame
52+
#test-case({
53+
defaults()
54+
smartart.cycle.basic(
55+
steps.map(text.with(fill: black)),
56+
step-style: none,
57+
steps: (shape: none)
58+
)
59+
})
60+
61+
// Square frame + thick curved arrows
62+
#test-case({
63+
defaults()
64+
smartart.cycle.basic(
65+
steps,
66+
step-style: none,
67+
arrows: (
68+
fill: rgb("#AAB6C1"),
69+
stroke: none
70+
)
71+
)
72+
})
73+
74+
// Circle frame + thick straight arrows
75+
#test-case({
76+
defaults()
77+
smartart.cycle.basic(
78+
steps,
79+
step-style: none,
80+
steps: (
81+
shape: "circle"
82+
),
83+
arrows: (
84+
fill: rgb("#AAB6C1"),
85+
stroke: none,
86+
curved: false
87+
)
88+
)
89+
})
90+
91+
// Circle frame + thin straight arrows
92+
#test-case({
93+
defaults()
94+
smartart.cycle.basic(
95+
steps,
96+
step-style: none,
97+
steps: (
98+
shape: "circle"
99+
),
100+
arrows: (
101+
thickness: none,
102+
curved: false
103+
)
104+
)
105+
})
106+
107+
// Square frame + thick double straight arrows
108+
#test-case({
109+
defaults()
110+
smartart.cycle.basic(
111+
steps,
112+
step-style: none,
113+
arrows: (
114+
fill: rgb("#AAB6C1"),
115+
stroke: none,
116+
curved: false,
117+
double: true
118+
)
119+
)
120+
})
121+
122+
// Square frame + thick double curved arrows
123+
#test-case({
124+
defaults()
125+
smartart.cycle.basic(
126+
steps,
127+
step-style: none,
128+
arrows: (
129+
fill: rgb("#AAB6C1"),
130+
stroke: none,
131+
curved: true,
132+
double: true
133+
)
134+
)
135+
})
136+
137+
// Square frame + thick counter clockwise curved arrows
138+
#test-case({
139+
defaults()
140+
smartart.cycle.basic(
141+
steps,
142+
step-style: none,
143+
ccw: true
144+
)
145+
})
146+
147+
// Square frame + thin double straight arrows
148+
#test-case({
149+
defaults()
150+
smartart.cycle.basic(
151+
steps,
152+
step-style: none,
153+
arrows: (
154+
thickness: none,
155+
curved: false,
156+
double: true
157+
)
158+
)
159+
})
160+
161+
#pagebreak()
162+
163+
// Radius
164+
#test-case({
165+
defaults()
166+
smartart.cycle.basic(
167+
steps,
168+
step-style: none,
169+
radius: 3
170+
)
171+
})
172+
173+
#let steps = ([Short], [Longer], [Very long], [High\ step\ ...])
174+
175+
// Equal-width / Equal-height
176+
#test-case(args => {
177+
defaults()
178+
smartart.cycle.basic(
179+
steps,
180+
step-style: none,
181+
equal-width: args.eq-w,
182+
equal-height: args.eq-h
183+
)
184+
}, args: (
185+
(eq-w: false, eq-h: false),
186+
(eq-w: true, eq-h: false),
187+
(eq-w: false, eq-h: true),
188+
(eq-w: true, eq-h: true)
189+
))
190+
191+
// Steps max-width
192+
#test-case(args => {
193+
defaults()
194+
smartart.cycle.basic(
195+
steps,
196+
step-style: none,
197+
steps: (
198+
max-width: args.max-w
199+
)
200+
)
201+
}, args: (
202+
(max-w: 5em),
203+
(max-w: 8em),
204+
))
205+
206+
// Offset angle
207+
#test-case(args => {
208+
defaults()
209+
smartart.cycle.basic(
210+
steps,
211+
step-style: none,
212+
offset-angle: args.angle,
213+
ccw: args.ccw
214+
)
215+
}, args: (
216+
(angle: 0deg, ccw: false),
217+
(angle: 15deg, ccw: false),
218+
(angle: -20deg, ccw: false),
219+
(angle: 0deg, ccw: true),
220+
(angle: 15deg, ccw: true),
221+
(angle: -20deg, ccw: true),
222+
))

0 commit comments

Comments
 (0)