circuit-to-svg 0.0.209 → 0.0.210
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/README.md +156 -35
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,20 +19,6 @@ bun add circuit-to-svg
|
|
|
19
19
|
|
|
20
20
|
This library provides functionality to convert Circuit JSON into SVG (Scalable Vector Graphics) representations. It supports both schematic and PCB (Printed Circuit Board), and Assembly layouts.
|
|
21
21
|
|
|
22
|
-
## Features
|
|
23
|
-
|
|
24
|
-
- Convert schematic circuit descriptions to SVG
|
|
25
|
-
- Convert PCB layouts to SVG
|
|
26
|
-
- Support for various circuit elements:
|
|
27
|
-
- Components
|
|
28
|
-
- Traces
|
|
29
|
-
- Text labels
|
|
30
|
-
- Net labels
|
|
31
|
-
- PCB boards
|
|
32
|
-
- PCB components
|
|
33
|
-
- PCB traces
|
|
34
|
-
- PCB holes and pads
|
|
35
|
-
|
|
36
22
|
## Installation
|
|
37
23
|
|
|
38
24
|
```bash
|
|
@@ -43,28 +29,25 @@ npm install circuit-to-svg
|
|
|
43
29
|
|
|
44
30
|
```typescript
|
|
45
31
|
import { readFileSync, writeFileSync } from 'fs'
|
|
46
|
-
import {
|
|
47
|
-
convertCircuitJsonToSchematicSvg,
|
|
48
|
-
convertCircuitJsonToPcbSvg,
|
|
49
|
-
} from 'circuit-to-svg'
|
|
32
|
+
import { convertCircuitJsonToSchematicSvg } from 'circuit-to-svg'
|
|
50
33
|
|
|
51
34
|
const circuitJson = JSON.parse(readFileSync('circuit.json', 'utf8'))
|
|
35
|
+
const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson)
|
|
52
36
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
width: 1000,
|
|
56
|
-
height: 600,
|
|
57
|
-
grid: true,
|
|
58
|
-
})
|
|
37
|
+
writeFileSync('schematic.svg', schematicSvg)
|
|
38
|
+
```
|
|
59
39
|
|
|
60
|
-
|
|
61
|
-
const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson, {
|
|
62
|
-
matchBoardAspectRatio: true,
|
|
63
|
-
backgroundColor: '#1e1e1e',
|
|
64
|
-
})
|
|
40
|
+
Explore the API sections below to render PCB, assembly, pinout, simulation, and solder paste views.
|
|
65
41
|
|
|
66
|
-
|
|
67
|
-
|
|
42
|
+
| Function | Description |
|
|
43
|
+
| --- | --- |
|
|
44
|
+
| [`convertCircuitJsonToSchematicSvg`](#convertcircuitjsontoschematicsvg) | Generate schematic SVG output from Circuit JSON. |
|
|
45
|
+
| [`convertCircuitJsonToSchematicSimulationSvg`](#convertcircuitjsontoschematicsimulationsvg) | Overlay simulation data on schematic diagrams. |
|
|
46
|
+
| [`convertCircuitJsonToPcbSvg`](#convertcircuitjsontopcbsvg) | Render PCB layouts as SVG graphics. |
|
|
47
|
+
| [`convertCircuitJsonToSolderPasteMask`](#convertcircuitjsontosolderpastemask) | Create solder paste mask layers for fabrication. |
|
|
48
|
+
| [`convertCircuitJsonToAssemblySvg`](#convertcircuitjsontoassemblysvg) | Produce assembly view SVGs for board visualization. |
|
|
49
|
+
| [`convertCircuitJsonToPinoutSvg`](#convertcircuitjsontopinoutsvg) | Build annotated pinout diagrams for boards and modules. |
|
|
50
|
+
| [`convertCircuitJsonToSimulationGraphSvg`](#convertcircuitjsontosimulationgraphsvg) | Plot simulation experiment results as SVG graphs. |
|
|
68
51
|
|
|
69
52
|
## API
|
|
70
53
|
|
|
@@ -74,8 +57,22 @@ writeFileSync('board.svg', pcbSvg)
|
|
|
74
57
|
|
|
75
58
|
Converts a schematic circuit description to an SVG string.
|
|
76
59
|
|
|
60
|
+
```typescript
|
|
61
|
+
import { convertCircuitJsonToSchematicSvg } from 'circuit-to-svg'
|
|
62
|
+
|
|
63
|
+
const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson, {
|
|
64
|
+
includeVersion: true,
|
|
65
|
+
})
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
See the [schematic grid snapshot](tests/sch/__snapshots__/grid-and-points.snap.svg).
|
|
69
|
+
|
|
77
70
|
#### Options
|
|
78
71
|
|
|
72
|
+
- `width` and `height` – dimensions of the output SVG. Defaults to `1200x600`.
|
|
73
|
+
- `grid` – enable a schematic grid (`true`) or configure cell size and labels.
|
|
74
|
+
- `labeledPoints` – annotate specific coordinates with helper labels.
|
|
75
|
+
- `colorOverrides` – override portions of the schematic color palette.
|
|
79
76
|
- `includeVersion` – if `true`, add a `data-circuit-to-svg-version` attribute to
|
|
80
77
|
the root `<svg>`.
|
|
81
78
|
|
|
@@ -85,6 +82,17 @@ Converts a schematic circuit description to an SVG string.
|
|
|
85
82
|
|
|
86
83
|
Converts a PCB layout description to an SVG string.
|
|
87
84
|
|
|
85
|
+
```typescript
|
|
86
|
+
import { convertCircuitJsonToPcbSvg } from 'circuit-to-svg'
|
|
87
|
+
|
|
88
|
+
const pcbSvg = convertCircuitJsonToPcbSvg(circuitJson, {
|
|
89
|
+
matchBoardAspectRatio: true,
|
|
90
|
+
backgroundColor: '#1e1e1e',
|
|
91
|
+
})
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
See the [PCB default snapshot](tests/pcb/__snapshots__/default.snap.svg).
|
|
95
|
+
|
|
88
96
|
#### Options
|
|
89
97
|
|
|
90
98
|
- `width` and `height` – dimensions of the output SVG. Defaults to `800x600`.
|
|
@@ -103,16 +111,129 @@ Converts a PCB layout description to an SVG string.
|
|
|
103
111
|
|
|
104
112
|
Converts circuit JSON into an assembly view of the board and components.
|
|
105
113
|
|
|
114
|
+
```typescript
|
|
115
|
+
import { convertCircuitJsonToAssemblySvg } from 'circuit-to-svg'
|
|
116
|
+
|
|
117
|
+
const assemblySvg = convertCircuitJsonToAssemblySvg(circuitJson, {
|
|
118
|
+
includeVersion: false,
|
|
119
|
+
})
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
See the [assembly board snapshot](tests/assembly/__snapshots__/first-assembly-test.snap.svg).
|
|
123
|
+
|
|
106
124
|
#### Options
|
|
107
125
|
|
|
108
126
|
- `width` and `height` – dimensions of the output SVG. Defaults to `800x600`.
|
|
109
127
|
- `includeVersion` – if `true`, add a `data-circuit-to-svg-version` attribute to
|
|
110
128
|
the root `<svg>`.
|
|
111
129
|
|
|
112
|
-
|
|
130
|
+
### convertCircuitJsonToPinoutSvg
|
|
131
|
+
|
|
132
|
+
`convertCircuitJsonToPinoutSvg(circuitJson: AnyCircuitElement[], options?): string`
|
|
133
|
+
|
|
134
|
+
Generates pinout diagrams that call out ports, pads, and holes for boards or modules.
|
|
113
135
|
|
|
114
|
-
|
|
136
|
+
```typescript
|
|
137
|
+
import { convertCircuitJsonToPinoutSvg } from 'circuit-to-svg'
|
|
138
|
+
|
|
139
|
+
const pinoutSvg = convertCircuitJsonToPinoutSvg(circuitJson)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
See the [pinout snapshot](tests/pinout/__snapshots__/pinout-basic.snap.svg).
|
|
143
|
+
|
|
144
|
+
#### Options
|
|
145
|
+
|
|
146
|
+
- `width` and `height` – dimensions of the output SVG. Defaults to `800x600`.
|
|
147
|
+
- `includeVersion` – if `true`, add a `data-circuit-to-svg-version` attribute to
|
|
148
|
+
the root `<svg>`.
|
|
115
149
|
|
|
116
|
-
|
|
150
|
+
### convertCircuitJsonToSchematicSimulationSvg
|
|
151
|
+
|
|
152
|
+
`convertCircuitJsonToSchematicSimulationSvg({
|
|
153
|
+
circuitJson,
|
|
154
|
+
simulation_experiment_id,
|
|
155
|
+
simulation_transient_voltage_graph_ids?,
|
|
156
|
+
width?,
|
|
157
|
+
height?,
|
|
158
|
+
schematicHeightRatio?,
|
|
159
|
+
schematicOptions?,
|
|
160
|
+
includeVersion?,
|
|
161
|
+
}): string`
|
|
162
|
+
|
|
163
|
+
Overlays simulation results directly on the rendered schematic for easy debugging.
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import { convertCircuitJsonToSchematicSimulationSvg } from 'circuit-to-svg'
|
|
167
|
+
|
|
168
|
+
const schematicSimulationSvg = convertCircuitJsonToSchematicSimulationSvg({
|
|
169
|
+
circuitJson,
|
|
170
|
+
simulation_experiment_id: 'simulation-experiment-id',
|
|
171
|
+
simulation_transient_voltage_graph_ids: ['transient-graph-id'],
|
|
172
|
+
schematicHeightRatio: 0.6,
|
|
173
|
+
})
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
See the [schematic simulation snapshot](tests/sim/__snapshots__/schematic-simulation-combined.snap.svg).
|
|
177
|
+
|
|
178
|
+
#### Options
|
|
179
|
+
|
|
180
|
+
- `width` and `height` – overall SVG dimensions. Defaults to `1200x1200`.
|
|
181
|
+
- `schematicHeightRatio` – ratio of the SVG dedicated to the schematic view. Defaults to `0.55`.
|
|
182
|
+
- `schematicOptions` – forward additional schematic rendering options (except `width`, `height`, and `includeVersion`).
|
|
183
|
+
- `includeVersion` – if `true`, add a `data-circuit-to-svg-version` attribute to
|
|
184
|
+
the root `<svg>`.
|
|
185
|
+
|
|
186
|
+
### convertCircuitJsonToSimulationGraphSvg
|
|
187
|
+
|
|
188
|
+
`convertCircuitJsonToSimulationGraphSvg({
|
|
189
|
+
circuitJson,
|
|
190
|
+
simulation_experiment_id,
|
|
191
|
+
simulation_transient_voltage_graph_ids?,
|
|
192
|
+
width?,
|
|
193
|
+
height?,
|
|
194
|
+
includeVersion?,
|
|
195
|
+
}): string`
|
|
196
|
+
|
|
197
|
+
Creates standalone graphs for circuit simulation experiments.
|
|
198
|
+
|
|
199
|
+
```typescript
|
|
200
|
+
import { convertCircuitJsonToSimulationGraphSvg } from 'circuit-to-svg'
|
|
201
|
+
|
|
202
|
+
const simulationGraphSvg = convertCircuitJsonToSimulationGraphSvg({
|
|
203
|
+
circuitJson,
|
|
204
|
+
simulation_experiment_id: 'simulation-experiment-id',
|
|
205
|
+
simulation_transient_voltage_graph_ids: ['transient-graph-id'],
|
|
206
|
+
})
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
See the [simulation graph snapshot](tests/sim/__snapshots__/simulation-graph.snap.svg).
|
|
210
|
+
|
|
211
|
+
#### Options
|
|
212
|
+
|
|
213
|
+
- `width` and `height` – SVG dimensions for the graph. Defaults to `1200x600`.
|
|
214
|
+
- `includeVersion` – if `true`, add a `data-circuit-to-svg-version` attribute to
|
|
215
|
+
the root `<svg>`.
|
|
216
|
+
|
|
217
|
+
### convertCircuitJsonToSolderPasteMask
|
|
218
|
+
|
|
219
|
+
`convertCircuitJsonToSolderPasteMask(circuitJson: AnyCircuitElement[], options: { layer: 'top' | 'bottom'; width?; height?; includeVersion? }): string`
|
|
220
|
+
|
|
221
|
+
Produces top and bottom solder paste mask renderings suitable for stencil generation.
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import { convertCircuitJsonToSolderPasteMask } from 'circuit-to-svg'
|
|
225
|
+
|
|
226
|
+
const solderPasteMaskSvg = convertCircuitJsonToSolderPasteMask(circuitJson, {
|
|
227
|
+
layer: 'top',
|
|
228
|
+
})
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
See the [solder paste snapshot](tests/pcb/__snapshots__/solder-paste.test.tsx.top.snap.svg).
|
|
232
|
+
|
|
233
|
+
#### Options
|
|
234
|
+
|
|
235
|
+
- `layer` – `'top' | 'bottom'`, chooses which solder paste layer to render. Defaults to `'top'`.
|
|
236
|
+
- `width` and `height` – dimensions of the output SVG. Defaults to `800x600`.
|
|
237
|
+
- `includeVersion` – if `true`, add a `data-circuit-to-svg-version` attribute to
|
|
238
|
+
the root `<svg>`.
|
|
117
239
|
|
|
118
|
-
This project is licensed under the MIT License.
|
package/dist/index.js
CHANGED
|
@@ -1783,7 +1783,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
1783
1783
|
var package_default = {
|
|
1784
1784
|
name: "circuit-to-svg",
|
|
1785
1785
|
type: "module",
|
|
1786
|
-
version: "0.0.
|
|
1786
|
+
version: "0.0.209",
|
|
1787
1787
|
description: "Convert Circuit JSON to SVG",
|
|
1788
1788
|
main: "dist/index.js",
|
|
1789
1789
|
files: [
|