refactored sequences, sync and gaps
This commit is contained in:
32
src/core/draw/sync.typ
Normal file
32
src/core/draw/sync.typ
Normal file
@ -0,0 +1,32 @@
|
||||
#import "../utils.typ": get-ctx, set-ctx, is-elmt
|
||||
|
||||
#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
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user