adapted entity shape rendering

This commit is contained in:
2025-07-19 21:35:17 +02:00
parent b34702485f
commit cc161a5d40

View File

@ -1,20 +1,22 @@
#import "/src/cetz.typ": draw
#import "/src/core/utils.typ": normalize-measure
#import "/src/consts.typ": *
#import "/src/core/utils.typ": normalize-measure, normalize-units
#let name = "entity"
#let render(x, y, p, bottom) = {
let m = measure(p.display-name)
let m = normalize-measure(p.display-name)
let style = p.resolved-style
let r = ENTITY-HEIGHT / 2
let size = normalize-units(style.size)
let spacing = normalize-units(style.spacing)
let gap = normalize-units(style.gap)
let r = size / 2
let y0 = if bottom {
y - m.height / 1pt - SYM-GAP
y - m.height - spacing
} else {
y + m.height / 1pt + ENTITY-HEIGHT + SYM-GAP
y + m.height + size + spacing
}
let y1 = y0 - ENTITY-HEIGHT - 1.5
let y1 = y0 - size - gap
draw.circle(
(x, y0 - r),
@ -37,12 +39,19 @@
#let get-size(par) = {
let m = normalize-measure(par.display-name)
// ENTITY-HEIGHT * 1pt
// ENTITY-HEIGHT * 1pt + 2pt + SYM-GAP * 1pt + h
let m = normalize-measure(par.display-name)
return m
let size = normalize-units(par.resolved-style.size)
let spacing = normalize-units(par.resolved-style.spacing)
return (
width: calc.max(m.width, size),
height: size + spacing + m.height
)
}
#let default-style = (
:
size: 20pt,
gap: 1.5pt,
spacing: 5pt
)