initial rewrite of drawing pipeline + positioning

This commit is contained in:
2025-04-18 17:25:38 +02:00
parent 2bb7e3b5a9
commit 358de4825d
6 changed files with 536 additions and 124 deletions

View File

@ -1,16 +1,15 @@
#import "@preview/cetz:0.3.2": draw
#import "element.typ"
#let draw-shape(id, tl, tr, br, bl, fill, stroke) = {
#let draw-shape(elmt, bounds) = {
let f = draw.rect(
radius: 0.5em,
inset: 0.5em,
fill: fill,
stroke: stroke,
name: id,
bl, tr
fill: elmt.fill,
stroke: elmt.stroke,
bounds.bl, bounds.tr
)
return (f, tl, tr, br, bl)
return (f, bounds)
}
/// Draws a block element
@ -18,32 +17,8 @@
/// #examples.block
/// For parameters description, see #doc-ref("element.elmt")
#let block(
x: none,
y: none,
w: none,
h: none,
name: none,
name-anchor: "center",
ports: (),
ports-margins: (),
fill: none,
stroke: black + 1pt,
id: "",
debug: (
ports: false
)
..args
) = element.elmt(
draw-shape: draw-shape,
x: x,
y: y,
w: w,
h: h,
name: name,
name-anchor: name-anchor,
ports: ports,
ports-margins: ports-margins,
fill: fill,
stroke: stroke,
id: id,
debug: debug
..args
)