Skip to content

Commit 4fb9a6f

Browse files
committed
Cetz 0.5.x Compatibility
1 parent 8002618 commit 4fb9a6f

14 files changed

Lines changed: 23 additions & 7 deletions

File tree

src/cetz.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// Import cetz into the root scope. Import cetz by importing this file only!
2-
#import "@preview/cetz:0.4.2": *
2+
#import "@preview/cetz:0.5.2": *

src/chart/piechart.typ

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#import "/src/cetz.typ": draw, styles, palette, util, vector, intersection
2-
#import util: circle-arclen
3-
42
#import "/src/plot/legend.typ"
53

64
// Piechart Label Kind
@@ -344,6 +342,10 @@
344342
continue
345343
}
346344

345+
let circle-arclen(radius, angle: 90deg) = {
346+
calc.abs(angle / 360deg * 2 * calc.pi * radius)
347+
}
348+
347349
// A sharp item is an item that should be round but is sharp due to the gap being big
348350
let is-sharp = inner-radius == 0 or circle-arclen(inner-radius, angle: inner-angle) > circle-arclen(radius, angle: outer-angle)
349351

src/plot.typ

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
legend-style: (:),
203203
..options
204204
) = draw.group(name: name, ctx => {
205-
draw.assert-version(version(0, 4, 2))
205+
draw.assert-version(version(0, 5, 0), max: version(0, 6, 0))
206206

207207
// Create plot context object
208208
let make-ctx(x, y, size) = {
@@ -233,7 +233,14 @@
233233
if y.horizontal {
234234
(x, y) = (y, x)
235235
body = draw.set-ctx(ctx => {
236-
ctx.transform = matrix.swap-cols(ctx.transform, 0, 1)
236+
let ((x0, x1, x2, x3),
237+
(y0, y1, y2, y3),
238+
(z0, z1, z2, z3),
239+
(w0, w1, w2, w3)) = ctx.transform
240+
ctx.transform = ((x1, x0, x2, x3),
241+
(y1, y0, y2, y3),
242+
(z1, z0, z2, z3),
243+
(w1, w0, w2, w3))
237244
return ctx
238245
}) + body
239246
}
@@ -451,7 +458,14 @@
451458
draw.scope({
452459
if y.horizontal {
453460
draw.set-ctx(ctx => {
454-
ctx.transform = matrix.swap-cols(ctx.transform, 0, 1)
461+
let ((x0, x1, x2, x3),
462+
(y0, y1, y2, y3),
463+
(z0, z1, z2, z3),
464+
(w0, w1, w2, w3)) = ctx.transform
465+
ctx.transform = ((x1, x0, x2, x3),
466+
(y1, y0, y2, y3),
467+
(z1, z0, z2, z3),
468+
(w1, w0, w2, w3))
455469
return ctx
456470
})
457471
}

src/plot/legend.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170

171171
// Draw item preview
172172
let draw-preview = if preview == auto { draw-generic-preview } else { preview }
173-
scope({
173+
group({ // BUG: scope in group seems to be bugged, we use group instead
174174
set-viewport(preview-a, preview-b, bounds: (1, 1, 0))
175175
(draw-preview)(item)
176176
})

tests/axes/log-mode/ref/1.png

-6 Bytes
Loading

tests/axes/self/ref/1.png

45 Bytes
Loading

tests/chart/boxwhisker/ref/1.png

456 Bytes
Loading

tests/chart/piechart/ref/1.png

-133 Bytes
Loading

tests/chart/self/ref/1.png

6.76 KB
Loading

tests/plot/legend/ref/1.png

-155 Bytes
Loading

0 commit comments

Comments
 (0)