refactored setup-ctx to use CeTZ context

This commit is contained in:
2025-07-28 18:54:04 +02:00
parent 1db922d44d
commit a24681827e
2 changed files with 96 additions and 72 deletions

View File

@@ -54,8 +54,10 @@
return style
}
#let pre-resolve-styles(ctx, elements, participants) = {
#let pre-resolve-styles() = get-ctx(ctx => {
let idx = (:)
let elements = ctx.setup.elements
let participants = ctx.setup.participants
for (i, par) in participants.enumerate() {
par.insert("resolved-style", resolve-style(ctx, par))
participants.at(i) = par
@@ -65,7 +67,7 @@
if type(elmt) == function {
ctx = elmt(ctx).ctx
} else if is-elmt(elmt) {
if elmt.type == par {
if elmt.type == "par" {
let style = resolve-style(ctx, elmt)
elements.at(i).insert("resolved-style", style)
let i = idx.at(elmt.name)
@@ -73,12 +75,17 @@
}
}
}
return (elements, participants)
}
set-ctx(c => {
c.setup.elements = elements
c.setup.participants = participants
return c
})
})
#let get-size(par) = {
if par.invisible {
return (width: 0pt, height: 0pt)
return (width: 0, height: 0)
}
let style = par.resolved-style
let func = shapes.at(style.shape).get-size