circuit-to-svg 0.0.108 → 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 +29 -12
- 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()
|
|
@@ -533,7 +537,7 @@ function createSvgObjectsFromPcbTrace(trace, transform) {
|
|
|
533
537
|
if (!layer) continue;
|
|
534
538
|
const layerColor = LAYER_NAME_TO_COLOR[layer] ?? "white";
|
|
535
539
|
const traceWidth = "width" in start ? start.width : "width" in end ? end.width : null;
|
|
536
|
-
|
|
540
|
+
const svgObject = {
|
|
537
541
|
name: "path",
|
|
538
542
|
type: "element",
|
|
539
543
|
value: "",
|
|
@@ -541,14 +545,28 @@ function createSvgObjectsFromPcbTrace(trace, transform) {
|
|
|
541
545
|
attributes: {
|
|
542
546
|
class: "pcb-trace",
|
|
543
547
|
stroke: layerColor,
|
|
548
|
+
fill: "none",
|
|
544
549
|
d: `M ${startPoint[0]} ${startPoint[1]} L ${endPoint[0]} ${endPoint[1]}`,
|
|
545
550
|
"stroke-width": traceWidth ? (traceWidth * Math.abs(transform.a)).toString() : "0.3",
|
|
546
551
|
"stroke-linecap": "round",
|
|
547
552
|
"stroke-linejoin": "round",
|
|
548
|
-
"shape-rendering": "crispEdges"
|
|
553
|
+
"shape-rendering": "crispEdges",
|
|
554
|
+
"data-layer": layer
|
|
549
555
|
}
|
|
550
|
-
}
|
|
556
|
+
};
|
|
557
|
+
svgObjects.push(svgObject);
|
|
551
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
|
+
});
|
|
552
570
|
return svgObjects;
|
|
553
571
|
}
|
|
554
572
|
|
|
@@ -656,6 +674,7 @@ function createSvgObjectsFromPcbBoard(pcbBoard, transform) {
|
|
|
656
674
|
attributes: {
|
|
657
675
|
class: "pcb-board",
|
|
658
676
|
d: path,
|
|
677
|
+
fill: "none",
|
|
659
678
|
stroke: "rgba(255, 255, 255, 0.5)",
|
|
660
679
|
"stroke-width": (0.1 * Math.abs(transform.a)).toString()
|
|
661
680
|
}
|
|
@@ -682,6 +701,7 @@ function createSvgObjectsFromPcbVia(hole, transform) {
|
|
|
682
701
|
type: "element",
|
|
683
702
|
attributes: {
|
|
684
703
|
class: "pcb-hole-outer",
|
|
704
|
+
fill: "rgb(200, 52, 52)",
|
|
685
705
|
cx: x.toString(),
|
|
686
706
|
cy: y.toString(),
|
|
687
707
|
r: outerRadius.toString()
|
|
@@ -692,6 +712,7 @@ function createSvgObjectsFromPcbVia(hole, transform) {
|
|
|
692
712
|
type: "element",
|
|
693
713
|
attributes: {
|
|
694
714
|
class: "pcb-hole-inner",
|
|
715
|
+
fill: "rgb(255, 38, 226)",
|
|
695
716
|
cx: x.toString(),
|
|
696
717
|
cy: y.toString(),
|
|
697
718
|
r: innerRadius.toString()
|
|
@@ -973,15 +994,7 @@ function convertCircuitJsonToPcbSvg(soup, options) {
|
|
|
973
994
|
children: [
|
|
974
995
|
{
|
|
975
996
|
type: "text",
|
|
976
|
-
value:
|
|
977
|
-
.boundary { fill: #000; }
|
|
978
|
-
.pcb-board { fill: none; }
|
|
979
|
-
.pcb-trace { fill: none; }
|
|
980
|
-
.pcb-hole-outer { fill: rgb(200, 52, 52); }
|
|
981
|
-
.pcb-hole-inner { fill: rgb(255, 38, 226); }
|
|
982
|
-
.pcb-pad { }
|
|
983
|
-
.pcb-boundary { fill: none; stroke: #fff; stroke-width: 0.3; }
|
|
984
|
-
`
|
|
997
|
+
value: ""
|
|
985
998
|
}
|
|
986
999
|
]
|
|
987
1000
|
},
|
|
@@ -992,6 +1005,7 @@ function convertCircuitJsonToPcbSvg(soup, options) {
|
|
|
992
1005
|
class: "boundary",
|
|
993
1006
|
x: "0",
|
|
994
1007
|
y: "0",
|
|
1008
|
+
fill: "#000",
|
|
995
1009
|
width: svgWidth.toString(),
|
|
996
1010
|
height: svgHeight.toString()
|
|
997
1011
|
}
|
|
@@ -1136,6 +1150,9 @@ function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
|
1136
1150
|
children: [],
|
|
1137
1151
|
attributes: {
|
|
1138
1152
|
class: "pcb-boundary",
|
|
1153
|
+
fill: "none",
|
|
1154
|
+
stroke: "#fff",
|
|
1155
|
+
"stroke-width": "0.3",
|
|
1139
1156
|
x: x.toString(),
|
|
1140
1157
|
y: y.toString(),
|
|
1141
1158
|
width: width.toString(),
|