circuit-json-to-gerber 0.0.70 → 0.0.71

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.
@@ -1280,7 +1280,7 @@ var defineCommonMacros = (glayer) => {
1280
1280
  0 $4 = Circle center offset
1281
1281
  0 21 = Center Line(Exposure, Width, Height, Center X, Center Y, Rotation)*
1282
1282
  0 1 = Circle(Exposure, Diameter, Center X, Center Y, Rotation)*
1283
- 21,1,$1,$2,0.0,0.0,0.0*
1283
+ 21,1,$1-$3,$2,0.0,0.0,0.0*
1284
1284
  1,1,$3,0.0-$4,0.0*
1285
1285
  1,1,$3,$4,0.0*
1286
1286
  `.trim()
@@ -1294,7 +1294,7 @@ var defineCommonMacros = (glayer) => {
1294
1294
  0 $3 = Circle diameter (equal to width)*
1295
1295
  0 $4 = Circle center offset
1296
1296
  0 21 = Center Line(Exposure, Width, Height, Center X, Center Y, Rotation)*
1297
- 21,1,$1,$2,0.0,0.0,0.0*
1297
+ 21,1,$1,$2-$3,0.0,0.0,0.0*
1298
1298
  1,1,$3,0.0,0.0-$4*
1299
1299
  1,1,$3,0.0,$4*
1300
1300
  `.trim()
@@ -1468,27 +1468,15 @@ var getApertureConfigFromPcbSmtpad = (elm) => {
1468
1468
  y_size: elm.height
1469
1469
  };
1470
1470
  }
