diff --git a/src/elements/alu.typ b/src/elements/alu.typ index 1c1ddd8..b187f01 100644 --- a/src/elements/alu.typ +++ b/src/elements/alu.typ @@ -24,6 +24,7 @@ draw.anchor("south", (p2, 50%, p3)) draw.anchor("west", (p0, 50%, p3)) draw.anchor("east", (p1, 50%, p2)) + draw.anchor("name", (p5, 50%, (p1, 50%, p2))) }) let f2 = add-port(id, "west", (id: "in1"), (p0, 50%, p6)) diff --git a/src/elements/element.typ b/src/elements/element.typ index 5b6e31e..19c8a5e 100644 --- a/src/elements/element.typ +++ b/src/elements/element.typ @@ -1,5 +1,6 @@ #import "@preview/cetz:0.2.2": draw, coordinate #import "ports.typ": add-ports, add-port +#import "../util.typ" #let find-port(ports, id) = { for (side, side-ports) in ports { @@ -115,7 +116,7 @@ if (name != none) { draw.content( (name: id, anchor: name-anchor), - anchor: name-anchor, + anchor: if name-anchor in util.valid-anchors {name-anchor} else {"center"}, padding: 0.5em, align(center)[*#name*] ) diff --git a/src/util.typ b/src/util.typ index 2ee80ba..a444434 100644 --- a/src/util.typ +++ b/src/util.typ @@ -68,4 +68,9 @@ south-east: "south-west", south-west: "north-west" ).at(anchor) -} \ No newline at end of file +} + +#let valid-anchors = ( + "center", "north", "east", "west", "south", + "north-east", "north-west", "south-east", "south-west" +) \ No newline at end of file