Files
chronos/src/core/draw/sync.typ
2025-07-15 12:36:30 +02:00

32 lines
637 B
Typst

#import "/src/core/utils.typ": get-ctx, is-elmt, set-ctx
#let render(sync) = get-ctx(ctx => {
set-ctx(c => {
c.sync-ys = ()
return c
})
for e in sync.elmts {
assert(is-elmt(e), message: "Sync element can only contain chronos elements, found " + repr(e))
assert(
e.type == "seq",
message: "Sync element can only contain sequences, found '" + e.type + "'"
)
set-ctx(c => {
c.y = ctx.y
return c
})
(e.draw)(e)
set-ctx(c => {
c.sync-ys.push(c.y)
return c
})
}
set-ctx(c => {
c.y = calc.min(..c.sync-ys)
c.remove("sync-ys")
return c
})
})