adapted boundary shape rendering
This commit is contained in:
@ -1,22 +1,23 @@
|
|||||||
#import "/src/cetz.typ": draw
|
#import "/src/cetz.typ": draw
|
||||||
|
|
||||||
#import "/src/core/utils.typ": normalize-measure
|
#import "/src/core/utils.typ": normalize-measure, normalize-units
|
||||||
#import "/src/consts.typ": *
|
|
||||||
|
|
||||||
#let name = "boundary"
|
#let name = "boundary"
|
||||||
|
|
||||||
#let render(x, y, p, bottom) = {
|
#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 style = p.resolved-style
|
||||||
let circle-r = BOUNDARY-HEIGHT / 2
|
let height = normalize-units(style.height)
|
||||||
|
let spacing = normalize-units(style.spacing)
|
||||||
|
let circle-r = height / 2
|
||||||
let y0 = if bottom {
|
let y0 = if bottom {
|
||||||
y - m.height / 1pt - SYM-GAP
|
y - m.height - spacing
|
||||||
} else {
|
} else {
|
||||||
y + m.height / 1pt + BOUNDARY-HEIGHT + SYM-GAP
|
y + m.height + height + spacing
|
||||||
}
|
}
|
||||||
let x0 = x - BOUNDARY-HEIGHT
|
let x0 = x - height
|
||||||
let y1 = y0 - circle-r
|
let y1 = y0 - circle-r
|
||||||
let y2 = y0 - BOUNDARY-HEIGHT
|
let y2 = y0 - height
|
||||||
|
|
||||||
draw.circle(
|
draw.circle(
|
||||||
(x + circle-r, y1),
|
(x + circle-r, y1),
|
||||||
@ -42,12 +43,17 @@
|
|||||||
#let get-size(par) = {
|
#let get-size(par) = {
|
||||||
let m = normalize-measure(par.display-name)
|
let m = normalize-measure(par.display-name)
|
||||||
|
|
||||||
// BOUNDARY-HEIGHT * 2pt
|
let height = normalize-units(par.resolved-style.height)
|
||||||
// BOUNDARY-HEIGHT * 1pt + SYM-GAP * 1pt + h
|
let width = height * 2
|
||||||
|
let spacing = normalize-units(par.resolved-style.spacing)
|
||||||
|
|
||||||
return m
|
return (
|
||||||
|
width: calc.max(m.width, width),
|
||||||
|
height: height + spacing + m.height
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#let default-style = (
|
#let default-style = (
|
||||||
:
|
height: 20pt,
|
||||||
|
spacing: 5pt
|
||||||
)
|
)
|
Reference in New Issue
Block a user