diff --git a/gallery/test.pdf b/gallery/test.pdf index 36b00ee..8539fc3 100644 Binary files a/gallery/test.pdf and b/gallery/test.pdf differ diff --git a/gallery/test.typ b/gallery/test.typ index d3fb70a..d1475e4 100644 --- a/gallery/test.typ +++ b/gallery/test.typ @@ -105,7 +105,7 @@ ) ) wire.stub("RegFile-port-CLK", "north", name: "CLK") - wire.stub("RegFile-port-WE3", "north", name: "Regwrite", vertical: true) + wire.stub("RegFile-port-WE3", "north", name: "Regwrite", name-offset: 0.6) wire.stub("RegFile-port-A2", "west") wire.stub("RegFile-port-RD2", "east") diff --git a/gallery/test2.pdf b/gallery/test2.pdf index 53639b8..8eafa77 100644 Binary files a/gallery/test2.pdf and b/gallery/test2.pdf differ diff --git a/gallery/test2.typ b/gallery/test2.typ index a8f3736..7e62cc4 100644 --- a/gallery/test2.typ +++ b/gallery/test2.typ @@ -110,7 +110,7 @@ ) ) wire.stub("RegFile-port-CLK", "north", name: "CLK") - wire.stub("RegFile-port-WE3", "north", name: "Regwrite", vertical: true) + wire.stub("RegFile-port-WE3", "north", name: "Regwrite", name-offset: 0.6) wire.stub("RegFile-port-A2", "west") wire.stub("RegFile-port-RD2", "east") diff --git a/manual.pdf b/manual.pdf index 14a0033..2c0c728 100644 Binary files a/manual.pdf and b/manual.pdf differ diff --git a/src/wire.typ b/src/wire.typ index 4b12679..027013a 100644 --- a/src/wire.typ +++ b/src/wire.typ @@ -224,16 +224,25 @@ /// - name (none, str): Optional name displayed at the end of the stub /// - vertical (bool): Whether the name should be displayed vertically /// - length (number): The length of the stub -#let stub(port-id, side, name: none, vertical: false, length: 1em) = { - let offset = ( +/// - name-offset (number): The name offset, perpendicular to the stub +#let stub(port-id, side, name: none, vertical: false, length: 1em, name-offset: 0) = { + let end-offset = ( north: (0, length), east: (length, 0), south: (0, -length), west: (-length, 0) ).at(side) + + let name-offset = ( + north: (name-offset, length), + east: (length, name-offset), + south: (name-offset, -length), + west: (-length, name-offset) + ).at(side) + draw.line( port-id, - (rel: offset, to: port-id) + (rel: end-offset, to: port-id) ) if name != none { let text-anchor = if vertical { @@ -248,7 +257,7 @@ anchor: text-anchor, padding: 0.2em, angle: if vertical {90deg} else {0deg}, - (rel: offset, to: port-id), + (rel: name-offset, to: port-id), name ) }