forked from HEL/chronos
adapted database shape rendering
This commit is contained in:
@ -1,20 +1,21 @@
|
|||||||
#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 = "database"
|
#let name = "database"
|
||||||
|
|
||||||
#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 height = DATABASE-WIDTH * 4 / 3
|
let width = normalize-units(style.width)
|
||||||
let rx = DATABASE-WIDTH / 2
|
let spacing = normalize-units(style.spacing)
|
||||||
|
let height = width * 4 / 3
|
||||||
|
let rx = width / 2
|
||||||
let ry = rx / 2
|
let ry = rx / 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 + height + SYM-GAP
|
y + m.height + height + spacing
|
||||||
}
|
}
|
||||||
let y1 = y0 - height
|
let y1 = y0 - height
|
||||||
|
|
||||||
@ -47,12 +48,17 @@
|
|||||||
#let get-size(par) = {
|
#let get-size(par) = {
|
||||||
let m = normalize-measure(par.display-name)
|
let m = normalize-measure(par.display-name)
|
||||||
|
|
||||||
// DATABASE-WIDTH * 1pt
|
let width = normalize-units(par.resolved-style.width)
|
||||||
// DATABASE-WIDTH * 4pt / 3 + SYM-GAP * 1pt + h
|
let height = width * 4 / 3
|
||||||
|
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 = (
|
||||||
:
|
width: 24pt,
|
||||||
|
spacing: 5pt
|
||||||
)
|
)
|
@ -39,8 +39,6 @@
|
|||||||
#let get-size(par) = {
|
#let get-size(par) = {
|
||||||
let m = normalize-measure(par.display-name)
|
let m = normalize-measure(par.display-name)
|
||||||
|
|
||||||
let m = normalize-measure(par.display-name)
|
|
||||||
|
|
||||||
let size = normalize-units(par.resolved-style.size)
|
let size = normalize-units(par.resolved-style.size)
|
||||||
let spacing = normalize-units(par.resolved-style.spacing)
|
let spacing = normalize-units(par.resolved-style.spacing)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user