-
Notifications
You must be signed in to change notification settings - Fork 12
/
parts.typ
78 lines (73 loc) · 1.85 KB
/
parts.typ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#import "../typst-canvas/draw.typ": *
#import "utils.typ": anchors
#let and-gate-body = {
merge-path(close: true, {
arc((0,0), -90deg, 90deg, radius: 0.5, name: "curve", anchor: "origin")
line(
(0, 0.5),
(-0.5, 0.5),
(-0.5, -0.5)
)
})
anchors((
"bin 1": (-0.5, 0.25),
"in 1": (rel: (-0.5, 0)),
"bin 2": (-0.5, -0.25),
"in 2": (rel: (-0.5, 0)),
"bout": (0.5, 0),
"out": (rel: (0.5, 0)),
"north": (0, 0.5),
"south": (rel: (0, -1)),
"east": "out",
"west": ("in 1", "|-", "center"),
"left": ("bin 1", "|-", "center"),
"right": "bout"
))
}
#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")
line("tcurve.end", (-0.5, 0.5))
arc((), -30deg, 30deg, anchor: "end")
})
// x coordinate of where the input legs touch the body of the gate
let x = calc.cos(calc.asin(0.25)) - calc.cos(calc.asin(0.5)) - 0.5
anchors((
"bin 1": (x, 0.25),
"in 1": (-1, 0.25),
"bin 2": (x, -0.25),
"in 2": (-1, -0.25),
"bout": (0.5, 0),
"out": (rel: (0.5, 0)),
"north": (0, 0.5),
"south": (rel: (0, -1)),
"east": "out",
"west": ("in 1", "|-", "center"),
"left": ("bin 1", "|-", "center"),
"right": "bout"
))
}
#let not-circle = {
circle((rel: (0.1, 0), to: "bout"), radius: 0.1)
anchors((
"N-not": (),
"body right": "bout",
"bout": (rel: (0.2, 0)),
"right": "bout"
))
}
#let xor-bar = {
arc((-0.6, -0.5), -30deg, 30deg)
anchors((
"ibin 1": "bin 1",
"ibin 2": "bin 2",
"bin 1": (rel: (-0.1, 0), to: "bin 1"),
"bin 2": (rel: (-0.1, 0), to: "bin 2"),
"body left": "left",
"left": (rel: (-0.1, 0), to: "left")
))
}
#let logic-gate-legs = for a in ("in 1", "in 2", "out") {
line("b" + a, a)
}