refactored groups, separators and delays

This commit is contained in:
2025-07-14 17:23:49 +02:00
parent 32f3a6fe57
commit 886b6c2f3f
7 changed files with 202 additions and 180 deletions

View File

@ -1,9 +1,12 @@
#import "/src/cetz.typ": draw
#import "consts.typ": *
#import "core/draw/separator.typ"
#import "core/draw/delay.typ"
#let _sep(name) = {
return ((
type: "sep",
draw: separator.render,
name: name
),)
}
@ -11,53 +14,8 @@
#let _delay(name: none, size: 30) = {
return ((
type: "delay",
draw: delay.render,
name: name,
size: size
),)
}
#let render(x-pos, elmt, y) = {
let shapes = ()
y -= Y-SPACE
let x0 = x-pos.first() - 20
let x1 = x-pos.last() + 20
let m = measure(
box(
elmt.name,
inset: (left: 3pt, right: 3pt, top: 5pt, bottom: 5pt)
)
)
let w = m.width / 1pt
let h = m.height / 1pt
let cx = (x0 + x1) / 2
let xl = cx - w / 2
let xr = cx + w / 2
y -= h / 2
shapes += draw.rect(
(x0, y),
(x1, y - 3),
stroke: none,
fill: white
)
shapes += draw.line((x0, y), (x1, y))
//shapes += draw.line((x0, y), (xl, y))
//shapes += draw.line((xr, y), (x1, y))
y -= 3
shapes += draw.line((x0, y), (x1, y))
//shapes += draw.line((x0, y), (xl, y))
//shapes += draw.line((xr, y), (x1, y))
shapes += draw.content(
((x0 + x1) / 2, y + 1.5),
elmt.name,
anchor: "center",
padding: (5pt, 3pt),
frame: "rect",
fill: COL-SEP-NAME
)
y -= h / 2
let r = (y, shapes)
return r
}