improve default-draw-shape by drawing a rectangle

This commit is contained in:
2025-06-28 11:40:36 -03:00
parent 9966656e8b
commit 8c91ccdd54

View File

@ -3,40 +3,20 @@
#import "../element.typ"
#let default-draw-shape(id, tl, tr, br, bl, fill, stroke, symbol) = {
let (x, y) = bl
let (width, height) = (tr.at(0) - x, tr.at(1) - y)
let t = (x + width / 2, y + height)
let b = (x + width / 2, y)
let f = draw.group(
name: id,
{
draw.merge-path(
let shapes = draw.rect(
inset: 0.5em,
fill: fill,
stroke: stroke,
name: id + "-path",
close: true,
{
draw.line(bl, tl, tr, br)
},
name: id,
bl, tr
)
draw.content(
(x + width / 2, y + height / 2),
padding: 0.5em,
align(center)[*$ symbol $*],
shapes += draw.content(
id + ".center",
[*$ symbol $*]
)
draw.anchor("north", t)
draw.anchor("south", b)
},
)
return (f, tl, tr, br, bl)
return (shapes, tl, tr, br, bl)
}
/// Draws a logic gate. This function is also available as `element.iec-gate()`
///
/// - draw-shape (function): see #doc-ref("element.elmt")