1471
- if (elm.shape === "pill") {
1471
+ if (elm.shape === "pill" || elm.shape === "rotated_pill") {
1472
1472
  if (!("width" in elm && "height" in elm)) {
1473
1473
  throw new Error(
1474
1474
  "Invalid pill shape in getApertureConfigFromPcbSmtpad: missing dimensions"
1475
1475
  );
1476
1476
  }
1477
- if (elm.width >= elm.height) {
1478
- return {
1479
- macro_name: "HORZPILL",
1480
- x_size: elm.width,
1481
- y_size: elm.height,
1482
- circle_diameter: Math.min(elm.width, elm.height),
1483
- circle_center_offset: elm.width / 2
1484
- };
1485
- }
1486
1477
  return {
1487
- macro_name: "VERTPILL",
1488
- x_size: elm.width,
1489
- y_size: elm.height,
1490
- circle_diameter: Math.min(elm.width, elm.height),
1491
- circle_center_offset: elm.height / 2
1478
+ standard_template_code: "C",
1479
+ diameter: Math.min(elm.width, elm.height)
1492
1480
  };
1493
1481
  }
1494
1482
  if (elm.shape === "polygon") {
@@ -1533,7 +1521,7 @@ var getApertureConfigFromPcbSmtpadSoldermask = (elm) => {
1533
1521
  y_size: elm.height + soldermaskMargin * 2
1534
1522
  };
1535
1523
  }
1536
- if (elm.shape === "pill") {
1524
+ if (elm.shape === "pill" || elm.shape === "rotated_pill") {
1537
1525
  if (!("width" in elm && "height" in elm)) {
1538
1526
  throw new Error(
1539
1527
  "Invalid pill shape in getApertureConfigFromPcbSmtpadSoldermask: missing dimensions"
@@ -1541,21 +1529,9 @@ var getApertureConfigFromPcbSmtpadSoldermask = (elm) => {
1541
1529
  }
1542
1530
  const width = elm.width + soldermaskMargin * 2;
1543
1531
  const height = elm.height + soldermaskMargin * 2;
1544
- if (width >= height) {
1545
- return {
1546
- macro_name: "HORZPILL",
1547
- x_size: width,
1548
- y_size: height,
1549
- circle_diameter: Math.min(width, height),
1550
- circle_center_offset: width / 2
1551
- };
1552
- }
1553
1532
  return {
1554
- macro_name: "VERTPILL",
1555
- x_size: width,
1556
- y_size: height,
1557
- circle_diameter: Math.min(width, height),
1558
- circle_center_offset: height / 2
1533
+ standard_template_code: "C",
1534
+ diameter: Math.min(width, height)
1559
1535
  };
1560
1536
  }
1561
1537
  if (elm.shape === "polygon") {
@@ -1625,7 +1601,7 @@ var getApertureConfigFromPcbSolderPaste = (elm) => {
1625
1601
  x_size: elm.width,
1626
1602
  y_size: elm.height,
1627
1603
  circle_diameter: Math.min(elm.width, elm.height),
1628
- circle_center_offset: elm.width / 2
1604
+ circle_center_offset: (elm.width - elm.height) / 2
1629
1605
  };
1630
1606
  }
1631
1607
  return {
@@ -1633,7 +1609,7 @@ var getApertureConfigFromPcbSolderPaste = (elm) => {
1633
1609
  x_size: elm.width,
1634
1610
  y_size: elm.height,
1635
1611
  circle_diameter: Math.min(elm.width, elm.height),
1636
- circle_center_offset: elm.height / 2
1612
+ circle_center_offset: (elm.height - elm.width) / 2
1637
1613
  };
1638
1614
  }
1639
1615
  throw new Error(`Unsupported shape ${elm.shape}`);
@@ -1662,7 +1638,7 @@ var getApertureConfigFromPcbPlatedHole = (elm) => {
1662
1638
  x_size: elm.outer_width,
1663
1639
  y_size: elm.outer_height,
1664
1640
  circle_diameter: Math.min(elm.outer_width, elm.outer_height),
1665
- circle_center_offset: elm.outer_width / 2
1641
+ circle_center_offset: (elm.outer_width - elm.outer_height) / 2
1666
1642
  };
1667
1643
  }
1668
1644
  return {
@@ -1670,7 +1646,7 @@ var getApertureConfigFromPcbPlatedHole = (elm) => {
1670
1646
  x_size: elm.outer_width,
1671
1647
  y_size: elm.outer_height,
1672
1648
  circle_diameter: Math.min(elm.outer_width, elm.outer_height),
1673
- circle_center_offset: elm.outer_height / 2
1649
+ circle_center_offset: (elm.outer_height - elm.outer_width) / 2
1674
1650
  };
1675
1651
  }
1676
1652
  const shape = elm.shape;
@@ -1720,7 +1696,7 @@ var getApertureConfigFromPcbPlatedHoleSoldermask = (elm) => {
1720
1696
  x_size: outerWidth,
1721
1697
  y_size: outerHeight,
1722
1698
  circle_diameter: Math.min(outerWidth, outerHeight),
1723
- circle_center_offset: outerWidth / 2
1699
+ circle_center_offset: (outerWidth - outerHeight) / 2
1724
1700
  };
1725
1701
  }
1726
1702
  return {
@@ -1728,7 +1704,7 @@ var getApertureConfigFromPcbPlatedHoleSoldermask = (elm) => {
1728
1704
  x_size: outerWidth,
1729
1705
  y_size: outerHeight,
1730
1706
  circle_diameter: Math.min(outerWidth, outerHeight),
1731
- circle_center_offset: outerHeight / 2
1707
+ circle_center_offset: (outerHeight - outerWidth) / 2
1732
1708
  };
1733
1709
  }
1734
1710
  const shape = elm.shape;
@@ -1916,7 +1892,7 @@ var findApertureNumber = (glayer, search_params) => {
1916
1892
  // package.json
1917
1893
  var package_default = {
1918
1894
  name: "circuit-json-to-gerber",
1919
- version: "0.0.68",
1895
+ version: "0.0.70",
1920
1896
  main: "dist/index.js",
1921
1897
  type: "module",
1922
1898
  scripts: {
@@ -2149,6 +2125,55 @@ var convertSoupToGerberCommands = (circuitJson, opts = {}) => {
2149
2125
  }).build()
2150
2126
  );
2151
2127
  const mfy = (y) => opts.flip_y_axis ? -y : y;
2128
+ const renderPillFlash = ({
2129
+ glayer,
2130
+ x,
2131
+ y,
2132
+ width,
2133
+ height,
2134
+ rotationDegrees = 0
2135
+ }) => {
2136
+ const circleApertureConfig = {
2137
+ standard_template_code: "C",
2138
+ diameter: Math.min(width, height)
2139
+ };
2140
+ const apertureNumber = findApertureNumber(glayer, circleApertureConfig);
2141
+ const gb = gerberBuilder().add("select_aperture", {
2142
+ aperture_number: apertureNumber
2143
+ });
2144
+ const offset = Math.abs(width - height) / 2;
2145
+ const rotationRadians = rotationDegrees * Math.PI / 180;
2146
+ const cosTheta = Math.cos(rotationRadians);
2147
+ const sinTheta = Math.sin(rotationRadians);
2148
+ const rotateAndTranslate = (dx, dy) => ({
2149
+ x: x + dx * cosTheta - dy * sinTheta,
2150
+ y: y + dx * sinTheta + dy * cosTheta
2151
+ });
2152
+ if (offset <= 1e-9) {
2153
+ gb.add("flash_operation", { x, y: mfy(y) });
2154
+ glayer.push(...gb.build());
2155
+ return;
2156
+ }
2157
+ const isHorizontal = width >= height;
2158
+ const startRelative = isHorizontal ? { x: -offset, y: 0 } : { x: 0, y: -offset };
2159
+ const endRelative = isHorizontal ? { x: offset, y: 0 } : { x: 0, y: offset };
2160
+ const startPoint = rotateAndTranslate(startRelative.x, startRelative.y);
2161
+ const endPoint = rotateAndTranslate(endRelative.x, endRelative.y);
2162
+ gb.add("flash_operation", {
2163
+ x: startPoint.x,
2164
+ y: mfy(startPoint.y)
2165
+ }).add("move_operation", {
2166
+ x: startPoint.x,
2167
+ y: mfy(startPoint.y)
2168
+ }).add("plot_operation", {
2169
+ x: endPoint.x,
2170
+ y: mfy(endPoint.y)
2171
+ }).add("flash_operation", {
2172
+ x: endPoint.x,
2173
+ y: mfy(endPoint.y)
2174
+ });
2175
+ glayer.push(...gb.build());
2176
+ };
2152
2177
  const getRegionApertureNumber = (glayer) => findApertureNumber(glayer, REGION_APERTURE_CONFIG);
2153
2178
  const addClosedRegionFromPoints = ({
2154
2179
  target,
@@ -2602,6 +2627,28 @@ var convertSoupToGerberCommands = (circuitJson, opts = {}) => {
2602
2627
  );
2603
2628
  } else if (element.type === "pcb_smtpad" && element.shape !== "polygon") {
2604
2629
  if (element.layer === layer && outerLayerRefs.includes(layer)) {
2630
+ if (element.shape === "pill" || element.shape === "rotated_pill") {
2631
+ const soldermaskMargin = typeof element.soldermask_margin === "number" ? element.soldermask_margin : 0;
2632
+ const rotation2 = element.shape === "rotated_pill" && typeof element.ccw_rotation === "number" ? element.ccw_rotation : 0;
2633
+ renderPillFlash({
2634
+ glayer: glayers[getGerberLayerName(layer, "copper")],
2635
+ x: element.x,
2636
+ y: element.y,
2637
+ width: element.width,
2638
+ height: element.height,
2639
+ rotationDegrees: rotation2
2640
+ });
2641
+ renderPillFlash({
2642
+ glayer: glayers[getGerberLayerName(layer, "soldermask")],
2643
+ x: element.x,
2644
+ y: element.y,
2645
+ width: element.width + soldermaskMargin * 2,
2646
+ height: element.height + soldermaskMargin * 2,
2647
+ rotationDegrees: rotation2
2648
+ });
2649
+ continue;
2650
+ }
2651
+ const rotation = element.shape === "rotated_rect" && typeof element.ccw_rotation === "number" ? element.ccw_rotation : 0;
2605
2652
  for (const { glayer, apertureConfig } of [
2606
2653
  {
2607
2654
  glayer: glayers[getGerberLayerName(layer, "copper")],
@@ -2616,13 +2663,13 @@ var convertSoupToGerberCommands = (circuitJson, opts = {}) => {
2616
2663
  const gb = gerberBuilder().add("select_aperture", {
2617
2664
  aperture_number: apertureNumber
2618
2665
  });
2619
- if (element.shape === "rotated_rect" && element.ccw_rotation) {
2666
+ if (rotation) {
2620
2667
  gb.add("load_rotation", {
2621
- rotation_degrees: element.ccw_rotation
2668
+ rotation_degrees: rotation
2622
2669
  });
2623
2670
  }
2624
2671
  gb.add("flash_operation", { x: element.x, y: mfy(element.y) });
2625
- if (element.shape === "rotated_rect" && element.ccw_rotation) {
2672
+ if (rotation) {
2626
2673
  gb.add("load_rotation", { rotation_degrees: 0 });
2627
2674
  }
2628
2675
  glayer.push(...gb.build());
@@ -3084,4 +3131,4 @@ export {
3084
3131
  stringifyGerberCommands,
3085
3132
  convertSoupToGerberCommands
3086
3133
  };
3087
- //# sourceMappingURL=chunk-ISNPG4RS.js.map
3134
+ //# sourceMappingURL=chunk-4OKFNZE6.js.map