diff --git a/circuitypst.typ b/circuitypst.typ index 80c175d..38de2e6 100644 --- a/circuitypst.typ +++ b/circuitypst.typ @@ -1,9 +1,8 @@ #import "components.typ" #import "utils.typ" -#import "../typst-canvas/draw.typ": * -#import "../typst-canvas/coordinate.typ" -#import "../typst-canvas/vector.typ" +#import "@preview/cetz:0.0.1" +#import cetz.draw: fill, stroke, group, anchor, rotate, set-origin, line, content, move-to #let canvas-fill = fill #let canvas-stroke = stroke @@ -17,7 +16,7 @@ #let node(component, position, label: none, name: none, anchor: none, fill: auto, stroke: auto, ..options) = { assert(component in components.node, message: "Component '" + component + "' is unknown") group(name: name, anchor: anchor, { - import "../typst-canvas/draw.typ": anchor + import cetz.draw: anchor if fill != auto { canvas-fill(fill) diff --git a/components.typ b/components.typ index 9f85ed8..dfeb464 100644 --- a/components.typ +++ b/components.typ @@ -1,4 +1,6 @@ -#import "../typst-canvas/draw.typ": * +#import "@preview/cetz:0.0.1" + +#import cetz.draw: line, circle, fill, rect #import "parts.typ" #import "utils.typ": anchors diff --git a/examples/current-shunt.pdf b/examples/current-shunt.pdf index 6476958..1aca3d4 100644 Binary files a/examples/current-shunt.pdf and b/examples/current-shunt.pdf differ diff --git a/examples/current-shunt.typ b/examples/current-shunt.typ index 83bd18c..516f04b 100644 --- a/examples/current-shunt.typ +++ b/examples/current-shunt.typ @@ -1,11 +1,11 @@ -#import "../../typst-canvas/canvas.typ": canvas +#import "@preview/cetz:0.0.1" #lorem(30) #figure( - canvas(length: 1cm, debug: false, { - import "../../typst-canvas/draw.typ": * - import "../circuitypst.typ": node, to + cetz.canvas(length: 1cm, debug: false, { + import cetz.draw: line + import "@local/circuitypst:0.0.1": node, to to("isourceAM", (0,0), (0,3), label: $I_0$, v: h(0.5em) + $V_0$) to("short", (), (2,3), i: $I_0$,) diff --git a/examples/exclusive-or.pdf b/examples/exclusive-or.pdf index 8b2bf80..e8ab54d 100644 Binary files a/examples/exclusive-or.pdf and b/examples/exclusive-or.pdf differ diff --git a/examples/exclusive-or.typ b/examples/exclusive-or.typ index b8064c9..51b5dc8 100644 --- a/examples/exclusive-or.typ +++ b/examples/exclusive-or.typ @@ -1,11 +1,11 @@ -#import "../../typst-canvas/canvas.typ": canvas +#import "@preview/cetz:0.0.1" #lorem(30) #figure( - canvas({ - import "../../typst-canvas/draw.typ": * - import "../circuitypst.typ": node + cetz.canvas({ + import cetz.draw: line, content + import "@local/circuitypst:0.0.1": node node("nand gate", (0,1), name: "g1") content("g1.out", [#h(0.5em) Q], anchor: "left") diff --git a/examples/half-adder.pdf b/examples/half-adder.pdf index ffa1c3d..88ad580 100644 Binary files a/examples/half-adder.pdf and b/examples/half-adder.pdf differ diff --git a/examples/half-adder.typ b/examples/half-adder.typ index 81c2ebb..29d45e0 100644 --- a/examples/half-adder.typ +++ b/examples/half-adder.typ @@ -1,11 +1,11 @@ -#import "../../typst-canvas/canvas.typ": canvas +#import "@preview/cetz:0.0.1" #lorem(30) #figure( - canvas(length: 1cm, debug: false, { - import "../../typst-canvas/draw.typ": * - import "../circuitypst.typ": node + cetz.canvas(length: 1cm, debug: false, { + import cetz.draw: line, content + import "@local/circuitypst:0.0.1": node node("and gate", (0,0), name: "g1") content("g1.out", h(0.5em)+[Carry], anchor: "left") diff --git a/parts.typ b/parts.typ index 0639e55..1949ede 100644 --- a/parts.typ +++ b/parts.typ @@ -1,8 +1,10 @@ -#import "../typst-canvas/draw.typ": * +#import "@preview/cetz:0.0.1" +#import cetz.draw: merge-path, arc, line, circle + #import "utils.typ": anchors #let and-gate-body = { merge-path(close: true, { - arc((0,0), -90deg, 90deg, radius: 0.5, name: "curve", anchor: "origin") + arc((0,0), start: -90deg, stop: 90deg, radius: 0.5, name: "curve", anchor: "origin") line( (0, 0.5), (-0.5, 0.5), @@ -27,10 +29,10 @@ #let or-gate-body = { merge-path(close: true, { - arc((0.5, 0), -90deg, -30deg, anchor: "end", name: "bcurve") - arc((0.5,0), 30deg, 90deg, anchor: "start", name: "tcurve") + arc((0.5, 0), start: -90deg, stop: -30deg, anchor: "end", name: "bcurve") + arc((0.5,0), start: 30deg, stop: 90deg, anchor: "start", name: "tcurve") line("tcurve.end", (-0.5, 0.5)) - arc((), -30deg, 30deg, anchor: "end") + arc((), start: 30deg, stop: -30deg, anchor: "start") }) // x coordinate of where the input legs touch the body of the gate @@ -62,7 +64,7 @@ } #let xor-bar = { - arc((-0.6, -0.5), -30deg, 30deg) + arc((-0.6, -0.5), start: -30deg, stop: 30deg) anchors(( "ibin 1": "bin 1", "ibin 2": "bin 2", @@ -75,4 +77,4 @@ #let logic-gate-legs = for a in ("in 1", "in 2", "out") { line("b" + a, a) -} \ No newline at end of file +} diff --git a/typst.toml b/typst.toml new file mode 100644 index 0000000..5dabf17 --- /dev/null +++ b/typst.toml @@ -0,0 +1,4 @@ +[package] +name = "circuitypst" +version = "0.0.1" +entrypoint = "circuitypst.typ" diff --git a/utils.typ b/utils.typ index 6d327c3..9904738 100644 --- a/utils.typ +++ b/utils.typ @@ -1,5 +1,6 @@ -#import "../typst-canvas/vector.typ" -#import "../typst-canvas/draw.typ": anchor +#import "@preview/cetz:0.0.1" +#import cetz.draw: anchor, vector + #let vector-dist(v1, v2) = { return calc.abs( @@ -56,4 +57,4 @@ for (k, v) in anchors { anchor(k, v) } -} \ No newline at end of file +}