circuit-to-svg 0.0.270 → 0.0.272
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 +81 -13
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2552,6 +2552,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
2552
2552
|
const isCoveredWithSolderMask = Boolean(pad?.is_covered_with_solder_mask);
|
|
2553
2553
|
const shouldshowSolderMask = showSolderMask && isCoveredWithSolderMask;
|
|
2554
2554
|
const solderMaskColor = colorMap2.soldermask[pad.layer] ?? colorMap2.soldermask.top;
|
|
2555
|
+
const soldermaskMargin = (pad.soldermask_margin ?? 0) * Math.abs(transform.a);
|
|
2555
2556
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
2556
2557
|
const width = pad.width * Math.abs(transform.a);
|
|
2557
2558
|
const height = pad.height * Math.abs(transform.d);
|
|
@@ -2583,6 +2584,9 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
2583
2584
|
if (!shouldshowSolderMask) {
|
|
2584
2585
|
return [padElement2];
|
|
2585
2586
|
}
|
|
2587
|
+
const maskWidth2 = width + 2 * soldermaskMargin;
|
|
2588
|
+
const maskHeight2 = height + 2 * soldermaskMargin;
|
|
2589
|
+
const maskBorderRadius2 = scaledBorderRadius ? scaledBorderRadius + soldermaskMargin : 0;
|
|
2586
2590
|
const maskElement2 = {
|
|
2587
2591
|
name: padElement2.name,
|
|
2588
2592
|
type: padElement2.type,
|
|
@@ -2592,7 +2596,15 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
2592
2596
|
...padElement2.attributes,
|
|
2593
2597
|
class: "pcb-solder-mask",
|
|
2594
2598
|
fill: solderMaskColor,
|
|
2595
|
-
"data-type": "pcb_soldermask"
|
|
2599
|
+
"data-type": "pcb_soldermask",
|
|
2600
|
+
x: (-maskWidth2 / 2).toString(),
|
|
2601
|
+
y: (-maskHeight2 / 2).toString(),
|
|
2602
|
+
width: maskWidth2.toString(),
|
|
2603
|
+
height: maskHeight2.toString(),
|
|
2604
|
+
...maskBorderRadius2 > 0 ? {
|
|
2605
|
+
rx: maskBorderRadius2.toString(),
|
|
2606
|
+
ry: maskBorderRadius2.toString()
|
|
2607
|
+
} : {}
|
|
2596
2608
|
}
|
|
2597
2609
|
};
|
|
2598
2610
|
return [padElement2, maskElement2];
|
|
@@ -2620,6 +2632,9 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
2620
2632
|
if (!shouldshowSolderMask) {
|
|
2621
2633
|
return [padElement];
|
|
2622
2634
|
}
|
|
2635
|
+
const maskWidth = width + 2 * soldermaskMargin;
|
|
2636
|
+
const maskHeight = height + 2 * soldermaskMargin;
|
|
2637
|
+
const maskBorderRadius = scaledBorderRadius ? scaledBorderRadius + soldermaskMargin : 0;
|
|
2623
2638
|
const maskElement = {
|
|
2624
2639
|
name: padElement.name,
|
|
2625
2640
|
type: padElement.type,
|
|
@@ -2629,7 +2644,15 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
2629
2644
|
...padElement.attributes,
|
|
2630
2645
|
class: "pcb-solder-mask",
|
|
2631
2646
|
fill: solderMaskColor,
|
|
2632
|
-
"data-type": "pcb_soldermask"
|
|
2647
|
+
"data-type": "pcb_soldermask",
|
|
2648
|
+
x: (x - maskWidth / 2).toString(),
|
|
2649
|
+
y: (y - maskHeight / 2).toString(),
|
|
2650
|
+
width: maskWidth.toString(),
|
|
2651
|
+
height: maskHeight.toString(),
|
|
2652
|
+
...maskBorderRadius > 0 ? {
|
|
2653
|
+
rx: maskBorderRadius.toString(),
|
|
2654
|
+
ry: maskBorderRadius.toString()
|
|
2655
|
+
} : {}
|
|
2633
2656
|
}
|
|
2634
2657
|
};
|
|
2635
2658
|
return [padElement, maskElement];
|
|
@@ -2660,6 +2683,9 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
2660
2683
|
if (!shouldshowSolderMask) {
|
|
2661
2684
|
return [padElement];
|
|
2662
2685
|
}
|
|
2686
|
+
const maskWidth = width + 2 * soldermaskMargin;
|
|
2687
|
+
const maskHeight = height + 2 * soldermaskMargin;
|
|
2688
|
+
const maskRadius = radius + soldermaskMargin;
|
|
2663
2689
|
const maskElement = {
|
|
2664
2690
|
name: padElement.name,
|
|
2665
2691
|
type: padElement.type,
|
|
@@ -2669,7 +2695,13 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
2669
2695
|
...padElement.attributes,
|
|
2670
2696
|
class: "pcb-solder-mask",
|
|
2671
2697
|
fill: solderMaskColor,
|
|
2672
|
-
"data-type": "pcb_soldermask"
|
|
2698
|
+
"data-type": "pcb_soldermask",
|
|
2699
|
+
x: (x - maskWidth / 2).toString(),
|
|
2700
|
+
y: (y - maskHeight / 2).toString(),
|
|
2701
|
+
width: maskWidth.toString(),
|
|
2702
|
+
height: maskHeight.toString(),
|
|
2703
|
+
rx: maskRadius.toString(),
|
|
2704
|
+
ry: maskRadius.toString()
|
|
2673
2705
|
}
|
|
2674
2706
|
};
|
|
2675
2707
|
return [padElement, maskElement];
|
|
@@ -2695,6 +2727,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
2695
2727
|
if (!shouldshowSolderMask) {
|
|
2696
2728
|
return [padElement];
|
|
2697
2729
|
}
|
|
2730
|
+
const maskRadius = radius + soldermaskMargin;
|
|
2698
2731
|
const maskElement = {
|
|
2699
2732
|
name: padElement.name,
|
|
2700
2733
|
type: padElement.type,
|
|
@@ -2704,7 +2737,8 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
2704
2737
|
...padElement.attributes,
|
|
2705
2738
|
class: "pcb-solder-mask",
|
|
2706
2739
|
fill: solderMaskColor,
|
|
2707
|
-
"data-type": "pcb_soldermask"
|
|
2740
|
+
"data-type": "pcb_soldermask",
|
|
2741
|
+
r: maskRadius.toString()
|
|
2708
2742
|
}
|
|
2709
2743
|
};
|
|
2710
2744
|
return [padElement, maskElement];
|
|
@@ -2729,6 +2763,23 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
2729
2763
|
if (!shouldshowSolderMask) {
|
|
2730
2764
|
return [padElement];
|
|
2731
2765
|
}
|
|
2766
|
+
let maskPoints = points;
|
|
2767
|
+
if (soldermaskMargin !== 0) {
|
|
2768
|
+
const centroidX = points.reduce((sum, p) => sum + p[0], 0) / points.length;
|
|
2769
|
+
const centroidY = points.reduce((sum, p) => sum + p[1], 0) / points.length;
|
|
2770
|
+
maskPoints = points.map(([px, py]) => {
|
|
2771
|
+
const dx = px - centroidX;
|
|
2772
|
+
const dy = py - centroidY;
|
|
2773
|
+
const distance3 = Math.sqrt(dx * dx + dy * dy);
|
|
2774
|
+
if (distance3 === 0) return [px, py];
|
|
2775
|
+
const normalizedDx = dx / distance3;
|
|
2776
|
+
const normalizedDy = dy / distance3;
|
|
2777
|
+
return [
|
|
2778
|
+
px + normalizedDx * soldermaskMargin,
|
|
2779
|
+
py + normalizedDy * soldermaskMargin
|
|
2780
|
+
];
|
|
2781
|
+
});
|
|
2782
|
+
}
|
|
2732
2783
|
const maskElement = {
|
|
2733
2784
|
name: padElement.name,
|
|
2734
2785
|
type: padElement.type,
|
|
@@ -2738,7 +2789,8 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
2738
2789
|
...padElement.attributes,
|
|
2739
2790
|
class: "pcb-solder-mask",
|
|
2740
2791
|
fill: solderMaskColor,
|
|
2741
|
-
"data-type": "pcb_soldermask"
|
|
2792
|
+
"data-type": "pcb_soldermask",
|
|
2793
|
+
points: maskPoints.map((p) => p.join(",")).join(" ")
|
|
2742
2794
|
}
|
|
2743
2795
|
};
|
|
2744
2796
|
return [padElement, maskElement];
|
|
@@ -2804,10 +2856,25 @@ function createSvgObjectsFromPcbPanel(pcbPanel, ctx) {
|
|
|
2804
2856
|
const { transform, colorMap: colorMap2, showSolderMask } = ctx;
|
|
2805
2857
|
const width = Number(pcbPanel.width);
|
|
2806
2858
|
const height = Number(pcbPanel.height);
|
|
2807
|
-
const
|
|
2808
|
-
const
|
|
2809
|
-
const
|
|
2810
|
-
const
|
|
2859
|
+
const center = pcbPanel.center ?? { x: width / 2, y: height / 2 };
|
|
2860
|
+
const halfWidth = width / 2;
|
|
2861
|
+
const halfHeight = height / 2;
|
|
2862
|
+
const topLeft = applyToPoint22(transform, [
|
|
2863
|
+
center.x - halfWidth,
|
|
2864
|
+
center.y - halfHeight
|
|
2865
|
+
]);
|
|
2866
|
+
const topRight = applyToPoint22(transform, [
|
|
2867
|
+
center.x + halfWidth,
|
|
2868
|
+
center.y - halfHeight
|
|
2869
|
+
]);
|
|
2870
|
+
const bottomRight = applyToPoint22(transform, [
|
|
2871
|
+
center.x + halfWidth,
|
|
2872
|
+
center.y + halfHeight
|
|
2873
|
+
]);
|
|
2874
|
+
const bottomLeft = applyToPoint22(transform, [
|
|
2875
|
+
center.x - halfWidth,
|
|
2876
|
+
center.y + halfHeight
|
|
2877
|
+
]);
|
|
2811
2878
|
const path = `M ${topLeft[0]} ${topLeft[1]} L ${topRight[0]} ${topRight[1]} L ${bottomRight[0]} ${bottomRight[1]} L ${bottomLeft[0]} ${bottomLeft[1]} Z`;
|
|
2812
2879
|
const isCoveredWithSolderMask = pcbPanel.covered_with_solder_mask !== false;
|
|
2813
2880
|
const shouldshowSolderMask = Boolean(
|
|
@@ -3963,7 +4030,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
3963
4030
|
var package_default = {
|
|
3964
4031
|
name: "circuit-to-svg",
|
|
3965
4032
|
type: "module",
|
|
3966
|
-
version: "0.0.
|
|
4033
|
+
version: "0.0.271",
|
|
3967
4034
|
description: "Convert Circuit JSON to SVG",
|
|
3968
4035
|
main: "dist/index.js",
|
|
3969
4036
|
files: [
|
|
@@ -3987,7 +4054,7 @@ var package_default = {
|
|
|
3987
4054
|
"bun-match-svg": "^0.0.12",
|
|
3988
4055
|
esbuild: "^0.20.2",
|
|
3989
4056
|
"performance-now": "^2.1.0",
|
|
3990
|
-
"circuit-json": "^0.0.
|
|
4057
|
+
"circuit-json": "^0.0.316",
|
|
3991
4058
|
react: "19.1.0",
|
|
3992
4059
|
"react-cosmos": "7.0.0",
|
|
3993
4060
|
"react-cosmos-plugin-vite": "7.0.0",
|
|
@@ -4184,7 +4251,7 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
4184
4251
|
if (width === void 0 || height === void 0) {
|
|
4185
4252
|
continue;
|
|
4186
4253
|
}
|
|
4187
|
-
const center = { x: width / 2, y: height / 2 };
|
|
4254
|
+
const center = panel.center ?? { x: width / 2, y: height / 2 };
|
|
4188
4255
|
updateBounds(center, width, height);
|
|
4189
4256
|
} else if (circuitJsonElm.type === "pcb_board") {
|
|
4190
4257
|
if (circuitJsonElm.outline && Array.isArray(circuitJsonElm.outline) && circuitJsonElm.outline.length >= 3) {
|
|
@@ -11291,7 +11358,8 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
|
|
|
11291
11358
|
const width = distance2.parse(panel.width);
|
|
11292
11359
|
const height = distance2.parse(panel.height);
|
|
11293
11360
|
if (width !== void 0 && height !== void 0) {
|
|
11294
|
-
|
|
11361
|
+
const center = panel.center ?? { x: width / 2, y: height / 2 };
|
|
11362
|
+
updateBounds(center, width, height);
|
|
11295
11363
|
}
|
|
11296
11364
|
} else if (item.type === "pcb_solder_paste" && "x" in item && "y" in item) {
|
|
11297
11365
|
updateBounds({ x: item.x, y: item.y }, 0, 0);
|