Skip to content
This repository was archived by the owner on Apr 7, 2026. It is now read-only.

Commit 66347b9

Browse files
authored
Merge branch 'main' into feat/circle-inverter-style
2 parents 206f814 + bdb1574 commit 66347b9

8 files changed

Lines changed: 47 additions & 7 deletions

File tree

docs/main.typ

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,12 +915,13 @@ The `diode` symbol accepts only one parameter, called `type`, and its appearance
915915
#zap.circuit({
916916
import zap: *
917917
918-
wire((0, 0), (8, 0))
918+
wire((0, 0), (10, 0))
919919
vcc("s1", (0, 0))
920920
vee("s2", (2, 0))
921921
earth("s3", (4, 0))
922922
frame("s4", (6, 0))
923923
ground("s5", (8, 0))
924+
rground("s6", (10, 0))
924925
})
925926
```,
926927
)

src/components/stub.typ

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
wire((0, 0), (rel: diff))
3737
}
3838

39-
4039
// Component call
4140
component("stub", "l", node, draw: draw, ..args)
4241
}

src/components/supply.typ

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,16 @@
99
// Drawing function
1010
let draw(ctx, position, style) = {
1111
wire((0, 0), (0, -style.distance))
12-
polygon((0, -style.distance), 3, anchor: "north", radius: style.radius, angle: -90deg, name: "polygon", stroke: style.stroke, fill: style.fill)
12+
polygon(
13+
(0, -style.distance),
14+
3,
15+
anchor: "north",
16+
radius: style.radius,
17+
angle: -90deg,
18+
name: "polygon",
19+
stroke: style.stroke,
20+
fill: style.fill,
21+
)
1322

1423
let (width, height) = cetz.util.measure(ctx, "polygon")
1524
interface((-width / 2, -height / 2), (width / 2, height / 2))
@@ -31,7 +40,9 @@
3140
set-style(stroke: style.stroke)
3241
line((-style.width / 2, -style.distance), (style.width / 2, -style.distance))
3342
for i in (0, 1, 2) {
34-
line((-style.width / 2 + (1 - i) * .01 + i * delta, -style.distance), (rel: (angle: -style.angle - 90deg, radius: style.depth)))
43+
line((-style.width / 2 + (1 - i) * .01 + i * delta, -style.distance), (
44+
rel: (angle: -style.angle - 90deg, radius: style.depth),
45+
))
3546
}
3647

3748
interface((-style.width / 2, style.distance), (style.width / 2, -style.distance))
@@ -49,7 +60,11 @@
4960
let draw(ctx, position, style) = {
5061
wire((0, 0), (0, -style.distance))
5162
for i in (0, 1, 2) {
52-
line((-style.width / 2 + i * style.delta, -style.distance - i * style.spacing), (style.width / 2 - i * style.delta, -style.distance - i * style.spacing), ..style)
63+
line(
64+
(-style.width / 2 + i * style.delta, -style.distance - i * style.spacing),
65+
(style.width / 2 - i * style.delta, -style.distance - i * style.spacing),
66+
..style,
67+
)
5368
}
5469

5570
interface((-style.width / 2, -style.distance - style.spacing * 2), (style.width / 2, -style.distance))
@@ -86,5 +101,21 @@
86101
)
87102
}
88103

104+
#let rground(name, node, ..params) = {
105+
assert(params.pos().len() == 0, message: "earth supports only one node")
106+
107+
// Drawing function
108+
let draw(ctx, position, style) = {
109+
wire((0, 0), (0, -style.distance))
110+
line((-style.width / 2, -style.distance), (style.width / 2, -style.distance))
111+
112+
interface((-style.width / 2, style.distance), (style.width / 2, -style.distance))
113+
anchor("default", (0, 0))
114+
}
115+
116+
// Component call
117+
component("rground", name, node, draw: draw, ..params)
118+
}
119+
89120
#let vcc(name, node, ..params) = vsupply("vcc", name, node, ..params)
90121
#let vee(name, node, ..params) = vsupply("vee", name, node, ..params, invert: true)

src/lib.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#import "components/diode.typ": diode, led, photodiode, schottky, tunnel, zener
2626
#import "components/switch.typ": switch
2727
#import "components/fuse.typ": afuse, fuse
28-
#import "components/supply.typ": earth, frame, ground, vcc, vee
28+
#import "components/supply.typ": earth, frame, ground, rground, vcc, vee
2929
#import "components/inductor.typ": inductor
3030
#import "components/logic.typ": land, lnand, lnor, lnot, lor, lxnor, lxor
3131
#import "components/resistor.typ": heater, potentiometer, resistor, rheostat

src/styles.typ

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@
223223
radius: 0.22,
224224
distance: 0.28,
225225
),
226+
rground: (
227+
variant: auto,
228+
scale: auto,
229+
stroke: auto,
230+
width: .53,
231+
distance: .28,
232+
),
226233
frame: (
227234
variant: auto,
228235
scale: auto,

tests/supplies/ref/1.png

4.93 KB
Loading

tests/supplies/ref/3.png

4.96 KB
Loading

tests/supplies/test.typ

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
ground("gnd", (2, 0))
1010
frame("fr", (3, 0))
1111
earth("ea", (4, 0))
12+
rground("rg", (5, 0))
1213
})
1314

1415
// Test label position
@@ -26,7 +27,8 @@
2627
ground("gnd", (2, 0))
2728
frame("fr", (3, 0))
2829
earth("ea", (4, 0))
29-
wire("vcc", "vee", "gnd", "fr", "ea")
30+
rground("rg", (5, 0))
31+
wire("vcc", "vee", "gnd", "fr", "ea", "rg")
3032
})
3133

3234
// Test styling

0 commit comments

Comments
 (0)