@tscircuit/schematic-viewer 1.4.3 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/bun-pver-release.yml +24 -0
- package/.github/workflows/{npm-typecheck.yml → bun-typecheck.yml} +6 -6
- package/LICENSE +21 -0
- package/README.md +16 -26
- package/biome.json +8 -1
- package/bun.lockb +0 -0
- package/cosmos.config.json +3 -0
- package/cosmos.decorator.tsx +3 -0
- package/examples/resistor-and-capacitor.fixture.tsx +14 -0
- package/index.html +12 -0
- package/lib/components/SchematicViewer.tsx +79 -0
- package/lib/dev/render-to-circuit-json.ts +7 -0
- package/lib/index.ts +1 -0
- package/package.json +27 -74
- package/src/main.tsx +20 -0
- package/test.ts +0 -0
- package/tsconfig.json +28 -25
- package/vite.config.js +12 -4
- package/.codesandbox/tasks.json +0 -36
- package/.github/workflows/chromatic.yml +0 -30
- package/.github/workflows/npm-build.yml +0 -26
- package/.github/workflows/release.yml +0 -29
- package/.prettierrc +0 -1
- package/.storybook/main.ts +0 -12
- package/.storybook/preview.ts +0 -17
- package/ava.config.js +0 -7
- package/dist/index.css +0 -7
- package/dist/index.css.map +0 -1
- package/dist/index.d.ts +0 -15
- package/dist/index.js +0 -2502
- package/dist/index.js.map +0 -1
- package/next-env.d.ts +0 -5
- package/parsel.d.ts +0 -81
- package/release.config.js +0 -15
- package/renovate.json +0 -17
- package/src/Schematic.tsx +0 -250
- package/src/index.ts +0 -1
- package/src/lib/hooks/index.ts +0 -1
- package/src/lib/hooks/use-maybe-promise.ts +0 -14
- package/src/lib/render-context/index.ts +0 -28
- package/src/lib/types/core.ts +0 -181
- package/src/lib/types/index.ts +0 -4
- package/src/lib/types/route-solver.ts +0 -10
- package/src/lib/types/source-component.ts +0 -73
- package/src/lib/types/util.ts +0 -52
- package/src/lib/utils/collect-element-refs.ts +0 -45
- package/src/lib/utils/colors.ts +0 -235
- package/src/lib/utils/direction-to-vec.ts +0 -50
- package/src/lib/utils/get-rotation-from-anchor-side.ts +0 -11
- package/src/lib/utils/get-svg-path-bounds.ts +0 -22
- package/src/lib/utils/get-vec-from-anchor-side.ts +0 -11
- package/src/lib/utils/point-math.ts +0 -26
- package/src/pages/_app.tsx +0 -23
- package/src/pages/index.tsx +0 -10
- package/src/pages/led-circuit-react.tsx +0 -54
- package/src/pages/style.css +0 -5
- package/src/schematic-components/ContextProviders.tsx +0 -15
- package/src/schematic-components/DebugPoint.tsx +0 -25
- package/src/schematic-components/RenderError.tsx +0 -23
- package/src/schematic-components/SVGPathComponent.tsx +0 -183
- package/src/schematic-components/SVGPathComponent2.tsx +0 -76
- package/src/schematic-components/SchematicChip.tsx +0 -202
- package/src/schematic-components/SchematicComponent.tsx +0 -51
- package/src/schematic-components/SchematicComponentFromSymbol.tsx +0 -46
- package/src/schematic-components/SchematicElement.tsx +0 -43
- package/src/schematic-components/SchematicGroup.tsx +0 -3
- package/src/schematic-components/SchematicNetLabel.tsx +0 -63
- package/src/schematic-components/SchematicText.tsx +0 -44
- package/src/schematic-components/SchematicTrace.tsx +0 -51
- package/src/schematic-components/TableViewer.tsx +0 -13
- package/src/schematic-components/index.tsx +0 -9
- package/src/stories/basics/schematic-net-label.stories.tsx +0 -138
- package/src/stories/basics/schematic-net-labels-2.stories.tsx +0 -35
- package/src/stories/bug-connections.stories.tsx +0 -31
- package/src/stories/bug-high-port-numbers.stories.tsx +0 -130
- package/src/stories/bug-one-sided.stories.tsx +0 -34
- package/src/stories/bug-pin-spacing.stories.tsx +0 -52
- package/src/stories/bugs/bug1-y-flip.stories.tsx +0 -20
- package/src/stories/bugs/bug2-component-bounds.stories.tsx +0 -62
- package/src/stories/bugs/bug3-scaling-trace.stories.tsx +0 -24
- package/src/stories/bugs/bug4-schematic-line.stories.tsx +0 -17
- package/src/stories/bugs/bug5-diode.stories.tsx +0 -16
- package/src/stories/bugs/bug6-trace-scaling.stories.tsx +0 -18
- package/src/stories/bugs/bug7-multiple-schematic-panning.stories.tsx +0 -23
- package/src/stories/bugs/bug8-autolayout.stories.tsx +0 -43
- package/src/stories/circuit-components/diode.stories.tsx +0 -16
- package/src/stories/circuit-components/netalias.stories.tsx +0 -14
- package/src/stories/circuit-components/resistor.stories.tsx +0 -16
- package/src/stories/component-drawing-example.stories.tsx +0 -17
- package/src/stories/led-circuit-react.stories.tsx +0 -48
- package/src/stories/net-alias.stories.tsx +0 -92
- package/src/stories/off-center-render.stories.tsx +0 -29
- package/src/stories/rotated-resistor.stories.tsx +0 -23
- package/src/stories/schematic-path.stories.tsx +0 -40
- package/src/stories/three-sided-bug.stories.tsx +0 -30
- package/tsconfig.tsbuildinfo +0 -1
- package/tsup.config.ts +0 -8
- package/vercel.json +0 -3
package/src/lib/utils/colors.ts
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
// Kicad-2020 color scheme
|
|
2
|
-
export const colorMap = {
|
|
3
|
-
"3d_viewer": {
|
|
4
|
-
background_bottom: "rgb(102, 102, 128)",
|
|
5
|
-
background_top: "rgb(204, 204, 230)",
|
|
6
|
-
board: "rgb(51, 43, 23)",
|
|
7
|
-
copper: "rgb(179, 156, 0)",
|
|
8
|
-
silkscreen_bottom: "rgb(230, 230, 230)",
|
|
9
|
-
silkscreen_top: "rgb(230, 230, 230)",
|
|
10
|
-
soldermask: "rgb(20, 51, 36)",
|
|
11
|
-
solderpaste: "rgb(128, 128, 128)",
|
|
12
|
-
},
|
|
13
|
-
board: {
|
|
14
|
-
anchor: "rgb(255, 38, 226)",
|
|
15
|
-
aux_items: "rgb(255, 255, 255)",
|
|
16
|
-
b_adhes: "rgb(0, 0, 132)",
|
|
17
|
-
b_crtyd: "rgb(255, 38, 226)",
|
|
18
|
-
b_fab: "rgb(88, 93, 132)",
|
|
19
|
-
b_mask: "rgba(2, 255, 238, 0.400)",
|
|
20
|
-
b_paste: "rgb(0, 194, 194)",
|
|
21
|
-
b_silks: "rgb(232, 178, 167)",
|
|
22
|
-
background: "rgb(0, 16, 35)",
|
|
23
|
-
cmts_user: "rgb(89, 148, 220)",
|
|
24
|
-
copper: {
|
|
25
|
-
b: "rgb(77, 127, 196)",
|
|
26
|
-
f: "rgb(200, 52, 52)",
|
|
27
|
-
in1: "rgb(127, 200, 127)",
|
|
28
|
-
in10: "rgb(237, 124, 51)",
|
|
29
|
-
in11: "rgb(91, 195, 235)",
|
|
30
|
-
in12: "rgb(247, 111, 142)",
|
|
31
|
-
in13: "rgb(167, 165, 198)",
|
|
32
|
-
in14: "rgb(40, 204, 217)",
|
|
33
|
-
in15: "rgb(232, 178, 167)",
|
|
34
|
-
in16: "rgb(242, 237, 161)",
|
|
35
|
-
in17: "rgb(237, 124, 51)",
|
|
36
|
-
in18: "rgb(91, 195, 235)",
|
|
37
|
-
in19: "rgb(247, 111, 142)",
|
|
38
|
-
in2: "rgb(206, 125, 44)",
|
|
39
|
-
in20: "rgb(167, 165, 198)",
|
|
40
|
-
in21: "rgb(40, 204, 217)",
|
|
41
|
-
in22: "rgb(232, 178, 167)",
|
|
42
|
-
in23: "rgb(242, 237, 161)",
|
|
43
|
-
in24: "rgb(237, 124, 51)",
|
|
44
|
-
in25: "rgb(91, 195, 235)",
|
|
45
|
-
in26: "rgb(247, 111, 142)",
|
|
46
|
-
in27: "rgb(167, 165, 198)",
|
|
47
|
-
in28: "rgb(40, 204, 217)",
|
|
48
|
-
in29: "rgb(232, 178, 167)",
|
|
49
|
-
in3: "rgb(79, 203, 203)",
|
|
50
|
-
in30: "rgb(242, 237, 161)",
|
|
51
|
-
in4: "rgb(219, 98, 139)",
|
|
52
|
-
in5: "rgb(167, 165, 198)",
|
|
53
|
-
in6: "rgb(40, 204, 217)",
|
|
54
|
-
in7: "rgb(232, 178, 167)",
|
|
55
|
-
in8: "rgb(242, 237, 161)",
|
|
56
|
-
in9: "rgb(141, 203, 129)",
|
|
57
|
-
},
|
|
58
|
-
cursor: "rgb(255, 255, 255)",
|
|
59
|
-
drc: "rgb(194, 194, 194)",
|
|
60
|
-
drc_error: "rgba(215, 91, 107, 0.800)",
|
|
61
|
-
drc_exclusion: "rgb(255, 255, 255)",
|
|
62
|
-
drc_warning: "rgba(255, 208, 66, 0.902)",
|
|
63
|
-
dwgs_user: "rgb(194, 194, 194)",
|
|
64
|
-
eco1_user: "rgb(180, 219, 210)",
|
|
65
|
-
eco2_user: "rgb(216, 200, 82)",
|
|
66
|
-
edge_cuts: "rgb(208, 210, 205)",
|
|
67
|
-
f_adhes: "rgb(132, 0, 132)",
|
|
68
|
-
f_crtyd: "rgb(255, 0, 245)",
|
|
69
|
-
f_fab: "rgb(175, 175, 175)",
|
|
70
|
-
f_mask: "rgba(216, 100, 255, 0.400)",
|
|
71
|
-
f_paste: "rgba(180, 160, 154, 0.902)",
|
|
72
|
-
f_silks: "rgb(242, 237, 161)",
|
|
73
|
-
footprint_text_back: "rgb(0, 0, 132)",
|
|
74
|
-
footprint_text_front: "rgb(194, 194, 194)",
|
|
75
|
-
footprint_text_invisible: "rgb(132, 132, 132)",
|
|
76
|
-
grid: "rgb(132, 132, 132)",
|
|
77
|
-
grid_axes: "rgb(194, 194, 194)",
|
|
78
|
-
margin: "rgb(255, 38, 226)",
|
|
79
|
-
microvia: "rgb(0, 132, 132)",
|
|
80
|
-
no_connect: "rgb(0, 0, 132)",
|
|
81
|
-
pad_back: "rgb(77, 127, 196)",
|
|
82
|
-
pad_front: "rgb(200, 52, 52)",
|
|
83
|
-
pad_plated_hole: "rgb(194, 194, 0)",
|
|
84
|
-
pad_through_hole: "rgb(227, 183, 46)",
|
|
85
|
-
plated_hole: "rgb(26, 196, 210)",
|
|
86
|
-
ratsnest: "rgba(245, 255, 213, 0.702)",
|
|
87
|
-
select_overlay: "rgb(4, 255, 67)",
|
|
88
|
-
through_via: "rgb(236, 236, 236)",
|
|
89
|
-
user_1: "rgb(194, 194, 194)",
|
|
90
|
-
user_2: "rgb(89, 148, 220)",
|
|
91
|
-
user_3: "rgb(180, 219, 210)",
|
|
92
|
-
user_4: "rgb(216, 200, 82)",
|
|
93
|
-
user_5: "rgb(194, 194, 194)",
|
|
94
|
-
user_6: "rgb(89, 148, 220)",
|
|
95
|
-
user_7: "rgb(180, 219, 210)",
|
|
96
|
-
user_8: "rgb(216, 200, 82)",
|
|
97
|
-
user_9: "rgb(232, 178, 167)",
|
|
98
|
-
via_blind_buried: "rgb(187, 151, 38)",
|
|
99
|
-
via_hole: "rgb(227, 183, 46)",
|
|
100
|
-
via_micro: "rgb(0, 132, 132)",
|
|
101
|
-
via_through: "rgb(236, 236, 236)",
|
|
102
|
-
worksheet: "rgb(200, 114, 171)",
|
|
103
|
-
},
|
|
104
|
-
gerbview: {
|
|
105
|
-
axes: "rgb(0, 0, 132)",
|
|
106
|
-
background: "rgb(0, 0, 0)",
|
|
107
|
-
dcodes: "rgb(255, 255, 255)",
|
|
108
|
-
grid: "rgb(132, 132, 132)",
|
|
109
|
-
layers: [
|
|
110
|
-
"rgb(132, 0, 0)",
|
|
111
|
-
"rgb(194, 194, 0)",
|
|
112
|
-
"rgb(194, 0, 194)",
|
|
113
|
-
"rgb(194, 0, 0)",
|
|
114
|
-
"rgb(0, 132, 132)",
|
|
115
|
-
"rgb(0, 132, 0)",
|
|
116
|
-
"rgb(0, 0, 132)",
|
|
117
|
-
"rgb(132, 132, 132)",
|
|
118
|
-
"rgb(132, 0, 132)",
|
|
119
|
-
"rgb(194, 194, 194)",
|
|
120
|
-
"rgb(132, 0, 132)",
|
|
121
|
-
"rgb(132, 0, 0)",
|
|
122
|
-
"rgb(132, 132, 0)",
|
|
123
|
-
"rgb(194, 194, 194)",
|
|
124
|
-
"rgb(0, 0, 132)",
|
|
125
|
-
"rgb(0, 132, 0)",
|
|
126
|
-
"rgb(132, 0, 0)",
|
|
127
|
-
"rgb(194, 194, 0)",
|
|
128
|
-
"rgb(194, 0, 194)",
|
|
129
|
-
"rgb(194, 0, 0)",
|
|
130
|
-
"rgb(0, 132, 132)",
|
|
131
|
-
"rgb(0, 132, 0)",
|
|
132
|
-
"rgb(0, 0, 132)",
|
|
133
|
-
"rgb(132, 132, 132)",
|
|
134
|
-
"rgb(132, 0, 132)",
|
|
135
|
-
"rgb(194, 194, 194)",
|
|
136
|
-
"rgb(132, 0, 132)",
|
|
137
|
-
"rgb(132, 0, 0)",
|
|
138
|
-
"rgb(132, 132, 0)",
|
|
139
|
-
"rgb(194, 194, 194)",
|
|
140
|
-
"rgb(0, 0, 132)",
|
|
141
|
-
"rgb(0, 132, 0)",
|
|
142
|
-
"rgb(132, 0, 0)",
|
|
143
|
-
"rgb(194, 194, 0)",
|
|
144
|
-
"rgb(194, 0, 194)",
|
|
145
|
-
"rgb(194, 0, 0)",
|
|
146
|
-
"rgb(0, 132, 132)",
|
|
147
|
-
"rgb(0, 132, 0)",
|
|
148
|
-
"rgb(0, 0, 132)",
|
|
149
|
-
"rgb(132, 132, 132)",
|
|
150
|
-
"rgb(132, 0, 132)",
|
|
151
|
-
"rgb(194, 194, 194)",
|
|
152
|
-
"rgb(132, 0, 132)",
|
|
153
|
-
"rgb(132, 0, 0)",
|
|
154
|
-
"rgb(132, 132, 0)",
|
|
155
|
-
"rgb(194, 194, 194)",
|
|
156
|
-
"rgb(0, 0, 132)",
|
|
157
|
-
"rgb(0, 132, 0)",
|
|
158
|
-
"rgb(132, 0, 0)",
|
|
159
|
-
"rgb(194, 194, 0)",
|
|
160
|
-
"rgb(194, 0, 194)",
|
|
161
|
-
"rgb(194, 0, 0)",
|
|
162
|
-
"rgb(0, 132, 132)",
|
|
163
|
-
"rgb(0, 132, 0)",
|
|
164
|
-
"rgb(0, 0, 132)",
|
|
165
|
-
"rgb(132, 132, 132)",
|
|
166
|
-
"rgb(132, 0, 132)",
|
|
167
|
-
"rgb(194, 194, 194)",
|
|
168
|
-
"rgb(132, 0, 132)",
|
|
169
|
-
"rgb(132, 0, 0)",
|
|
170
|
-
],
|
|
171
|
-
negative_objects: "rgb(132, 132, 132)",
|
|
172
|
-
worksheet: "rgb(0, 0, 132)",
|
|
173
|
-
},
|
|
174
|
-
meta: {
|
|
175
|
-
filename: "kicad_2020",
|
|
176
|
-
name: "KiCad 2020",
|
|
177
|
-
version: 2,
|
|
178
|
-
},
|
|
179
|
-
palette: [
|
|
180
|
-
"rgb(132, 0, 0)",
|
|
181
|
-
"rgb(194, 194, 0)",
|
|
182
|
-
"rgb(194, 0, 194)",
|
|
183
|
-
"rgb(194, 0, 0)",
|
|
184
|
-
"rgb(0, 132, 132)",
|
|
185
|
-
"rgb(0, 132, 0)",
|
|
186
|
-
"rgb(0, 0, 132)",
|
|
187
|
-
"rgb(132, 132, 132)",
|
|
188
|
-
"rgb(132, 0, 132)",
|
|
189
|
-
"rgb(194, 194, 194)",
|
|
190
|
-
"rgb(132, 0, 132)",
|
|
191
|
-
"rgb(132, 0, 0)",
|
|
192
|
-
"rgb(132, 132, 0)",
|
|
193
|
-
"rgb(194, 194, 194)",
|
|
194
|
-
"rgb(0, 0, 132)",
|
|
195
|
-
"rgb(0, 132, 0)",
|
|
196
|
-
],
|
|
197
|
-
schematic: {
|
|
198
|
-
aux_items: "rgb(46, 46, 46)",
|
|
199
|
-
background: "rgb(245, 241, 237)",
|
|
200
|
-
brightened: "rgb(255, 0, 255)",
|
|
201
|
-
bus: "rgb(0, 0, 132)",
|
|
202
|
-
bus_junction: "rgb(0, 0, 132)",
|
|
203
|
-
component_body: "rgb(255, 255, 194)",
|
|
204
|
-
component_outline: "rgb(132, 0, 0)",
|
|
205
|
-
cursor: "rgb(15, 15, 15)",
|
|
206
|
-
erc_error: "rgba(230, 9, 13, 0.800)",
|
|
207
|
-
erc_warning: "rgba(209, 146, 0, 0.800)",
|
|
208
|
-
fields: "rgb(132, 0, 132)",
|
|
209
|
-
grid: "rgb(181, 181, 181)",
|
|
210
|
-
grid_axes: "rgb(0, 0, 132)",
|
|
211
|
-
hidden: "rgb(194, 194, 194)",
|
|
212
|
-
junction: "rgb(0, 150, 0)",
|
|
213
|
-
label_global: "rgb(132, 0, 0)",
|
|
214
|
-
label_hier: "rgb(114, 86, 0)",
|
|
215
|
-
label_local: "rgb(15, 15, 15)",
|
|
216
|
-
net_name: "rgb(132, 132, 132)",
|
|
217
|
-
no_connect: "rgb(0, 0, 132)",
|
|
218
|
-
note: "rgb(0, 0, 194)",
|
|
219
|
-
override_item_colors: false,
|
|
220
|
-
pin: "rgb(132, 0, 0)",
|
|
221
|
-
pin_name: "rgb(0, 100, 100)",
|
|
222
|
-
pin_number: "rgb(169, 0, 0)",
|
|
223
|
-
reference: "rgb(0, 100, 100)",
|
|
224
|
-
shadow: "rgba(102, 179, 255, 0.800)",
|
|
225
|
-
sheet: "rgb(132, 0, 0)",
|
|
226
|
-
sheet_background: "rgba(253, 255, 231, 0.000)",
|
|
227
|
-
sheet_fields: "rgb(132, 0, 132)",
|
|
228
|
-
sheet_filename: "rgb(114, 86, 0)",
|
|
229
|
-
sheet_label: "rgb(0, 100, 100)",
|
|
230
|
-
sheet_name: "rgb(0, 100, 100)",
|
|
231
|
-
value: "rgb(0, 100, 100)",
|
|
232
|
-
wire: "rgb(0, 150, 0)",
|
|
233
|
-
worksheet: "rgb(132, 0, 0)",
|
|
234
|
-
},
|
|
235
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export const directionToVec = (direction: "up" | "down" | "left" | "right") => {
|
|
2
|
-
if (direction === "up") return { x: 0, y: 1 }
|
|
3
|
-
else if (direction === "down") return { x: 0, y: -1 }
|
|
4
|
-
else if (direction === "left") return { x: -1, y: 0 }
|
|
5
|
-
else if (direction === "right") return { x: 1, y: 0 }
|
|
6
|
-
else throw new Error(`Invalid direction "${direction}"`)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const vecToDirection = ({ x, y }: { x: number; y: number }) => {
|
|
10
|
-
if (x > y) y = 0
|
|
11
|
-
if (y > x) x = 0
|
|
12
|
-
if (x > 0 && y === 0) return "right"
|
|
13
|
-
else if (x < 0 && y === 0) return "left"
|
|
14
|
-
else if (x === 0 && y > 0) return "up"
|
|
15
|
-
else if (x === 0 && y < 0) return "down"
|
|
16
|
-
else throw new Error(`Invalid vector for direction conversion (${x}, ${y})`)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const rotateClockwise = (
|
|
20
|
-
direction: "up" | "down" | "left" | "right",
|
|
21
|
-
) => {
|
|
22
|
-
if (direction === "up") return "right"
|
|
23
|
-
else if (direction === "right") return "down"
|
|
24
|
-
else if (direction === "down") return "left"
|
|
25
|
-
else if (direction === "left") return "up"
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const rotateCounterClockwise = (
|
|
29
|
-
direction: "up" | "down" | "left" | "right",
|
|
30
|
-
) => {
|
|
31
|
-
if (direction === "up") return "left"
|
|
32
|
-
else if (direction === "left") return "down"
|
|
33
|
-
else if (direction === "down") return "right"
|
|
34
|
-
else if (direction === "right") return "up"
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const rotateDirection = (
|
|
38
|
-
direction: "up" | "down" | "left" | "right",
|
|
39
|
-
num90DegreeClockwiseTurns: number,
|
|
40
|
-
) => {
|
|
41
|
-
while (num90DegreeClockwiseTurns > 0) {
|
|
42
|
-
direction = rotateClockwise(direction)
|
|
43
|
-
num90DegreeClockwiseTurns--
|
|
44
|
-
}
|
|
45
|
-
while (num90DegreeClockwiseTurns < 0) {
|
|
46
|
-
direction = rotateCounterClockwise(direction)
|
|
47
|
-
num90DegreeClockwiseTurns++
|
|
48
|
-
}
|
|
49
|
-
return direction
|
|
50
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SchematicNetLabel } from "@tscircuit/soup"
|
|
2
|
-
|
|
3
|
-
type AnchorSide = SchematicNetLabel["anchor_side"]
|
|
4
|
-
|
|
5
|
-
export const getRotationFromAnchorSide = (anchor_side: AnchorSide) => {
|
|
6
|
-
if (anchor_side === "left") return 0
|
|
7
|
-
if (anchor_side === "top") return (Math.PI * 3) / 2
|
|
8
|
-
if (anchor_side === "right") return Math.PI
|
|
9
|
-
if (anchor_side === "bottom") return Math.PI / 2
|
|
10
|
-
return 0
|
|
11
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import svgPathBounds from "svg-path-bounds"
|
|
2
|
-
|
|
3
|
-
export function getSVGPathBounds(ds: string[] | string) {
|
|
4
|
-
if (typeof ds === "string") ds = [ds]
|
|
5
|
-
let minX = Infinity,
|
|
6
|
-
maxX = -Infinity,
|
|
7
|
-
minY = Infinity,
|
|
8
|
-
maxY = -Infinity
|
|
9
|
-
|
|
10
|
-
for (const d of ds) {
|
|
11
|
-
const [left, top, right, bottom] = svgPathBounds(d)
|
|
12
|
-
|
|
13
|
-
minX = Math.min(left, minX)
|
|
14
|
-
maxX = Math.max(right, maxX)
|
|
15
|
-
minY = Math.min(top, minY)
|
|
16
|
-
maxY = Math.max(bottom, maxY)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return { minX, maxX, minY, maxY, width: maxX - minX, height: maxY - minY }
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default getSVGPathBounds
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { SchematicNetLabel } from "@tscircuit/soup"
|
|
2
|
-
|
|
3
|
-
type AnchorSide = SchematicNetLabel["anchor_side"]
|
|
4
|
-
|
|
5
|
-
export const getVecFromAnchorSide = (anchor_side: AnchorSide) => {
|
|
6
|
-
if (anchor_side === "left") return { x: -1, y: 0 }
|
|
7
|
-
if (anchor_side === "top") return { x: 0, y: -1 }
|
|
8
|
-
if (anchor_side === "right") return { x: 1, y: 0 }
|
|
9
|
-
if (anchor_side === "bottom") return { x: 0, y: 1 }
|
|
10
|
-
throw new Error(`invalid anchor side "${anchor_side}"`)
|
|
11
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export type Point = { x: number; y: number }
|
|
2
|
-
|
|
3
|
-
export function sub(p1: Point, p2: Point) {
|
|
4
|
-
return { x: p1.x - p2.x, y: p1.y - p2.y }
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function mult(p1: Point, p2: Point) {
|
|
8
|
-
return { x: p1.x * p2.x, y: p1.y * p2.y }
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function mag(p1: Point, p2: Point) {
|
|
12
|
-
const dx = p1.x - p2.x
|
|
13
|
-
const dy = p1.y - p2.y
|
|
14
|
-
return Math.sqrt(dx ** 2 + dy ** 2)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function componentSum(p1: Point) {
|
|
18
|
-
return p1.x + p1.y
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function norm(p1: Point) {
|
|
22
|
-
return {
|
|
23
|
-
x: Math.sign(p1.x),
|
|
24
|
-
y: Math.sign(p1.y),
|
|
25
|
-
}
|
|
26
|
-
}
|
package/src/pages/_app.tsx
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import Head from "next/head"
|
|
2
|
-
|
|
3
|
-
export const App = ({ Component }) => {
|
|
4
|
-
return (
|
|
5
|
-
<>
|
|
6
|
-
<Head>
|
|
7
|
-
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
8
|
-
<link
|
|
9
|
-
rel="preconnect"
|
|
10
|
-
href="https://fonts.gstatic.com"
|
|
11
|
-
crossOrigin="anonymous"
|
|
12
|
-
/>
|
|
13
|
-
<link
|
|
14
|
-
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&display=swap"
|
|
15
|
-
rel="stylesheet"
|
|
16
|
-
/>
|
|
17
|
-
</Head>
|
|
18
|
-
<Component />
|
|
19
|
-
</>
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default App
|
package/src/pages/index.tsx
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React, { Fragment } from "react"
|
|
2
|
-
import { Schematic } from "Schematic"
|
|
3
|
-
|
|
4
|
-
export const ExampleCircuit = () => {
|
|
5
|
-
return (
|
|
6
|
-
<Schematic style={{ height: 500 }}>
|
|
7
|
-
<resistor name="R1" resistance="10 ohm" schX={2} schY={1} />
|
|
8
|
-
<capacitor
|
|
9
|
-
name="C1"
|
|
10
|
-
capacitance="10 uF"
|
|
11
|
-
schX={4}
|
|
12
|
-
schY={2}
|
|
13
|
-
schRotation="90deg"
|
|
14
|
-
/>
|
|
15
|
-
<resistor
|
|
16
|
-
name="R2"
|
|
17
|
-
resistance="10 ohm"
|
|
18
|
-
schX={6}
|
|
19
|
-
schY={1}
|
|
20
|
-
schRotation="90deg"
|
|
21
|
-
/>
|
|
22
|
-
<trace
|
|
23
|
-
path={[".R1 > port.right", ".C1 > port.left", ".R2 > port.left"]}
|
|
24
|
-
/>
|
|
25
|
-
<powersource voltage="5V" schX={1} schY={2} name="main_power" />
|
|
26
|
-
<trace path={[".main_power > port.positive", ".R1 > port.left"]} />
|
|
27
|
-
<trace
|
|
28
|
-
path={["power > port.negative", ".C1 > port.right", ".R2 > port.right"]}
|
|
29
|
-
/>
|
|
30
|
-
<bug
|
|
31
|
-
name="B1"
|
|
32
|
-
schPortArrangement={{ leftSize: 3, rightSize: 3 }}
|
|
33
|
-
schX={8}
|
|
34
|
-
schY={3}
|
|
35
|
-
pinLabels={{
|
|
36
|
-
1: "PWR",
|
|
37
|
-
2: "NC",
|
|
38
|
-
3: "RG",
|
|
39
|
-
4: "D0",
|
|
40
|
-
5: "D1",
|
|
41
|
-
6: "GND",
|
|
42
|
-
}}
|
|
43
|
-
/>
|
|
44
|
-
<trace path={[".B1 > port.PWR", ".R2 > port.left"]} />
|
|
45
|
-
{/* <ground name="GND" schX={11} schY={3} /> */}
|
|
46
|
-
<trace from=".B1 > port.GND" to=".GND" />
|
|
47
|
-
<diode name="D1" schX={6} schY={3.5} schRotation="180deg" />
|
|
48
|
-
<trace from=".D1 > .left" to=".B1 > .RG" />
|
|
49
|
-
<trace from=".D1 > .right" to=".C1> .right" />
|
|
50
|
-
</Schematic>
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export default ExampleCircuit
|
package/src/pages/style.css
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { createRenderContextStore } from "lib/render-context"
|
|
2
|
-
import { useMemo } from "react"
|
|
3
|
-
import { createContext } from "react"
|
|
4
|
-
|
|
5
|
-
export const StoreContext = createContext(null)
|
|
6
|
-
|
|
7
|
-
export const ContextProviders = ({ children }: { children?: any }) => {
|
|
8
|
-
const store = useMemo(() => createRenderContextStore(), [])
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<StoreContext.Provider value={store as any}>
|
|
12
|
-
{children}
|
|
13
|
-
</StoreContext.Provider>
|
|
14
|
-
)
|
|
15
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import { SVGPathComponent } from "./SVGPathComponent"
|
|
3
|
-
|
|
4
|
-
export const DebugPoint = ({
|
|
5
|
-
center,
|
|
6
|
-
}: {
|
|
7
|
-
center: { x: number; y: number }
|
|
8
|
-
}) => {
|
|
9
|
-
return (
|
|
10
|
-
<SVGPathComponent
|
|
11
|
-
rotation={0}
|
|
12
|
-
center={center}
|
|
13
|
-
size={{ width: 0.02, height: 0.02 }}
|
|
14
|
-
paths={[
|
|
15
|
-
{
|
|
16
|
-
stroke: "red",
|
|
17
|
-
strokeWidth: 0.5,
|
|
18
|
-
// d: "M -1 -1 l 1 1 M -1 1 l 1 -1",
|
|
19
|
-
//square
|
|
20
|
-
d: "M -1 -1 l 2 0 l 0 2 l -2 0 l 0 -2",
|
|
21
|
-
},
|
|
22
|
-
]}
|
|
23
|
-
/>
|
|
24
|
-
)
|
|
25
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
interface Props {
|
|
2
|
-
text: string
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export default ({ text }: Props) => {
|
|
6
|
-
return (
|
|
7
|
-
<div
|
|
8
|
-
style={{
|
|
9
|
-
position: "fixed",
|
|
10
|
-
backgroundColor: "red",
|
|
11
|
-
color: "white",
|
|
12
|
-
fontSize: 14,
|
|
13
|
-
fontFamily: "sans-serif",
|
|
14
|
-
padding: 5,
|
|
15
|
-
right: 0,
|
|
16
|
-
top: 0,
|
|
17
|
-
opacity: 0.75,
|
|
18
|
-
}}
|
|
19
|
-
>
|
|
20
|
-
{text}
|
|
21
|
-
</div>
|
|
22
|
-
)
|
|
23
|
-
}
|