circuit-to-svg 0.0.107 → 0.0.109
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/dist/index.js +37 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -220,6 +220,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, transform) {
|
|
|
220
220
|
type: "element",
|
|
221
221
|
attributes: {
|
|
222
222
|
class: "pcb-hole-outer",
|
|
223
|
+
fill: "rgb(200, 52, 52)",
|
|
223
224
|
d: `M${x - outerRadiusX},${y - straightLength / 2} v${straightLength} a${outerRadiusX},${outerRadiusX} 0 0 0 ${scaledOuterWidth},0 v-${straightLength} a${outerRadiusX},${outerRadiusX} 0 0 0 -${scaledOuterWidth},0 z`
|
|
224
225
|
},
|
|
225
226
|
value: "",
|
|
@@ -231,6 +232,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, transform) {
|
|
|
231
232
|
type: "element",
|
|
232
233
|
attributes: {
|
|
233
234
|
class: "pcb-hole-inner",
|
|
235
|
+
fill: "rgb(255, 38, 226)",
|
|
234
236
|
d: `M${x - innerRadiusX},${y - (scaledHoleHeight - scaledHoleWidth) / 2} v${scaledHoleHeight - scaledHoleWidth} a${innerRadiusX},${innerRadiusX} 0 0 0 ${scaledHoleWidth},0 v-${scaledHoleHeight - scaledHoleWidth} a${innerRadiusX},${innerRadiusX} 0 0 0 -${scaledHoleWidth},0 z`
|
|
235
237
|
},
|
|
236
238
|
value: "",
|
|
@@ -259,6 +261,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, transform) {
|
|
|
259
261
|
type: "element",
|
|
260
262
|
attributes: {
|
|
261
263
|
class: "pcb-hole-outer",
|
|
264
|
+
fill: "rgb(200, 52, 52)",
|
|
262
265
|
cx: x.toString(),
|
|
263
266
|
cy: y.toString(),
|
|
264
267
|
r: outerRadius.toString()
|
|
@@ -271,6 +274,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, transform) {
|
|
|
271
274
|
type: "element",
|
|
272
275
|
attributes: {
|
|
273
276
|
class: "pcb-hole-inner",
|
|
277
|
+
fill: "rgb(255, 38, 226)",
|
|
274
278
|
cx: x.toString(),
|
|
275
279
|
cy: y.toString(),
|
|
276
280
|
r: innerRadius.toString()
|
|
@@ -307,6 +311,8 @@ function createSvgObjectsFromPcbSilkscreenPath(silkscreenPath, transform) {
|
|
|
307
311
|
attributes: {
|
|
308
312
|
class: `pcb-silkscreen pcb-silkscreen-${silkscreenPath.layer}`,
|
|
309
313
|
d: path,
|
|
314
|
+
fill: "none",
|
|
315
|
+
stroke: "#f2eda1",
|
|
310
316
|
"stroke-width": (silkscreenPath.stroke_width * Math.abs(transform.a)).toString(),
|
|
311
317
|
"data-pcb-component-id": silkscreenPath.pcb_component_id,
|
|
312
318
|
"data-pcb-silkscreen-path-id": silkscreenPath.pcb_silkscreen_path_id
|
|
@@ -353,6 +359,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, transform) {
|
|
|
353
359
|
attributes: {
|
|
354
360
|
x: "0",
|
|
355
361
|
y: "0",
|
|
362
|
+
fill: "#f2eda1",
|
|
356
363
|
"font-family": "Arial, sans-serif",
|
|
357
364
|
"font-size": transformedFontSize.toString(),
|
|
358
365
|
"text-anchor": "middle",
|
|
@@ -406,7 +413,8 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, transform) {
|
|
|
406
413
|
width: transformedWidth.toString(),
|
|
407
414
|
height: transformedHeight.toString(),
|
|
408
415
|
class: `pcb-silkscreen-rect pcb-silkscreen-${layer}`,
|
|
409
|
-
|
|
416
|
+
fill: "none",
|
|
417
|
+
stroke: "#f2eda1",
|
|
410
418
|
"stroke-width": "1",
|
|
411
419
|
"data-pcb-silkscreen-rect-id": pcb_silkscreen_rect_id
|
|
412
420
|
},
|
|
@@ -436,9 +444,6 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, transform)
|
|
|
436
444
|
center.y
|
|
437
445
|
]);
|
|
438
446
|
const transformedRadius = radius * Math.abs(transform.a);
|
|
439
|
-
console.debug(
|
|
440
|
-
`Transformed Circle - X: ${transformedX}, Y: ${transformedY}, Radius: ${transformedRadius}`
|
|
441
|
-
);
|
|
442
447
|
const svgObject = {
|
|
443
448
|
name: "circle",
|
|
444
449
|
type: "element",
|
|
@@ -447,14 +452,13 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, transform)
|
|
|
447
452
|
cy: transformedY.toString(),
|
|
448
453
|
r: transformedRadius.toString(),
|
|
449
454
|
class: `pcb-silkscreen-circle pcb-silkscreen-${layer}`,
|
|
450
|
-
stroke: "
|
|
451
|
-
"stroke-width": "
|
|
455
|
+
stroke: "#f2eda1",
|
|
456
|
+
"stroke-width": "1",
|
|
452
457
|
"data-pcb-silkscreen-circle-id": pcb_silkscreen_circle_id
|
|
453
458
|
},
|
|
454
459
|
value: "",
|
|
455
460
|
children: []
|
|
456
461
|
};
|
|
457
|
-
console.log(svgObject);
|
|
458
462
|
return [svgObject];
|
|
459
463
|
}
|
|
460
464
|
|
|
@@ -488,6 +492,7 @@ function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, transform) {
|
|
|
488
492
|
y1: transformedY1.toString(),
|
|
489
493
|
x2: transformedX2.toString(),
|
|
490
494
|
y2: transformedY2.toString(),
|
|
495
|
+
stroke: "#f2eda1",
|
|
491
496
|
"stroke-width": transformedStrokeWidth.toString(),
|
|
492
497
|
class: `pcb-silkscreen-line pcb-silkscreen-${layer}`,
|
|
493
498
|
"data-pcb-silkscreen-line-id": pcb_silkscreen_line_id
|
|
@@ -532,7 +537,7 @@ function createSvgObjectsFromPcbTrace(trace, transform) {
|
|
|
532
537
|
if (!layer) continue;
|
|
533
538
|
const layerColor = LAYER_NAME_TO_COLOR[layer] ?? "white";
|
|
534
539
|
const traceWidth = "width" in start ? start.width : "width" in end ? end.width : null;
|
|
535
|
-
|
|
540
|
+
const svgObject = {
|
|
536
541
|
name: "path",
|
|
537
542
|
type: "element",
|
|
538
543
|
value: "",
|
|
@@ -540,14 +545,28 @@ function createSvgObjectsFromPcbTrace(trace, transform) {
|
|
|
540
545
|
attributes: {
|
|
541
546
|
class: "pcb-trace",
|
|
542
547
|
stroke: layerColor,
|
|
548
|
+
fill: "none",
|
|
543
549
|
d: `M ${startPoint[0]} ${startPoint[1]} L ${endPoint[0]} ${endPoint[1]}`,
|
|
544
550
|
"stroke-width": traceWidth ? (traceWidth * Math.abs(transform.a)).toString() : "0.3",
|
|
545
551
|
"stroke-linecap": "round",
|
|
546
552
|
"stroke-linejoin": "round",
|
|
547
|
-
"shape-rendering": "crispEdges"
|
|
553
|
+
"shape-rendering": "crispEdges",
|
|
554
|
+
"data-layer": layer
|
|
548
555
|
}
|
|
549
|
-
}
|
|
556
|
+
};
|
|
557
|
+
svgObjects.push(svgObject);
|
|
550
558
|
}
|
|
559
|
+
svgObjects.sort((a, b) => {
|
|
560
|
+
const layerA = a.attributes["data-layer"];
|
|
561
|
+
const layerB = b.attributes["data-layer"];
|
|
562
|
+
if (layerA === "bottom" && layerB !== "bottom") {
|
|
563
|
+
return -1;
|
|
564
|
+
}
|
|
565
|
+
if (layerA === "top" && layerB !== "top") {
|
|
566
|
+
return 1;
|
|
567
|
+
}
|
|
568
|
+
return 0;
|
|
569
|
+
});
|
|
551
570
|
return svgObjects;
|
|
552
571
|
}
|
|
553
572
|
|
|
@@ -655,6 +674,7 @@ function createSvgObjectsFromPcbBoard(pcbBoard, transform) {
|
|
|
655
674
|
attributes: {
|
|
656
675
|
class: "pcb-board",
|
|
657
676
|
d: path,
|
|
677
|
+
fill: "none",
|
|
658
678
|
stroke: "rgba(255, 255, 255, 0.5)",
|
|
659
679
|
"stroke-width": (0.1 * Math.abs(transform.a)).toString()
|
|
660
680
|
}
|
|
@@ -681,6 +701,7 @@ function createSvgObjectsFromPcbVia(hole, transform) {
|
|
|
681
701
|
type: "element",
|
|
682
702
|
attributes: {
|
|
683
703
|
class: "pcb-hole-outer",
|
|
704
|
+
fill: "rgb(200, 52, 52)",
|
|
684
705
|
cx: x.toString(),
|
|
685
706
|
cy: y.toString(),
|
|
686
707
|
r: outerRadius.toString()
|
|
@@ -691,6 +712,7 @@ function createSvgObjectsFromPcbVia(hole, transform) {
|
|
|
691
712
|
type: "element",
|
|
692
713
|
attributes: {
|
|
693
714
|
class: "pcb-hole-inner",
|
|
715
|
+
fill: "rgb(255, 38, 226)",
|
|
694
716
|
cx: x.toString(),
|
|
695
717
|
cy: y.toString(),
|
|
696
718
|
r: innerRadius.toString()
|
|
@@ -972,19 +994,7 @@ function convertCircuitJsonToPcbSvg(soup, options) {
|
|
|
972
994
|
children: [
|
|
973
995
|
{
|
|
974
996
|
type: "text",
|
|
975
|
-
value:
|
|
976
|
-
.boundary { fill: #000; }
|
|
977
|
-
.pcb-board { fill: none; }
|
|
978
|
-
.pcb-trace { fill: none; }
|
|
979
|
-
.pcb-hole-outer { fill: rgb(200, 52, 52); }
|
|
980
|
-
.pcb-hole-inner { fill: rgb(255, 38, 226); }
|
|
981
|
-
.pcb-pad { }
|
|
982
|
-
.pcb-boundary { fill: none; stroke: #fff; stroke-width: 0.3; }
|
|
983
|
-
.pcb-silkscreen { fill: none; }
|
|
984
|
-
.pcb-silkscreen-top { stroke: #f2eda1; }
|
|
985
|
-
.pcb-silkscreen-bottom { stroke: #f2eda1; }
|
|
986
|
-
.pcb-silkscreen-text { fill: #f2eda1; }
|
|
987
|
-
`
|
|
997
|
+
value: ""
|
|
988
998
|
}
|
|
989
999
|
]
|
|
990
1000
|
},
|
|
@@ -995,6 +1005,7 @@ function convertCircuitJsonToPcbSvg(soup, options) {
|
|
|
995
1005
|
class: "boundary",
|
|
996
1006
|
x: "0",
|
|
997
1007
|
y: "0",
|
|
1008
|
+
fill: "#000",
|
|
998
1009
|
width: svgWidth.toString(),
|
|
999
1010
|
height: svgHeight.toString()
|
|
1000
1011
|
}
|
|
@@ -1139,6 +1150,9 @@ function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
|
1139
1150
|
children: [],
|
|
1140
1151
|
attributes: {
|
|
1141
1152
|
class: "pcb-boundary",
|
|
1153
|
+
fill: "none",
|
|
1154
|
+
stroke: "#fff",
|
|
1155
|
+
"stroke-width": "0.3",
|
|
1142
1156
|
x: x.toString(),
|
|
1143
1157
|
y: y.toString(),
|
|
1144
1158
|
width: width.toString(),
|