circuit-to-svg 0.0.199 → 0.0.201
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.d.ts +2 -0
- package/dist/index.js +66 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -42,6 +42,7 @@ interface Options$4 {
|
|
|
42
42
|
backgroundColor?: string;
|
|
43
43
|
drawPaddingOutsideBoard?: boolean;
|
|
44
44
|
includeVersion?: boolean;
|
|
45
|
+
renderSolderMask?: boolean;
|
|
45
46
|
}
|
|
46
47
|
interface PcbContext {
|
|
47
48
|
transform: Matrix;
|
|
@@ -49,6 +50,7 @@ interface PcbContext {
|
|
|
49
50
|
shouldDrawErrors?: boolean;
|
|
50
51
|
drawPaddingOutsideBoard?: boolean;
|
|
51
52
|
colorMap: PcbColorMap;
|
|
53
|
+
renderSolderMask?: boolean;
|
|
52
54
|
}
|
|
53
55
|
declare function convertCircuitJsonToPcbSvg(circuitJson: AnyCircuitElement[], options?: Options$4): string;
|
|
54
56
|
/**
|
package/dist/index.js
CHANGED
|
@@ -680,8 +680,8 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
680
680
|
const transformedFontSize = font_size * Math.abs(transform.a);
|
|
681
681
|
let textAnchor = "middle";
|
|
682
682
|
let dominantBaseline = "central";
|
|
683
|
-
|
|
684
|
-
|
|
683
|
+
const dx = 0;
|
|
684
|
+
const dy = 0;
|
|
685
685
|
switch (anchor_alignment) {
|
|
686
686
|
case "top_left":
|
|
687
687
|
textAnchor = "start";
|
|
@@ -723,7 +723,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
723
723
|
}
|
|
724
724
|
const textTransform = compose2(
|
|
725
725
|
translate2(transformedX, transformedY),
|
|
726
|
-
rotate2(ccw_rotation * Math.PI / 180),
|
|
726
|
+
rotate2(-ccw_rotation * Math.PI / 180),
|
|
727
727
|
...layer === "bottom" ? [scale(-1, 1)] : []
|
|
728
728
|
);
|
|
729
729
|
const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
|
|
@@ -980,7 +980,7 @@ function solderPasteLayerNameToColor(layerName) {
|
|
|
980
980
|
|
|
981
981
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace.ts
|
|
982
982
|
function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
983
|
-
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
983
|
+
const { transform, layer: layerFilter, colorMap: colorMap2, renderSolderMask } = ctx;
|
|
984
984
|
if (!trace.route || !Array.isArray(trace.route) || trace.route.length < 2)
|
|
985
985
|
return [];
|
|
986
986
|
const segments = pairs(trace.route);
|
|
@@ -991,26 +991,66 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
|
991
991
|
const layer = "layer" in start ? start.layer : "layer" in end ? end.layer : null;
|
|
992
992
|
if (!layer) continue;
|
|
993
993
|
if (layerFilter && layer !== layerFilter) continue;
|
|
994
|
-
const
|
|
994
|
+
const copperColor = layerNameToColor(layer, colorMap2);
|
|
995
|
+
const maskColor = colorMap2.soldermask[layer] ?? copperColor;
|
|
995
996
|
const traceWidth = "width" in start ? start.width : "width" in end ? end.width : null;
|
|
996
|
-
const
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
997
|
+
const width = traceWidth ? (traceWidth * Math.abs(transform.a)).toString() : "0.3";
|
|
998
|
+
if (renderSolderMask) {
|
|
999
|
+
const copperObject = {
|
|
1000
|
+
name: "path",
|
|
1001
|
+
type: "element",
|
|
1002
|
+
value: "",
|
|
1003
|
+
children: [],
|
|
1004
|
+
attributes: {
|
|
1005
|
+
class: "pcb-trace",
|
|
1006
|
+
stroke: copperColor,
|
|
1007
|
+
fill: "none",
|
|
1008
|
+
d: `M ${startPoint[0]} ${startPoint[1]} L ${endPoint[0]} ${endPoint[1]}`,
|
|
1009
|
+
"stroke-width": width,
|
|
1010
|
+
"stroke-linecap": "round",
|
|
1011
|
+
"stroke-linejoin": "round",
|
|
1012
|
+
"shape-rendering": "crispEdges",
|
|
1013
|
+
"data-layer": layer
|
|
1014
|
+
}
|
|
1015
|
+
};
|
|
1016
|
+
const maskObject = {
|
|
1017
|
+
name: "path",
|
|
1018
|
+
type: "element",
|
|
1019
|
+
value: "",
|
|
1020
|
+
children: [],
|
|
1021
|
+
attributes: {
|
|
1022
|
+
class: "pcb-soldermask",
|
|
1023
|
+
stroke: maskColor,
|
|
1024
|
+
fill: "none",
|
|
1025
|
+
d: `M ${startPoint[0]} ${startPoint[1]} L ${endPoint[0]} ${endPoint[1]}`,
|
|
1026
|
+
"stroke-width": width,
|
|
1027
|
+
"stroke-linecap": "round",
|
|
1028
|
+
"stroke-linejoin": "round",
|
|
1029
|
+
"shape-rendering": "crispEdges",
|
|
1030
|
+
"data-layer": layer
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
1033
|
+
svgObjects.push(maskObject, copperObject);
|
|
1034
|
+
} else {
|
|
1035
|
+
const maskOnlyObject = {
|
|
1036
|
+
name: "path",
|
|
1037
|
+
type: "element",
|
|
1038
|
+
value: "",
|
|
1039
|
+
children: [],
|
|
1040
|
+
attributes: {
|
|
1041
|
+
class: "pcb-trace",
|
|
1042
|
+
stroke: maskColor,
|
|
1043
|
+
fill: "none",
|
|
1044
|
+
d: `M ${startPoint[0]} ${startPoint[1]} L ${endPoint[0]} ${endPoint[1]}`,
|
|
1045
|
+
"stroke-width": width,
|
|
1046
|
+
"stroke-linecap": "round",
|
|
1047
|
+
"stroke-linejoin": "round",
|
|
1048
|
+
"shape-rendering": "crispEdges",
|
|
1049
|
+
"data-layer": layer
|
|
1050
|
+
}
|
|
1051
|
+
};
|
|
1052
|
+
svgObjects.push(maskOnlyObject);
|
|
1053
|
+
}
|
|
1014
1054
|
}
|
|
1015
1055
|
svgObjects.sort((a, b) => {
|
|
1016
1056
|
const layerA = a.attributes["data-layer"];
|
|
@@ -1743,7 +1783,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
1743
1783
|
var package_default = {
|
|
1744
1784
|
name: "circuit-to-svg",
|
|
1745
1785
|
type: "module",
|
|
1746
|
-
version: "0.0.
|
|
1786
|
+
version: "0.0.200",
|
|
1747
1787
|
description: "Convert Circuit JSON to SVG",
|
|
1748
1788
|
main: "dist/index.js",
|
|
1749
1789
|
files: [
|
|
@@ -1932,7 +1972,8 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
1932
1972
|
layer,
|
|
1933
1973
|
shouldDrawErrors: options?.shouldDrawErrors,
|
|
1934
1974
|
drawPaddingOutsideBoard,
|
|
1935
|
-
colorMap: colorMap2
|
|
1975
|
+
colorMap: colorMap2,
|
|
1976
|
+
renderSolderMask: options?.renderSolderMask
|
|
1936
1977
|
};
|
|
1937
1978
|
function getLayer(elm) {
|
|
1938
1979
|
if (elm.type === "pcb_smtpad") {
|