From 8c91ccdd5421e9fcdbc0017270d1b8b89a78659f Mon Sep 17 00:00:00 2001 From: juanbono Date: Sat, 28 Jun 2025 11:40:36 -0300 Subject: [PATCH] improve default-draw-shape by drawing a rectangle --- src/elements/logic/iec_gate.typ | 40 +++++++++------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) diff --git a/src/elements/logic/iec_gate.typ b/src/elements/logic/iec_gate.typ index 3334d11..31766d2 100644 --- a/src/elements/logic/iec_gate.typ +++ b/src/elements/logic/iec_gate.typ @@ -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( + let shapes = draw.rect( + inset: 0.5em, + fill: fill, + stroke: stroke, name: id, - { - draw.merge-path( - inset: 0.5em, - fill: fill, - stroke: stroke, - name: id + "-path", - close: true, - { - draw.line(bl, tl, tr, br) - }, - ) - - draw.content( - (x + width / 2, y + height / 2), - padding: 0.5em, - align(center)[*$ symbol $*], - ) - - draw.anchor("north", t) - draw.anchor("south", b) - }, + bl, tr ) - return (f, tl, tr, br, bl) + shapes += draw.content( + id + ".center", + [*$ symbol $*] + ) + 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")