forked from HEL/circuiteria
feat: Add port-name-padding parameter
Replaces the hard-coded 2pt padding used when placing port name labels. Configurable per element via port-name-padding on elmt (forwarded by block and group), defaulting to 2pt to preserve existing layout.
This commit is contained in:
1 parent
0d1478c765
commit
563bb7b1d2
8 files changed
+6952
-6733
No files matched your search
@@ -196,6 +196,7 @@ element.group(
|
|||||||
fill: util.colors.blue.lighten(60%),
|
fill: util.colors.blue.lighten(60%),
|
||||||
padding: 2em,
|
padding: 2em,
|
||||||
outside-port-names: true,
|
outside-port-names: true,
|
||||||
|
port-name-padding: 4pt,
|
||||||
ports: (
|
ports: (
|
||||||
west: ((id: "in", name: "D"),),
|
west: ((id: "in", name: "D"),),
|
||||||
east: ((id: "out", name: "Q"),),
|
east: ((id: "out", name: "Q"),),
|
||||||
@@ -209,12 +210,14 @@ wire.wire("wG1in", ("g1-port-in", "b1-port-d"), directed: true)
|
|||||||
wire.wire("wG1out", ("b1-port-q", "g1-port-out"), directed: true)
|
wire.wire("wG1out", ("b1-port-q", "g1-port-out"), directed: true)
|
||||||
|
|
||||||
// outside-port-names: false — labels inside the border (block style)
|
// outside-port-names: false — labels inside the border (block style)
|
||||||
|
// with extra padding via port-name-padding
|
||||||
element.group(
|
element.group(
|
||||||
id: "g2", name: "inside",
|
id: "g2", name: "inside",
|
||||||
stroke: (dash: "dashed"),
|
stroke: (dash: "dashed"),
|
||||||
fill: util.colors.orange.lighten(60%),
|
fill: util.colors.orange.lighten(60%),
|
||||||
padding: 2em,
|
padding: 2em,
|
||||||
outside-port-names: false,
|
outside-port-names: false,
|
||||||
|
port-name-padding: 0.4em,
|
||||||
ports: (
|
ports: (
|
||||||
west: ((id: "in", name: "D"),),
|
west: ((id: "in", name: "D"),),
|
||||||
east: ((id: "out", name: "Q"),),
|
east: ((id: "out", name: "Q"),),
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
@@ -6,7 +6,7 @@
|
|||||||
#set page(width: auto, height: auto, margin: .5cm)
|
#set page(width: auto, height: auto, margin: .5cm)
|
||||||
|
|
||||||
#circuit({
|
#circuit({
|
||||||
// --- Group with port labels OUTSIDE (default) ---
|
// --- Group with port labels INSIDE (outside-port-names: false) ---
|
||||||
element.group(
|
element.group(
|
||||||
id: "cpu",
|
id: "cpu",
|
||||||
name: "CPU (labels outside)",
|
name: "CPU (labels outside)",
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
stroke: (dash: "dashed"),
|
stroke: (dash: "dashed"),
|
||||||
fill: util.colors.yellow.lighten(60%),
|
fill: util.colors.yellow.lighten(60%),
|
||||||
padding: 1em,
|
padding: 1em,
|
||||||
|
port-name-padding: .5em,
|
||||||
outside-port-names: true,
|
outside-port-names: true,
|
||||||
ports: (
|
ports: (
|
||||||
west: (
|
west: (
|
||||||
@@ -51,6 +52,7 @@
|
|||||||
fill: util.colors.yellow.lighten(60%),
|
fill: util.colors.yellow.lighten(60%),
|
||||||
padding: 4em,
|
padding: 4em,
|
||||||
outside-port-names: false,
|
outside-port-names: false,
|
||||||
|
port-name-padding: 0.5em,
|
||||||
ports: (
|
ports: (
|
||||||
west: (
|
west: (
|
||||||
(id: "in1", name: "D1"),
|
(id: "in1", name: "D1"),
|
||||||
|
|||||||
+6933
-6730
File diff suppressed because it is too large.
Load diff
@@ -27,6 +27,7 @@
|
|||||||
name-anchor: "center",
|
name-anchor: "center",
|
||||||
ports: (),
|
ports: (),
|
||||||
ports-margins: (),
|
ports-margins: (),
|
||||||
|
port-name-padding: 2pt,
|
||||||
fill: none,
|
fill: none,
|
||||||
radius: 0.5em,
|
radius: 0.5em,
|
||||||
stroke: black + 1pt,
|
stroke: black + 1pt,
|
||||||
@@ -44,6 +45,7 @@
|
|||||||
name-anchor: name-anchor,
|
name-anchor: name-anchor,
|
||||||
ports: ports,
|
ports: ports,
|
||||||
ports-margins: ports-margins,
|
ports-margins: ports-margins,
|
||||||
|
port-name-padding: port-name-padding,
|
||||||
fill: fill,
|
fill: fill,
|
||||||
stroke: stroke,
|
stroke: stroke,
|
||||||
id: id,
|
id: id,
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
/// - `clock` (`bool`): Whether it is a clock port (triangle symbol)
|
/// - `clock` (`bool`): Whether it is a clock port (triangle symbol)
|
||||||
/// - `vertical` (`bool`): Whether the name should be drawn vertically
|
/// - `vertical` (`bool`): Whether the name should be drawn vertically
|
||||||
/// - ports-margins (dictionary): Dictionary of ports margins (used with automatic port placement). They keys are cardinal directions ("north", "east", "south", "west"). The values are tuples of (`<start>`, `<end>`) margins (numbers)
|
/// - ports-margins (dictionary): Dictionary of ports margins (used with automatic port placement). They keys are cardinal directions ("north", "east", "south", "west"). The values are tuples of (`<start>`, `<end>`) margins (numbers)
|
||||||
|
/// - port-name-padding (number, length): Padding between the port name label and the port anchor point (default `2pt`)
|
||||||
/// - fill (none, color): Fill color
|
/// - fill (none, color): Fill color
|
||||||
/// - stroke (stroke): Border stroke
|
/// - stroke (stroke): Border stroke
|
||||||
/// - id (str): The block id (for future reference)
|
/// - id (str): The block id (for future reference)
|
||||||
@@ -56,6 +57,7 @@
|
|||||||
name-anchor: "center",
|
name-anchor: "center",
|
||||||
ports: (:),
|
ports: (:),
|
||||||
ports-margins: (:),
|
ports-margins: (:),
|
||||||
|
port-name-padding: 2pt,
|
||||||
fill: none,
|
fill: none,
|
||||||
stroke: black + 1pt,
|
stroke: black + 1pt,
|
||||||
id: "",
|
id: "",
|
||||||
@@ -140,7 +142,8 @@
|
|||||||
tl, tr, br, bl,
|
tl, tr, br, bl,
|
||||||
ports,
|
ports,
|
||||||
ports-margins,
|
ports-margins,
|
||||||
debug: debug.ports
|
debug: debug.ports,
|
||||||
|
name-padding: port-name-padding,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
/// - ports (dictionary): see #doc-ref("element.elmt")
|
/// - ports (dictionary): see #doc-ref("element.elmt")
|
||||||
/// - ports-margins (dictionary): see #doc-ref("element.elmt")
|
/// - ports-margins (dictionary): see #doc-ref("element.elmt")
|
||||||
/// - outside-port-names (bool): If `true` (default), port name labels are drawn outside the group border so they do not overlap child elements. Set to `false` to draw labels inside, matching the block behaviour
|
/// - outside-port-names (bool): If `true` (default), port name labels are drawn outside the group border so they do not overlap child elements. Set to `false` to draw labels inside, matching the block behaviour
|
||||||
|
/// - port-name-padding (number, length): Padding between the port name label and the group border (default `2pt`). Accepts anything CeTZ accepts as `padding` (number or length)
|
||||||
/// - debug (dictionary): see #doc-ref("element.elmt")
|
/// - debug (dictionary): see #doc-ref("element.elmt")
|
||||||
#let group(
|
#let group(
|
||||||
body,
|
body,
|
||||||
@@ -38,6 +39,7 @@
|
|||||||
ports: (:),
|
ports: (:),
|
||||||
ports-margins: (:),
|
ports-margins: (:),
|
||||||
outside-port-names: true,
|
outside-port-names: true,
|
||||||
|
port-name-padding: 2pt,
|
||||||
debug: (
|
debug: (
|
||||||
ports: false
|
ports: false
|
||||||
)
|
)
|
||||||
@@ -95,6 +97,7 @@
|
|||||||
ports-margins,
|
ports-margins,
|
||||||
debug: debug.ports,
|
debug: debug.ports,
|
||||||
outside-name: outside-port-names,
|
outside-name: outside-port-names,
|
||||||
|
name-padding: port-name-padding,
|
||||||
)
|
)
|
||||||
|
|
||||||
if name != none {
|
if name != none {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
next: none,
|
next: none,
|
||||||
debug: false,
|
debug: false,
|
||||||
outside-name: false,
|
outside-name: false,
|
||||||
|
name-padding: 2pt,
|
||||||
) = {
|
) = {
|
||||||
let name = port.at("name", default: "")
|
let name = port.at("name", default: "")
|
||||||
let name-rotate = port.at("vertical", default: false)
|
let name-rotate = port.at("vertical", default: false)
|
||||||
@@ -43,7 +44,7 @@
|
|||||||
draw.content(
|
draw.content(
|
||||||
pos,
|
pos,
|
||||||
anchor: name-anchor,
|
anchor: name-anchor,
|
||||||
padding: 2pt,
|
padding: name-padding,
|
||||||
angle: if name-rotate {90deg} else {0deg},
|
angle: if name-rotate {90deg} else {0deg},
|
||||||
name
|
name
|
||||||
)
|
)
|
||||||
@@ -75,6 +76,7 @@
|
|||||||
ports-margins,
|
ports-margins,
|
||||||
debug: false,
|
debug: false,
|
||||||
outside-name: false,
|
outside-name: false,
|
||||||
|
name-padding: 2pt,
|
||||||
) = {
|
) = {
|
||||||
let sides = (
|
let sides = (
|
||||||
"north": (tl, tr),
|
"north": (tl, tr),
|
||||||
@@ -125,6 +127,7 @@
|
|||||||
next: pos-next,
|
next: pos-next,
|
||||||
debug: debug,
|
debug: debug,
|
||||||
outside-name: outside-name,
|
outside-name: outside-name,
|
||||||
|
name-padding: name-padding,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user