restructured code in separated files
This commit is contained in:
46
src/separator.typ
Normal file
46
src/separator.typ
Normal file
@ -0,0 +1,46 @@
|
||||
#import "@preview/cetz:0.2.2": draw
|
||||
#import "consts.typ": *
|
||||
|
||||
#let _sep(name) = {
|
||||
return ((
|
||||
type: "sep",
|
||||
name: name
|
||||
),)
|
||||
}
|
||||
|
||||
#let render(x-pos, elmt, y) = {
|
||||
let shapes = ()
|
||||
|
||||
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.line((x0, y), (xl, y))
|
||||
shapes += draw.line((xr, y), (x1, y))
|
||||
y -= 3
|
||||
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"
|
||||
)
|
||||
y -= h / 2
|
||||
y -= Y-SPACE
|
||||
|
||||
let r = (y, shapes)
|
||||
return r
|
||||
}
|
Reference in New Issue
Block a user