circuit-to-svg 0.0.271 → 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 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];
@@ -3978,7 +4030,7 @@ function getSoftwareUsedString(circuitJson) {
3978
4030
  var package_default = {
3979
4031
  name: "circuit-to-svg",
3980
4032
  type: "module",
3981
- version: "0.0.270",
4033
+ version: "0.0.271",
3982
4034
  description: "Convert Circuit JSON to SVG",
3983
4035
  main: "dist/index.js",
3984
4036
  files: [
@@ -4002,7 +4054,7 @@ var package_default = {
4002
4054
  "bun-match-svg": "^0.0.12",
4003
4055
  esbuild: "^0.20.2",
4004
4056
  "performance-now": "^2.1.0",
4005
- "circuit-json": "^0.0.315",
4057
+ "circuit-json": "^0.0.316",
4006
4058
  react: "19.1.0",
4007
4059
  "react-cosmos": "7.0.0",
4008
4060
  "react-cosmos-plugin-vite": "7.0.0",