circuit-json-to-lbrn 0.0.14 → 0.0.15

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 CHANGED
@@ -10,6 +10,7 @@ declare const convertCircuitJsonToLbrn: (circuitJson: CircuitJson, options?: {
10
10
  margin?: number;
11
11
  includeCopper?: boolean;
12
12
  includeSoldermask?: boolean;
13
+ soldermaskMargin?: number;
13
14
  }) => LightBurnProject;
14
15
 
15
16
  export { convertCircuitJsonToLbrn };
package/dist/index.js CHANGED
@@ -52,7 +52,8 @@ var addCirclePlatedHole = (platedHole, ctx) => {
52
52
  origin,
53
53
  includeCopper,
54
54
  includeSoldermask,
55
- connMap
55
+ connMap,
56
+ soldermaskMargin
56
57
  } = ctx;
57
58
  const centerX = platedHole.x + origin.x;
58
59
  const centerY = platedHole.y + origin.y;
@@ -76,8 +77,8 @@ var addCirclePlatedHole = (platedHole, ctx) => {
76
77
  }
77
78
  }
78
79
  if (platedHole.outer_diameter > 0 && includeSoldermask) {
79
- const outerRadius = platedHole.outer_diameter / 2;
80
- const outer = createCirclePath(centerX, centerY, outerRadius);
80
+ const smRadius = platedHole.outer_diameter / 2 + soldermaskMargin;
81
+ const outer = createCirclePath(centerX, centerY, smRadius);
81
82
  project.children.push(
82
83
  new ShapePath({
83
84
  cutIndex: soldermaskCutSetting.index,
@@ -140,7 +141,8 @@ var addOvalPlatedHole = (platedHole, ctx) => {
140
141
  throughBoardCutSetting,
141
142
  origin,
142
143
  includeCopper,
143
- includeSoldermask
144
+ includeSoldermask,
145
+ soldermaskMargin
144
146
  } = ctx;
145
147
  if (platedHole.outer_width <= 0 || platedHole.outer_height <= 0) {
146
148
  return;
@@ -166,13 +168,9 @@ var addOvalPlatedHole = (platedHole, ctx) => {
166
168
  );
167
169
  }
168
170
  if (platedHole.outer_width > 0 && platedHole.outer_height > 0 && includeSoldermask) {
169
- const outer = createOvalPath(
170
- centerX,
171
- centerY,
172
- platedHole.outer_width,
173
- platedHole.outer_height,
174
- rotation
175
- );
171
+ const smWidth = platedHole.outer_width + 2 * soldermaskMargin;
172
+ const smHeight = platedHole.outer_height + 2 * soldermaskMargin;
173
+ const outer = createOvalPath(centerX, centerY, smWidth, smHeight, rotation);
176
174
  project.children.push(
177
175
  new ShapePath2({
178
176
  cutIndex: soldermaskCutSetting.index,
@@ -294,7 +292,8 @@ var addCircularHoleWithRectPad = (platedHole, ctx) => {
294
292
  throughBoardCutSetting,
295
293
  origin,
296
294
  includeCopper,
297
- includeSoldermask
295
+ includeSoldermask,
296
+ soldermaskMargin
298
297
  } = ctx;
299
298
  const centerX = platedHole.x + origin.x;
300
299
  const centerY = platedHole.y + origin.y;
@@ -320,11 +319,20 @@ var addCircularHoleWithRectPad = (platedHole, ctx) => {
320
319
  );
321
320
  }
322
321
  if (includeSoldermask) {
322
+ const smPadWidth = padWidth + 2 * soldermaskMargin;
323
+ const smPadHeight = padHeight + 2 * soldermaskMargin;
324
+ const smPadPath = createRoundedRectPath(
325
+ centerX,
326
+ centerY,
327
+ smPadWidth,
328
+ smPadHeight,
329
+ borderRadius
330
+ );
323
331
  project.children.push(
324
332
  new ShapePath3({
325
333
  cutIndex: soldermaskCutSetting.index,
326
- verts: padPath.verts,
327
- prims: padPath.prims,
334
+ verts: smPadPath.verts,
335
+ prims: smPadPath.prims,
328
336
  isClosed: true
329
337
  })
330
338
  );
@@ -435,7 +443,8 @@ var addPillHoleWithRectPad = (platedHole, ctx) => {
435
443
  throughBoardCutSetting,
436
444
  origin,
437
445
  includeCopper,
438
- includeSoldermask
446
+ includeSoldermask,
447
+ soldermaskMargin
439
448
  } = ctx;
440
449
  const centerX = platedHole.x + origin.x;
441
450
  const centerY = platedHole.y + origin.y;
@@ -461,11 +470,20 @@ var addPillHoleWithRectPad = (platedHole, ctx) => {
461
470
  );
462
471
  }
463
472
  if (includeSoldermask) {
473
+ const smPadWidth = padWidth + 2 * soldermaskMargin;
474
+ const smPadHeight = padHeight + 2 * soldermaskMargin;
475
+ const smPadPath = createRoundedRectPath(
476
+ centerX,
477
+ centerY,
478
+ smPadWidth,
479
+ smPadHeight,
480
+ borderRadius
481
+ );
464
482
  project.children.push(
465
483
  new ShapePath4({
466
484
  cutIndex: soldermaskCutSetting.index,
467
- verts: padPath.verts,
468
- prims: padPath.prims,
485
+ verts: smPadPath.verts,
486
+ prims: smPadPath.prims,
469
487
  isClosed: true
470
488
  })
471
489
  );
@@ -503,7 +521,8 @@ var addRotatedPillHoleWithRectPad = (platedHole, ctx) => {
503
521
  throughBoardCutSetting,
504
522
  origin,
505
523
  includeCopper,
506
- includeSoldermask
524
+ includeSoldermask,
525
+ soldermaskMargin
507
526
  } = ctx;
508
527
  const centerX = platedHole.x + origin.x;
509
528
  const centerY = platedHole.y + origin.y;
@@ -532,11 +551,22 @@ var addRotatedPillHoleWithRectPad = (platedHole, ctx) => {
532
551
  );
533
552
  }
534
553
  if (includeSoldermask) {
554
+ const smPadWidth = padWidth + 2 * soldermaskMargin;
555
+ const smPadHeight = padHeight + 2 * soldermaskMargin;
556
+ const smPadPath = createRoundedRectPath(
557
+ centerX,
558
+ centerY,
559
+ smPadWidth,
560
+ smPadHeight,
561
+ borderRadius,
562
+ 4,
563
+ padRotation
564
+ );
535
565
  project.children.push(
536
566
  new ShapePath5({
537
567
  cutIndex: soldermaskCutSetting.index,
538
- verts: padPath.verts,
539
- prims: padPath.prims,
568
+ verts: smPadPath.verts,
569
+ prims: smPadPath.prims,
540
570
  isClosed: true
541
571
  })
542
572
  );
@@ -595,7 +625,8 @@ var addHoleWithPolygonPad = (platedHole, ctx) => {
595
625
  throughBoardCutSetting,
596
626
  origin,
597
627
  includeCopper,
598
- includeSoldermask
628
+ includeSoldermask,
629
+ soldermaskMargin
599
630
  } = ctx;
600
631
  if (platedHole.pad_outline.length >= 3) {
601
632
  const pad = createPolygonPathFromOutline(
@@ -664,7 +695,8 @@ var addPcbPlatedHolePill = (platedHole, ctx) => {
664
695
  throughBoardCutSetting,
665
696
  origin,
666
697
  includeCopper,
667
- includeSoldermask
698
+ includeSoldermask,
699
+ soldermaskMargin
668
700
  } = ctx;
669
701
  const centerX = platedHole.x + origin.x;
670
702
  const centerY = platedHole.y + origin.y;
@@ -687,13 +719,9 @@ var addPcbPlatedHolePill = (platedHole, ctx) => {
687
719
  );
688
720
  }
689
721
  if (platedHole.outer_width > 0 && platedHole.outer_height > 0 && includeSoldermask) {
690
- const outer = createPillPath(
691
- centerX,
692
- centerY,
693
- platedHole.outer_width,
694
- platedHole.outer_height,
695
- rotation
696
- );
722
+ const smWidth = platedHole.outer_width + 2 * soldermaskMargin;
723
+ const smHeight = platedHole.outer_height + 2 * soldermaskMargin;
724
+ const outer = createPillPath(centerX, centerY, smWidth, smHeight, rotation);
697
725
  project.children.push(
698
726
  new ShapePath7({
699
727
  cutIndex: soldermaskCutSetting.index,
@@ -757,7 +785,8 @@ var addRectSmtPad = (smtPad, ctx) => {
757
785
  netGeoms,
758
786
  origin,
759
787
  includeCopper,
760
- includeSoldermask
788
+ includeSoldermask,
789
+ soldermaskMargin
761
790
  } = ctx;
762
791
  const centerX = smtPad.x + origin.x;
763
792
  const centerY = smtPad.y + origin.y;
@@ -801,12 +830,14 @@ var addRectSmtPad = (smtPad, ctx) => {
801
830
  }
802
831
  }
803
832
  if (includeSoldermask) {
833
+ const smHalfWidth = halfWidth + soldermaskMargin;
834
+ const smHalfHeight = halfHeight + soldermaskMargin;
804
835
  const verts = [
805
- { x: centerX - halfWidth, y: centerY - halfHeight },
806
- { x: centerX + halfWidth, y: centerY - halfHeight },
807
- { x: centerX + halfWidth, y: centerY + halfHeight },
808
- { x: centerX - halfWidth, y: centerY + halfHeight },
809
- { x: centerX - halfWidth, y: centerY - halfHeight }
836
+ { x: centerX - smHalfWidth, y: centerY - smHalfHeight },
837
+ { x: centerX + smHalfWidth, y: centerY - smHalfHeight },
838
+ { x: centerX + smHalfWidth, y: centerY + smHalfHeight },
839
+ { x: centerX - smHalfWidth, y: centerY + smHalfHeight },
840
+ { x: centerX - smHalfWidth, y: centerY - smHalfHeight }
810
841
  // Close the path
811
842
  ];
812
843
  const prims = [
@@ -838,7 +869,8 @@ var addCircleSmtPad = (smtPad, ctx) => {
838
869
  origin,
839
870
  includeCopper,
840
871
  includeSoldermask,
841
- connMap
872
+ connMap,
873
+ soldermaskMargin
842
874
  } = ctx;
843
875
  const centerX = smtPad.x + origin.x;
844
876
  const centerY = smtPad.y + origin.y;
@@ -863,7 +895,8 @@ var addCircleSmtPad = (smtPad, ctx) => {
863
895
  }
864
896
  }
865
897
  if (includeSoldermask) {
866
- const outer = createCirclePath(centerX, centerY, outerRadius);
898
+ const smRadius = outerRadius + soldermaskMargin;
899
+ const outer = createCirclePath(centerX, centerY, smRadius);
867
900
  project.children.push(
868
901
  new ShapePath9({
869
902
  cutIndex: soldermaskCutSetting.index,
@@ -895,7 +928,8 @@ var addPillSmtPad = (smtPad, ctx) => {
895
928
  origin,
896
929
  includeCopper,
897
930
  includeSoldermask,
898
- connMap
931
+ connMap,
932
+ soldermaskMargin
899
933
  } = ctx;
900
934
  const centerX = smtPad.x + origin.x;
901
935
  const centerY = smtPad.y + origin.y;
@@ -918,11 +952,14 @@ var addPillSmtPad = (smtPad, ctx) => {
918
952
  }
919
953
  }
920
954
  if (includeSoldermask) {
955
+ const smWidth = smtPad.width + 2 * soldermaskMargin;
956
+ const smHeight = smtPad.height + 2 * soldermaskMargin;
957
+ const smOuter = createPillPath(centerX, centerY, smWidth, smHeight);
921
958
  project.children.push(
922
959
  new ShapePath10({
923
960
  cutIndex: soldermaskCutSetting.index,
924
- verts: outer.verts,
925
- prims: outer.prims,
961
+ verts: smOuter.verts,
962
+ prims: smOuter.prims,
926
963
  isClosed: true
927
964
  })
928
965
  );
@@ -940,7 +977,8 @@ var addRotatedPillSmtPad = (smtPad, ctx) => {
940
977
  origin,
941
978
  includeCopper,
942
979
  includeSoldermask,
943
- connMap
980
+ connMap,
981
+ soldermaskMargin
944
982
  } = ctx;
945
983
  const centerX = smtPad.x + origin.x;
946
984
  const centerY = smtPad.y + origin.y;
@@ -969,11 +1007,20 @@ var addRotatedPillSmtPad = (smtPad, ctx) => {
969
1007
  }
970
1008
  }
971
1009
  if (includeSoldermask) {
1010
+ const smWidth = smtPad.width + 2 * soldermaskMargin;
1011
+ const smHeight = smtPad.height + 2 * soldermaskMargin;
1012
+ const smOuter = createPillPath(
1013
+ centerX,
1014
+ centerY,
1015
+ smWidth,
1016
+ smHeight,
1017
+ (smtPad.ccw_rotation ?? 0) * (Math.PI / 180)
1018
+ );
972
1019
  project.children.push(
973
1020
  new ShapePath11({
974
1021
  cutIndex: soldermaskCutSetting.index,
975
- verts: outer.verts,
976
- prims: outer.prims,
1022
+ verts: smOuter.verts,
1023
+ prims: smOuter.prims,
977
1024
  isClosed: true
978
1025
  })
979
1026
  );
@@ -983,6 +1030,35 @@ var addRotatedPillSmtPad = (smtPad, ctx) => {
983
1030
 
984
1031
  // lib/element-handlers/addSmtPad/addPolygonSmtPad.ts
985
1032
  import { ShapePath as ShapePath12 } from "lbrnts";
1033
+
1034
+ // lib/polygon-to-shape-path.ts
1035
+ function polygonToShapePathData(polygon) {
1036
+ const verts = [];
1037
+ const prims = [];
1038
+ const svgString = polygon.svg();
1039
+ const dAttributeMatch = svgString.match(/\bd="([^"]+)"/);
1040
+ if (!dAttributeMatch || !dAttributeMatch[1]) {
1041
+ return { verts, prims };
1042
+ }
1043
+ const pathData = dAttributeMatch[1].trim();
1044
+ const commands = pathData.match(/[MLz][^MLz]*/g) || [];
1045
+ for (const command of commands) {
1046
+ const type = command[0];
1047
+ const coords = command.slice(1).trim();
1048
+ if (type === "M" || type === "L") {
1049
+ const parts = coords.split(",");
1050
+ const x = Number(parts[0]);
1051
+ const y = Number(parts[1]);
1052
+ if (!Number.isNaN(x) && !Number.isNaN(y)) {
1053
+ verts.push({ x, y });
1054
+ prims.push({ type: 0 });
1055
+ }
1056
+ }
1057
+ }
1058
+ return { verts, prims };
1059
+ }
1060
+
1061
+ // lib/element-handlers/addSmtPad/addPolygonSmtPad.ts
986
1062
  var addPolygonSmtPad = (smtPad, ctx) => {
987
1063
  const {
988
1064
  project,
@@ -991,7 +1067,8 @@ var addPolygonSmtPad = (smtPad, ctx) => {
991
1067
  origin,
992
1068
  includeCopper,
993
1069
  includeSoldermask,
994
- connMap
1070
+ connMap,
1071
+ soldermaskMargin
995
1072
  } = ctx;
996
1073
  if (smtPad.points.length >= 3) {
997
1074
  const pad = createPolygonPathFromOutline(smtPad.points, origin.x, origin.y);
@@ -1034,7 +1111,8 @@ var addRotatedRectSmtPad = (smtPad, ctx) => {
1034
1111
  origin,
1035
1112
  includeCopper,
1036
1113
  includeSoldermask,
1037
- connMap
1114
+ connMap,
1115
+ soldermaskMargin
1038
1116
  } = ctx;
1039
1117
  const centerX = smtPad.x + origin.x;
1040
1118
  const centerY = smtPad.y + origin.y;
@@ -1067,11 +1145,22 @@ var addRotatedRectSmtPad = (smtPad, ctx) => {
1067
1145
  }
1068
1146
  }
1069
1147
  if (includeSoldermask) {
1148
+ const smWidth = smtPad.width + 2 * soldermaskMargin;
1149
+ const smHeight = smtPad.height + 2 * soldermaskMargin;
1150
+ const smOuter = createRoundedRectPath(
1151
+ centerX,
1152
+ centerY,
1153
+ smWidth,
1154
+ smHeight,
1155
+ borderRadius,
1156
+ 4,
1157
+ rotation
1158
+ );
1070
1159
  project.children.push(
1071
1160
  new ShapePath13({
1072
1161
  cutIndex: soldermaskCutSetting.index,
1073
- verts: outer.verts,
1074
- prims: outer.prims,
1162
+ verts: smOuter.verts,
1163
+ prims: smOuter.prims,
1075
1164
  isClosed: true
1076
1165
  })
1077
1166
  );
@@ -1169,35 +1258,6 @@ var addPcbTrace = (trace, ctx) => {
1169
1258
  // lib/element-handlers/addPcbBoard/index.ts
1170
1259
  import { Polygon as Polygon3, point as point4 } from "@flatten-js/core";
1171
1260
  import { ShapePath as ShapePath14 } from "lbrnts";
1172
-
1173
- // lib/polygon-to-shape-path.ts
1174
- function polygonToShapePathData(polygon) {
1175
- const verts = [];
1176
- const prims = [];
1177
- const svgString = polygon.svg();
1178
- const dAttributeMatch = svgString.match(/\bd="([^"]+)"/);
1179
- if (!dAttributeMatch || !dAttributeMatch[1]) {
1180
- return { verts, prims };
1181
- }
1182
- const pathData = dAttributeMatch[1].trim();
1183
- const commands = pathData.match(/[MLz][^MLz]*/g) || [];
1184
- for (const command of commands) {
1185
- const type = command[0];
1186
- const coords = command.slice(1).trim();
1187
- if (type === "M" || type === "L") {
1188
- const parts = coords.split(",");
1189
- const x = Number(parts[0]);
1190
- const y = Number(parts[1]);
1191
- if (!Number.isNaN(x) && !Number.isNaN(y)) {
1192
- verts.push({ x, y });
1193
- prims.push({ type: 0 });
1194
- }
1195
- }
1196
- }
1197
- return { verts, prims };
1198
- }
1199
-
1200
- // lib/element-handlers/addPcbBoard/index.ts
1201
1261
  var addPcbBoard = (board, ctx) => {
1202
1262
  const {
1203
1263
  origin,
@@ -1365,7 +1425,8 @@ var convertCircuitJsonToLbrn = (circuitJson, options = {}) => {
1365
1425
  netGeoms: /* @__PURE__ */ new Map(),
1366
1426
  origin,
1367
1427
  includeCopper: options.includeCopper ?? true,
1368
- includeSoldermask: options.includeSoldermask ?? false
1428
+ includeSoldermask: options.includeSoldermask ?? false,
1429
+ soldermaskMargin: options.soldermaskMargin ?? 0
1369
1430
  };
1370
1431
  for (const net of Object.keys(connMap.netMap)) {
1371
1432
  ctx.netGeoms.set(net, []);
@@ -22,4 +22,7 @@ export interface ConvertContext {
22
22
  // Include flags
23
23
  includeCopper: boolean
24
24
  includeSoldermask: boolean
25
+
26
+ // Soldermask margin (can be negative)
27
+ soldermaskMargin: number
25
28
  }
@@ -18,6 +18,7 @@ export const addCirclePlatedHole = (
18
18
  includeCopper,
19
19
  includeSoldermask,
20
20
  connMap,
21
+ soldermaskMargin,
21
22
  } = ctx
22
23
  const centerX = platedHole.x + origin.x
23
24
  const centerY = platedHole.y + origin.y
@@ -48,8 +49,8 @@ export const addCirclePlatedHole = (
48
49
 
49
50
  // Add soldermask opening if drawing soldermask
50
51
  if (platedHole.outer_diameter > 0 && includeSoldermask) {
51
- const outerRadius = platedHole.outer_diameter / 2
52
- const outer = createCirclePath(centerX, centerY, outerRadius)
52
+ const smRadius = platedHole.outer_diameter / 2 + soldermaskMargin
53
+ const outer = createCirclePath(centerX, centerY, smRadius)
53
54
  project.children.push(
54
55
  new ShapePath({
55
56
  cutIndex: soldermaskCutSetting.index,
@@ -16,6 +16,7 @@ export const addCircularHoleWithRectPad = (
16
16
  origin,
17
17
  includeCopper,
18
18
  includeSoldermask,
19
+ soldermaskMargin,
19
20
  } = ctx
20
21
  const centerX = platedHole.x + origin.x
21
22
  const centerY = platedHole.y + origin.y
@@ -47,11 +48,21 @@ export const addCircularHoleWithRectPad = (
47
48
 
48
49
  // Add soldermask opening if drawing soldermask
49
50
  if (includeSoldermask) {
51
+ const smPadWidth = padWidth + 2 * soldermaskMargin
52
+ const smPadHeight = padHeight + 2 * soldermaskMargin
53
+ const smPadPath = createRoundedRectPath(
54
+ centerX,
55
+ centerY,
56
+ smPadWidth,
57
+ smPadHeight,
58
+ borderRadius,
59
+ )
60
+
50
61
  project.children.push(
51
62
  new ShapePath({
52
63
  cutIndex: soldermaskCutSetting.index,
53
- verts: padPath.verts,
54
- prims: padPath.prims,
64
+ verts: smPadPath.verts,
65
+ prims: smPadPath.prims,
55
66
  isClosed: true,
56
67
  }),
57
68
  )
@@ -16,6 +16,7 @@ export const addHoleWithPolygonPad = (
16
16
  origin,
17
17
  includeCopper,
18
18
  includeSoldermask,
19
+ soldermaskMargin,
19
20
  } = ctx
20
21
 
21
22
  // Create the polygon pad
@@ -40,6 +41,8 @@ export const addHoleWithPolygonPad = (
40
41
 
41
42
  // Add soldermask opening if drawing soldermask
42
43
  if (includeSoldermask) {
44
+ // TODO: For polygon pads with soldermask margin, we need to implement proper
45
+ // polygon offsetting. For now, we use the pad vertices directly.
43
46
  project.children.push(
44
47
  new ShapePath({
45
48
  cutIndex: soldermaskCutSetting.index,
@@ -15,6 +15,7 @@ export const addOvalPlatedHole = (
15
15
  origin,
16
16
  includeCopper,
17
17
  includeSoldermask,
18
+ soldermaskMargin,
18
19
  } = ctx
19
20
 
20
21
  if (platedHole.outer_width <= 0 || platedHole.outer_height <= 0) {
@@ -54,13 +55,9 @@ export const addOvalPlatedHole = (
54
55
  platedHole.outer_height > 0 &&
55
56
  includeSoldermask
56
57
  ) {
57
- const outer = createOvalPath(
58
- centerX,
59
- centerY,
60
- platedHole.outer_width,
61
- platedHole.outer_height,
62
- rotation,
63
- )
58
+ const smWidth = platedHole.outer_width + 2 * soldermaskMargin
59
+ const smHeight = platedHole.outer_height + 2 * soldermaskMargin
60
+ const outer = createOvalPath(centerX, centerY, smWidth, smHeight, rotation)
64
61
  project.children.push(
65
62
  new ShapePath({
66
63
  cutIndex: soldermaskCutSetting.index,
@@ -16,6 +16,7 @@ export const addPillHoleWithRectPad = (
16
16
  origin,
17
17
  includeCopper,
18
18
  includeSoldermask,
19
+ soldermaskMargin,
19
20
  } = ctx
20
21
  const centerX = platedHole.x + origin.x
21
22
  const centerY = platedHole.y + origin.y
@@ -47,11 +48,21 @@ export const addPillHoleWithRectPad = (
47
48
 
48
49
  // Add soldermask opening if drawing soldermask
49
50
  if (includeSoldermask) {
51
+ const smPadWidth = padWidth + 2 * soldermaskMargin
52
+ const smPadHeight = padHeight + 2 * soldermaskMargin
53
+ const smPadPath = createRoundedRectPath(
54
+ centerX,
55
+ centerY,
56
+ smPadWidth,
57
+ smPadHeight,
58
+ borderRadius,
59
+ )
60
+
50
61
  project.children.push(
51
62
  new ShapePath({
52
63
  cutIndex: soldermaskCutSetting.index,
53
- verts: padPath.verts,
54
- prims: padPath.prims,
64
+ verts: smPadPath.verts,
65
+ prims: smPadPath.prims,
55
66
  isClosed: true,
56
67
  }),
57
68
  )
@@ -15,6 +15,7 @@ export const addPcbPlatedHolePill = (
15
15
  origin,
16
16
  includeCopper,
17
17
  includeSoldermask,
18
+ soldermaskMargin,
18
19
  } = ctx
19
20
  const centerX = platedHole.x + origin.x
20
21
  const centerY = platedHole.y + origin.y
@@ -49,13 +50,9 @@ export const addPcbPlatedHolePill = (
49
50
  platedHole.outer_height > 0 &&
50
51
  includeSoldermask
51
52
  ) {
52
- const outer = createPillPath(
53
- centerX,
54
- centerY,
55
- platedHole.outer_width,
56
- platedHole.outer_height,
57
- rotation,
58
- )
53
+ const smWidth = platedHole.outer_width + 2 * soldermaskMargin
54
+ const smHeight = platedHole.outer_height + 2 * soldermaskMargin
55
+ const outer = createPillPath(centerX, centerY, smWidth, smHeight, rotation)
59
56
  project.children.push(
60
57
  new ShapePath({
61
58
  cutIndex: soldermaskCutSetting.index,
@@ -16,6 +16,7 @@ export const addRotatedPillHoleWithRectPad = (
16
16
  origin,
17
17
  includeCopper,
18
18
  includeSoldermask,
19
+ soldermaskMargin,
19
20
  } = ctx
20
21
  const centerX = platedHole.x + origin.x
21
22
  const centerY = platedHole.y + origin.y
@@ -50,11 +51,23 @@ export const addRotatedPillHoleWithRectPad = (
50
51
 
51
52
  // Add soldermask opening if drawing soldermask
52
53
  if (includeSoldermask) {
54
+ const smPadWidth = padWidth + 2 * soldermaskMargin
55
+ const smPadHeight = padHeight + 2 * soldermaskMargin
56
+ const smPadPath = createRoundedRectPath(
57
+ centerX,
58
+ centerY,
59
+ smPadWidth,
60
+ smPadHeight,
61
+ borderRadius,
62
+ 4,
63
+ padRotation,
64
+ )
65
+
53
66
  project.children.push(
54
67
  new ShapePath({
55
68
  cutIndex: soldermaskCutSetting.index,
56
- verts: padPath.verts,
57
- prims: padPath.prims,
69
+ verts: smPadPath.verts,
70
+ prims: smPadPath.prims,
58
71
  isClosed: true,
59
72
  }),
60
73
  )
@@ -17,6 +17,7 @@ export const addCircleSmtPad = (
17
17
  includeCopper,
18
18
  includeSoldermask,
19
19
  connMap,
20
+ soldermaskMargin,
20
21
  } = ctx
21
22
  const centerX = smtPad.x + origin.x
22
23
  const centerY = smtPad.y + origin.y
@@ -49,7 +50,8 @@ export const addCircleSmtPad = (
49
50
 
50
51
  // Add soldermask opening if drawing soldermask
51
52
  if (includeSoldermask) {
52
- const outer = createCirclePath(centerX, centerY, outerRadius)
53
+ const smRadius = outerRadius + soldermaskMargin
54
+ const outer = createCirclePath(centerX, centerY, smRadius)
53
55
  project.children.push(
54
56
  new ShapePath({
55
57
  cutIndex: soldermaskCutSetting.index,
@@ -16,6 +16,7 @@ export const addPillSmtPad = (
16
16
  includeCopper,
17
17
  includeSoldermask,
18
18
  connMap,
19
+ soldermaskMargin,
19
20
  } = ctx
20
21
  const centerX = smtPad.x + origin.x
21
22
  const centerY = smtPad.y + origin.y
@@ -46,11 +47,15 @@ export const addPillSmtPad = (
46
47
 
47
48
  // Add soldermask opening if drawing soldermask
48
49
  if (includeSoldermask) {
50
+ const smWidth = smtPad.width + 2 * soldermaskMargin
51
+ const smHeight = smtPad.height + 2 * soldermaskMargin
52
+ const smOuter = createPillPath(centerX, centerY, smWidth, smHeight)
53
+
49
54
  project.children.push(
50
55
  new ShapePath({
51
56
  cutIndex: soldermaskCutSetting.index,
52
- verts: outer.verts,
53
- prims: outer.prims,
57
+ verts: smOuter.verts,
58
+ prims: smOuter.prims,
54
59
  isClosed: true,
55
60
  }),
56
61
  )
@@ -3,6 +3,7 @@ import type { ConvertContext } from "../../ConvertContext"
3
3
  import { ShapePath } from "lbrnts"
4
4
  import { createPolygonPathFromOutline } from "../../helpers/polygonShape"
5
5
  import { pathToPolygon } from "../../helpers/pathToPolygon"
6
+ import { polygonToShapePathData } from "../../polygon-to-shape-path"
6
7
 
7
8
  export const addPolygonSmtPad = (
8
9
  smtPad: PcbSmtPadPolygon,
@@ -16,6 +17,7 @@ export const addPolygonSmtPad = (
16
17
  includeCopper,
17
18
  includeSoldermask,
18
19
  connMap,
20
+ soldermaskMargin,
19
21
  } = ctx
20
22
 
21
23
  // Create the polygon pad
@@ -45,6 +47,10 @@ export const addPolygonSmtPad = (
45
47
 
46
48
  // Add soldermask opening if drawing soldermask
47
49
  if (includeSoldermask) {
50
+ // TODO: For polygon pads with soldermask margin, we need to implement proper
51
+ // polygon offsetting. For now, we use the pad vertices directly.
52
+ // Consider using a polygon offsetting library like polygon-offset or
53
+ // implementing offset using @flatten-js/core buffer operations
48
54
  project.children.push(
49
55
  new ShapePath({
50
56
  cutIndex: soldermaskCutSetting.index,