forked from HEL/circuiteria
54 lines
2.0 KiB
Typst
54 lines
2.0 KiB
Typst
// Demonstrates the u-shape wire style.
|
|
// The u-side is auto-detected from the port anchors when both endpoints
|
|
// belong to elements (deduced from the port position vs the element's
|
|
// center anchor). It can also be set explicitly with u-side.
|
|
#import "/src/lib.typ": circuit, element, util, wire
|
|
|
|
#set page(width: auto, height: auto, margin: .5cm)
|
|
|
|
#circuit({
|
|
// ---- east <-> east (auto-detected) ----
|
|
element.block(x: 0, y: 0, w: 1.5, h: 1.5, id: "eA",
|
|
fill: util.colors.orange,
|
|
ports: (east: ((id: "out"),)))
|
|
element.block(x: 0.5, y: -2.5, w: 1.5, h: 1.5, id: "eB",
|
|
fill: util.colors.orange,
|
|
ports: (east: ((id: "out"),)))
|
|
wire.wire("uEE", ("eA-port-out", "eB-port-out"),
|
|
style: "u-shape", u-depth: 0.6,
|
|
name: "E-E")
|
|
|
|
// ---- west <-> west (auto-detected) ----
|
|
element.block(x: 6, y: 0, w: 1.5, h: 1.5, id: "wA",
|
|
fill: util.colors.yellow,
|
|
ports: (west: ((id: "in"),)))
|
|
element.block(x: 6.5, y: -2.5, w: 1.5, h: 1.5, id: "wB",
|
|
fill: util.colors.yellow,
|
|
ports: (west: ((id: "in"),)))
|
|
wire.wire("uWW", ("wA-port-in", "wB-port-in"),
|
|
style: "u-shape", u-depth: 0.6,
|
|
name: "W-W")
|
|
|
|
// ---- north <-> north (auto-detected) ----
|
|
element.block(x: 10, y: -3, w: 1.5, h: 1.5, id: "nA",
|
|
fill: util.colors.green,
|
|
ports: (north: ((id: "out"),)))
|
|
element.block(x: 12.5, y: -2.5, w: 1.5, h: 1.5, id: "nB",
|
|
fill: util.colors.green,
|
|
ports: (north: ((id: "out"),)))
|
|
wire.wire("uNN", ("nA-port-out", "nB-port-out"),
|
|
style: "u-shape", u-depth: 0.6,
|
|
name: "N-N")
|
|
|
|
// ---- south <-> south (explicit u-side override) ----
|
|
element.block(x: 16, y: 0, w: 1.5, h: 1.5, id: "sA",
|
|
fill: util.colors.pink,
|
|
ports: (south: ((id: "out"),)))
|
|
element.block(x: 18.5, y: -0.5, w: 1.5, h: 1.5, id: "sB",
|
|
fill: util.colors.pink,
|
|
ports: (south: ((id: "out"),)))
|
|
wire.wire("uSS", ("sA-port-out", "sB-port-out"),
|
|
style: "u-shape", u-side: "south", u-depth: 0.6,
|
|
name: "S-S")
|
|
})
|