@tscircuit/footprinter 0.0.344 → 0.0.346

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
@@ -411,29 +411,28 @@ var dip = (raw_params) => {
411
411
  });
412
412
  }
413
413
  const silkscreenRefText = silkscreenRef(0, sh / 2 + 0.5, 0.4);
414
- const roundToCourtyardGrid = (value) => Math.round(value / 0.01) * 0.01;
415
414
  const pinRowSpanX = parameters.w + parameters.od;
416
415
  const pinRowSpanY = padEdgeHeight;
417
- const courtyardStepOuterHalfX = roundToCourtyardGrid(pinRowSpanX / 2 + 0.25);
418
- const courtyardStepInnerHalfX = courtyardStepOuterHalfX;
419
- const courtyardStepOuterHalfY = roundToCourtyardGrid(pinRowSpanY / 2 + 0.72);
420
- const courtyardStepInnerHalfY = courtyardStepOuterHalfY;
416
+ const courtyardStepOuterHalfWidth = pinRowSpanX / 2 + 0.25;
417
+ const courtyardStepInnerHalfWidth = courtyardStepOuterHalfWidth;
418
+ const courtyardStepOuterHalfHeight = pinRowSpanY / 2 + 0.72;
419
+ const courtyardStepInnerHalfHeight = courtyardStepOuterHalfHeight;
421
420
  const courtyard = {
422
421
  type: "pcb_courtyard_outline",
423
422
  pcb_courtyard_outline_id: "",
424
423
  pcb_component_id: "",
425
424
  outline: createRectUnionOutline([
426
425
  {
427
- minX: -courtyardStepOuterHalfX,
428
- maxX: courtyardStepOuterHalfX,
429
- minY: -courtyardStepInnerHalfY,
430
- maxY: courtyardStepInnerHalfY
426
+ minX: -courtyardStepOuterHalfWidth,
427
+ maxX: courtyardStepOuterHalfWidth,
428
+ minY: -courtyardStepInnerHalfHeight,
429
+ maxY: courtyardStepInnerHalfHeight
431
430
  },
432
431
  {
433
- minX: -courtyardStepInnerHalfX,
434
- maxX: courtyardStepInnerHalfX,
435
- minY: -courtyardStepOuterHalfY,
436
- maxY: courtyardStepOuterHalfY
432
+ minX: -courtyardStepInnerHalfWidth,
433
+ maxX: courtyardStepInnerHalfWidth,
434
+ minY: -courtyardStepOuterHalfHeight,
435
+ maxY: courtyardStepOuterHalfHeight
437
436
  }
438
437
  ]),
439
438
  layer: "top"
@@ -1290,39 +1289,34 @@ var bga = (raw_params) => {
1290
1289
  route: markerRoute,
1291
1290
  stroke_width: 0.05
1292
1291
  };
1293
- const roundToCourtyardGrid = (value) => Math.round(value / 0.01) * 0.01;
1294
1292
  const padSpanX = (grid.x - 1) * p + pad2;
1295
1293
  const padSpanY = (grid.y - 1) * p + pad2;
1296
1294
  const bodySpanX = w ?? padSpanX;
1297
1295
  const bodySpanY = h ?? padSpanY;
1298
- const courtyardEnvelopeHalfX = Math.max(padSpanX / 2, bodySpanX / 2);
1299
- const courtyardEnvelopeHalfY = Math.max(padSpanY / 2, bodySpanY / 2);
1296
+ const courtyardEnvelopeHalfWidth = Math.max(padSpanX / 2, bodySpanX / 2);
1297
+ const courtyardEnvelopeHalfHeight = Math.max(padSpanY / 2, bodySpanY / 2);
1300
1298
  const courtyardClearanceX = 1.715;
1301
1299
  const courtyardClearanceY = 1.765;
1302
- const courtyardStepOuterHalfX = roundToCourtyardGrid(
1303
- courtyardEnvelopeHalfX + courtyardClearanceX
1304
- );
1305
- const courtyardStepInnerHalfX = courtyardStepOuterHalfX;
1306
- const courtyardStepOuterHalfY = roundToCourtyardGrid(
1307
- courtyardEnvelopeHalfY + courtyardClearanceY
1308
- );
1309
- const courtyardStepInnerHalfY = courtyardStepOuterHalfY;
1300
+ const courtyardStepOuterHalfWidth = courtyardEnvelopeHalfWidth + courtyardClearanceX;
1301
+ const courtyardStepInnerHalfWidth = courtyardStepOuterHalfWidth;
1302
+ const courtyardStepOuterHalfHeight = courtyardEnvelopeHalfHeight + courtyardClearanceY;
1303
+ const courtyardStepInnerHalfHeight = courtyardStepOuterHalfHeight;
1310
1304
  const courtyard = {
1311
1305
  type: "pcb_courtyard_outline",
1312
1306
  pcb_courtyard_outline_id: "",
1313
1307
  pcb_component_id: "",
1314
1308
  outline: createRectUnionOutline([
1315
1309
  {
1316
- minX: -courtyardStepOuterHalfX,
1317
- maxX: courtyardStepOuterHalfX,
1318
- minY: -courtyardStepInnerHalfY,
1319
- maxY: courtyardStepInnerHalfY
1310
+ minX: -courtyardStepOuterHalfWidth,
1311
+ maxX: courtyardStepOuterHalfWidth,
1312
+ minY: -courtyardStepInnerHalfHeight,
1313
+ maxY: courtyardStepInnerHalfHeight
1320
1314
  },
1321
1315
  {
1322
- minX: -courtyardStepInnerHalfX,
1323
- maxX: courtyardStepInnerHalfX,
1324
- minY: -courtyardStepOuterHalfY,
1325
- maxY: courtyardStepOuterHalfY
1316
+ minX: -courtyardStepInnerHalfWidth,
1317
+ maxX: courtyardStepInnerHalfWidth,
1318
+ minY: -courtyardStepOuterHalfHeight,
1319
+ maxY: courtyardStepOuterHalfHeight
1326
1320
  }
1327
1321
  ]),
1328
1322
  layer: "top"
@@ -1448,14 +1442,11 @@ var soicWithoutParsing = (parameters) => {
1448
1442
  { x: -sw / 2, y: -sh / 2 }
1449
1443
  ]
1450
1444
  };
1451
- const roundToCourtyardGrid = (value) => Math.round(value / 0.01) * 0.01;
1452
1445
  const pinRowSpanY = (parameters.num_pins / 2 - 1) * parameters.p + parameters.pw;
1453
- const courtyardStepInnerHalfX = roundToCourtyardGrid(parameters.w / 2 + 0.25);
1454
- const courtyardStepOuterHalfX = roundToCourtyardGrid(
1455
- courtyardStepInnerHalfX + 1.93
1456
- );
1457
- const courtyardStepInnerHalfY = roundToCourtyardGrid(pinRowSpanY / 2 + 0.27);
1458
- const courtyardStepOuterHalfY = roundToCourtyardGrid(pinRowSpanY / 2 + 0.63);
1446
+ const courtyardStepInnerHalfWidth = parameters.w / 2 + 0.25;
1447
+ const courtyardStepOuterHalfWidth = courtyardStepInnerHalfWidth + 1.93;
1448
+ const courtyardStepInnerHalfHeight = pinRowSpanY / 2 + 0.275;
1449
+ const courtyardStepOuterHalfHeight = pinRowSpanY / 2 + 0.635;
1459
1450
  const courtyard = {
1460
1451
  type: "pcb_courtyard_outline",
1461
1452
  pcb_courtyard_outline_id: "",
@@ -1463,16 +1454,16 @@ var soicWithoutParsing = (parameters) => {
1463
1454
  layer: "top",
1464
1455
  outline: createRectUnionOutline([
1465
1456
  {
1466
- minX: -courtyardStepOuterHalfX,
1467
- maxX: courtyardStepOuterHalfX,
1468
- minY: -courtyardStepInnerHalfY,
1469
- maxY: courtyardStepInnerHalfY
1457
+ minX: -courtyardStepOuterHalfWidth,
1458
+ maxX: courtyardStepOuterHalfWidth,
1459
+ minY: -courtyardStepInnerHalfHeight,
1460
+ maxY: courtyardStepInnerHalfHeight
1470
1461
  },
1471
1462
  {
1472
- minX: -courtyardStepInnerHalfX,
1473
- maxX: courtyardStepInnerHalfX,
1474
- minY: -courtyardStepOuterHalfY,
1475
- maxY: courtyardStepOuterHalfY
1463
+ minX: -courtyardStepInnerHalfWidth,
1464
+ maxX: courtyardStepInnerHalfWidth,
1465
+ minY: -courtyardStepOuterHalfHeight,
1466
+ maxY: courtyardStepOuterHalfHeight
1476
1467
  }
1477
1468
  ])
1478
1469
  };
@@ -1814,20 +1805,19 @@ var quad = (raw_params) => {
1814
1805
  parameters.h / 2 + (parameters.legsoutside ? parameters.pl * 1.2 : 0.5),
1815
1806
  0.3
1816
1807
  );
1817
- const roundToCourtyardGrid = (value) => Math.round(value / 0.01) * 0.01;
1818
1808
  const roundUpToCourtyardOuterGrid = (value) => Math.ceil(value / 0.05) * 0.05;
1819
1809
  const pinRowSpanX = (spc - 1) * parameters.p + parameters.pw;
1820
1810
  const pinRowSpanY = (spc - 1) * parameters.p + parameters.pw;
1821
- const courtyardStepInnerHalfX = roundToCourtyardGrid(pinRowSpanX / 2 + 0.25);
1822
- const courtyardStepInnerHalfY = roundToCourtyardGrid(pinRowSpanY / 2 + 0.25);
1823
- const courtyardStepOuterHalfX = roundToCourtyardGrid(parameters.w / 2 + 0.25);
1824
- const courtyardStepOuterHalfY = roundToCourtyardGrid(parameters.h / 2 + 0.25);
1825
- const courtyardOuterHalfX = Math.max(
1826
- courtyardStepOuterHalfX,
1811
+ const courtyardStepInnerHalfWidth = pinRowSpanX / 2 + 0.25;
1812
+ const courtyardStepInnerHalfHeight = pinRowSpanY / 2 + 0.25;
1813
+ const courtyardStepOuterHalfWidth = parameters.w / 2 + 0.25;
1814
+ const courtyardStepOuterHalfHeight = parameters.h / 2 + 0.25;
1815
+ const courtyardOuterHalfWidth = Math.max(
1816
+ courtyardStepOuterHalfWidth,
1827
1817
  roundUpToCourtyardOuterGrid(padOuterHalfX + 0.25)
1828
1818
  );
1829
- const courtyardOuterHalfY = Math.max(
1830
- courtyardStepOuterHalfY,
1819
+ const courtyardOuterHalfHeight = Math.max(
1820
+ courtyardStepOuterHalfHeight,
1831
1821
  roundUpToCourtyardOuterGrid(padOuterHalfY + 0.25)
1832
1822
  );
1833
1823
  const courtyard = {
@@ -1837,22 +1827,22 @@ var quad = (raw_params) => {
1837
1827
  layer: "top",
1838
1828
  outline: createRectUnionOutline([
1839
1829
  {
1840
- minX: -courtyardOuterHalfX,
1841
- maxX: courtyardOuterHalfX,
1842
- minY: -courtyardStepInnerHalfY,
1843
- maxY: courtyardStepInnerHalfY
1830
+ minX: -courtyardOuterHalfWidth,
1831
+ maxX: courtyardOuterHalfWidth,
1832
+ minY: -courtyardStepInnerHalfHeight,
1833
+ maxY: courtyardStepInnerHalfHeight
1844
1834
  },
1845
1835
  {
1846
- minX: -courtyardStepOuterHalfX,
1847
- maxX: courtyardStepOuterHalfX,
1848
- minY: -courtyardStepOuterHalfY,
1849
- maxY: courtyardStepOuterHalfY
1836
+ minX: -courtyardStepOuterHalfWidth,
1837
+ maxX: courtyardStepOuterHalfWidth,
1838
+ minY: -courtyardStepOuterHalfHeight,
1839
+ maxY: courtyardStepOuterHalfHeight
1850
1840
  },
1851
1841
  {
1852
- minX: -courtyardStepInnerHalfX,
1853
- maxX: courtyardStepInnerHalfX,
1854
- minY: -courtyardOuterHalfY,
1855
- maxY: courtyardOuterHalfY
1842
+ minX: -courtyardStepInnerHalfWidth,
1843
+ maxX: courtyardStepInnerHalfWidth,
1844
+ minY: -courtyardOuterHalfHeight,
1845
+ maxY: courtyardOuterHalfHeight
1856
1846
  }
1857
1847
  ])
1858
1848
  };
@@ -2079,30 +2069,29 @@ var ssop = (raw_params) => {
2079
2069
  { x: -sw / 2, y: -sh / 2 }
2080
2070
  ]
2081
2071
  };
2082
- const roundToCourtyardGrid = (value) => Math.round(value / 0.01) * 0.01;
2083
2072
  const pinRowSpanY = (parameters.num_pins / 2 - 1) * parameters.p + parameters.pw;
2084
2073
  const padToeHalfX = parameters.legsoutside ? parameters.w / 2 + parameters.pl : (parameters.w + 0.2) / 2 + parameters.pl / 2;
2085
2074
  const pinRowHalfY = pinRowSpanY / 2;
2086
- const courtyardStepOuterHalfX = roundToCourtyardGrid(padToeHalfX + 0.25);
2087
- const courtyardStepInnerHalfX = courtyardStepOuterHalfX;
2088
- const courtyardStepOuterHalfY = roundToCourtyardGrid(pinRowHalfY + 0.445);
2089
- const courtyardStepInnerHalfY = courtyardStepOuterHalfY;
2075
+ const courtyardStepOuterHalfWidth = padToeHalfX + 0.25;
2076
+ const courtyardStepInnerHalfWidth = courtyardStepOuterHalfWidth;
2077
+ const courtyardStepOuterHalfHeight = pinRowHalfY + 0.445;
2078
+ const courtyardStepInnerHalfHeight = courtyardStepOuterHalfHeight;
2090
2079
  const courtyard = {
2091
2080
  type: "pcb_courtyard_outline",
2092
2081
  pcb_courtyard_outline_id: "",
2093
2082
  pcb_component_id: "",
2094
2083
  outline: createRectUnionOutline([
2095
2084
  {
2096
- minX: -courtyardStepOuterHalfX,
2097
- maxX: courtyardStepOuterHalfX,
2098
- minY: -courtyardStepInnerHalfY,
2099
- maxY: courtyardStepInnerHalfY
2085
+ minX: -courtyardStepOuterHalfWidth,
2086
+ maxX: courtyardStepOuterHalfWidth,
2087
+ minY: -courtyardStepInnerHalfHeight,
2088
+ maxY: courtyardStepInnerHalfHeight
2100
2089
  },
2101
2090
  {
2102
- minX: -courtyardStepInnerHalfX,
2103
- maxX: courtyardStepInnerHalfX,
2104
- minY: -courtyardStepOuterHalfY,
2105
- maxY: courtyardStepOuterHalfY
2091
+ minX: -courtyardStepInnerHalfWidth,
2092
+ maxX: courtyardStepInnerHalfWidth,
2093
+ minY: -courtyardStepOuterHalfHeight,
2094
+ maxY: courtyardStepOuterHalfHeight
2106
2095
  }
2107
2096
  ]),
2108
2097
  layer: "top"
@@ -2183,15 +2172,12 @@ var tssop = (raw_params) => {
2183
2172
  { x: -sw / 2, y: -sh / 2 }
2184
2173
  ]
2185
2174
  };
2186
- const roundToCourtyardGrid = (value) => Math.round(value / 0.01) * 0.01;
2187
2175
  const pinRowSpanY = (parameters.num_pins / 2 - 1) * parameters.p + parameters.pw;
2188
2176
  const pinToeHalfSpanX = parameters.w / 2 + (parameters.legsoutside ? parameters.pl : 0);
2189
- const courtyardStepInnerHalfX = roundToCourtyardGrid(parameters.w / 2 + 0.25);
2190
- const courtyardStepOuterHalfX = roundToCourtyardGrid(pinToeHalfSpanX + 0.18);
2191
- const courtyardStepInnerHalfY = roundToCourtyardGrid(pinRowSpanY / 2 + 0.25);
2192
- const courtyardStepOuterHalfY = roundToCourtyardGrid(
2193
- courtyardStepInnerHalfY + 0.35
2194
- );
2177
+ const courtyardStepInnerHalfWidth = parameters.w / 2 + 0.25;
2178
+ const courtyardStepOuterHalfWidth = pinToeHalfSpanX + 0.18;
2179
+ const courtyardStepInnerHalfHeight = pinRowSpanY / 2 + 0.25;
2180
+ const courtyardStepOuterHalfHeight = courtyardStepInnerHalfHeight + 0.35;
2195
2181
  const courtyard = {
2196
2182
  type: "pcb_courtyard_outline",
2197
2183
  pcb_courtyard_outline_id: "",
@@ -2199,16 +2185,16 @@ var tssop = (raw_params) => {
2199
2185
  layer: "top",
2200
2186
  outline: createRectUnionOutline([
2201
2187
  {
2202
- minX: -courtyardStepOuterHalfX,
2203
- maxX: courtyardStepOuterHalfX,
2204
- minY: -courtyardStepInnerHalfY,
2205
- maxY: courtyardStepInnerHalfY
2188
+ minX: -courtyardStepOuterHalfWidth,
2189
+ maxX: courtyardStepOuterHalfWidth,
2190
+ minY: -courtyardStepInnerHalfHeight,
2191
+ maxY: courtyardStepInnerHalfHeight
2206
2192
  },
2207
2193
  {
2208
- minX: -courtyardStepInnerHalfX,
2209
- maxX: courtyardStepInnerHalfX,
2210
- minY: -courtyardStepOuterHalfY,
2211
- maxY: courtyardStepOuterHalfY
2194
+ minX: -courtyardStepInnerHalfWidth,
2195
+ maxX: courtyardStepInnerHalfWidth,
2196
+ minY: -courtyardStepOuterHalfHeight,
2197
+ maxY: courtyardStepOuterHalfHeight
2212
2198
  }
2213
2199
  ])
2214
2200
  };
@@ -3139,17 +3125,29 @@ var pinrow = (raw_params) => {
3139
3125
  }
3140
3126
  }
3141
3127
  const refText = silkscreenRef(0, p, 0.5);
3142
- const halfSpanX = (numPinsPerRow - 1) / 2 * p;
3143
- const padHalfX = parameters.smd ? parameters.pw / 2 : od / 2;
3144
- const padHalfY = parameters.smd ? parameters.pl / 2 : od / 2;
3145
- const courtyardPadding = 0.25;
3128
+ const padHalfWidth = parameters.smd ? parameters.pw / 2 : od / 2;
3129
+ const padHalfHeight = parameters.smd ? parameters.pl / 2 : od / 2;
3130
+ const pinRowSpanX = (numPinsPerRow - 1) * p;
3131
+ const pinRowSpanY = (rows - 1) * p;
3132
+ const padOuterHalfWidth = pinRowSpanX / 2 + padHalfWidth;
3133
+ const padOuterHalfHeight = pinRowSpanY / 2 + padHalfHeight;
3134
+ const bodyHalfWidth = pinRowSpanX / 2 + p / 2;
3135
+ const bodyHalfHeight = pinRowSpanY / 2 + p / 2;
3136
+ const courtyardHalfWidth = Math.max(
3137
+ padOuterHalfWidth + 0.25,
3138
+ bodyHalfWidth + 0.5
3139
+ );
3140
+ const courtyardHalfHeight = Math.max(
3141
+ padOuterHalfHeight + 0.25,
3142
+ bodyHalfHeight + 0.5
3143
+ );
3146
3144
  const courtyard = {
3147
3145
  type: "pcb_courtyard_rect",
3148
3146
  pcb_courtyard_rect_id: "",
3149
3147
  pcb_component_id: "",
3150
3148
  center: { x: 0, y: -((rows - 1) * p) / 2 },
3151
- width: 2 * (halfSpanX + padHalfX + courtyardPadding),
3152
- height: (rows - 1) * p + 2 * (padHalfY + courtyardPadding),
3149
+ width: 2 * courtyardHalfWidth,
3150
+ height: 2 * courtyardHalfHeight,
3153
3151
  layer: "top"
3154
3152
  };
3155
3153
  return {
@@ -3460,21 +3458,16 @@ var axial = (raw_params) => {
3460
3458
  pcb_silkscreen_path_id: ""
3461
3459
  };
3462
3460
  const silkscreenRefText = silkscreenRef(0, 1.5, 0.5);
3463
- const roundToCourtyardGrid = (value) => Math.round(value / 0.01) * 0.01;
3464
3461
  const pin1CenterX = -p / 2;
3465
3462
  const pin2CenterX = p / 2;
3466
3463
  const pinPadHalfX = od / 2;
3467
3464
  const pinPadHalfY = od / 2;
3468
- const courtyardStepOuterMinX = roundToCourtyardGrid(
3469
- pin1CenterX - pinPadHalfX - 0.35
3470
- );
3471
- const courtyardStepOuterMaxX = roundToCourtyardGrid(
3472
- pin2CenterX + pinPadHalfX + 0.26
3473
- );
3474
- const courtyardStepOuterHalfY = roundToCourtyardGrid(pinPadHalfY + 0.35);
3465
+ const courtyardStepOuterMinX = pin1CenterX - pinPadHalfX - 0.35;
3466
+ const courtyardStepOuterMaxX = pin2CenterX + pinPadHalfX + 0.26;
3467
+ const courtyardStepOuterHalfHeight = pinPadHalfY + 0.35;
3475
3468
  const courtyardStepInnerMinX = courtyardStepOuterMinX;
3476
3469
  const courtyardStepInnerMaxX = courtyardStepOuterMaxX;
3477
- const courtyardStepInnerHalfY = courtyardStepOuterHalfY;
3470
+ const courtyardStepInnerHalfHeight = courtyardStepOuterHalfHeight;
3478
3471
  const courtyard = {
3479
3472
  type: "pcb_courtyard_outline",
3480
3473
  pcb_courtyard_outline_id: "",
@@ -3483,14 +3476,14 @@ var axial = (raw_params) => {
3483
3476
  {
3484
3477
  minX: courtyardStepOuterMinX,
3485
3478
  maxX: courtyardStepOuterMaxX,
3486
- minY: -courtyardStepInnerHalfY,
3487
- maxY: courtyardStepInnerHalfY
3479
+ minY: -courtyardStepInnerHalfHeight,
3480
+ maxY: courtyardStepInnerHalfHeight
3488
3481
  },
3489
3482
  {
3490
3483
  minX: courtyardStepInnerMinX,
3491
3484
  maxX: courtyardStepInnerMaxX,
3492
- minY: -courtyardStepOuterHalfY,
3493
- maxY: courtyardStepOuterHalfY
3485
+ minY: -courtyardStepOuterHalfHeight,
3486
+ maxY: courtyardStepOuterHalfHeight
3494
3487
  }
3495
3488
  ]),
3496
3489
  layer: "top"
@@ -3716,15 +3709,20 @@ var pushbutton = (raw_params) => {
3716
3709
  height / 2 + 0.4,
3717
3710
  0.5
3718
3711
  );
3719
- const outerRadius = holeDiameter * 1.5 / 2;
3720
- const courtyardPadding = 0.25;
3712
+ const padOuterRadius = holeDiameter * 1.5 / 2;
3713
+ const pinRowSpanX = width;
3714
+ const pinRowSpanY = height;
3715
+ const padOuterHalfWidth = pinRowSpanX / 2 + padOuterRadius;
3716
+ const padOuterHalfHeight = pinRowSpanY / 2 + padOuterRadius;
3717
+ const courtyardHalfWidth = padOuterHalfWidth + 0.5;
3718
+ const courtyardHalfHeight = padOuterHalfHeight + 0.5;
3721
3719
  const courtyard = {
3722
3720
  type: "pcb_courtyard_rect",
3723
3721
  pcb_courtyard_rect_id: "",
3724
3722
  pcb_component_id: "",
3725
3723
  center: { x: 0, y: 0 },
3726
- width: width + 2 * outerRadius + 2 * courtyardPadding,
3727
- height: height + 2 * outerRadius + 2 * courtyardPadding,
3724
+ width: 2 * courtyardHalfWidth,
3725
+ height: 2 * courtyardHalfHeight,
3728
3726
  layer: "top"
3729
3727
  };
3730
3728
  return {
@@ -4685,6 +4683,79 @@ import {
4685
4683
  length as length25
4686
4684
  } from "circuit-json";
4687
4685
  import { z as z33 } from "zod";
4686
+
4687
+ // src/helpers/capsule-outline.ts
4688
+ var createCapsuleOutline = (options) => {
4689
+ const {
4690
+ centerX,
4691
+ centerY,
4692
+ straightHalfLength,
4693
+ radius,
4694
+ arcSegmentCount = 9,
4695
+ orientation = "horizontal"
4696
+ } = options;
4697
+ if (straightHalfLength < 0) {
4698
+ throw new Error("Capsule straightHalfLength must be non-negative");
4699
+ }
4700
+ if (radius <= 0) {
4701
+ throw new Error("Capsule radius must be positive");
4702
+ }
4703
+ if (arcSegmentCount < 2) {
4704
+ throw new Error("Capsule arcSegmentCount must be at least 2");
4705
+ }
4706
+ if (orientation === "horizontal") {
4707
+ const leftCenterX = centerX - straightHalfLength;
4708
+ const rightCenterX = centerX + straightHalfLength;
4709
+ const rightArc = Array.from({ length: arcSegmentCount + 1 }, (_, i) => {
4710
+ const theta = Math.PI / 2 - i * Math.PI / arcSegmentCount;
4711
+ return {
4712
+ x: rightCenterX + Math.cos(theta) * radius,
4713
+ y: centerY + Math.sin(theta) * radius
4714
+ };
4715
+ });
4716
+ const leftArc = Array.from({ length: arcSegmentCount + 1 }, (_, i) => {
4717
+ const theta = -Math.PI / 2 + i * Math.PI / arcSegmentCount;
4718
+ return {
4719
+ x: leftCenterX - Math.cos(theta) * radius,
4720
+ y: centerY + Math.sin(theta) * radius
4721
+ };
4722
+ });
4723
+ return [
4724
+ { x: leftCenterX, y: centerY + radius },
4725
+ { x: rightCenterX, y: centerY + radius },
4726
+ ...rightArc.slice(1, -1),
4727
+ { x: rightCenterX, y: centerY - radius },
4728
+ { x: leftCenterX, y: centerY - radius },
4729
+ ...leftArc.slice(1, -1)
4730
+ ];
4731
+ }
4732
+ const bottomCenterY = centerY - straightHalfLength;
4733
+ const topCenterY = centerY + straightHalfLength;
4734
+ const topArc = Array.from({ length: arcSegmentCount + 1 }, (_, i) => {
4735
+ const theta = Math.PI - i * Math.PI / arcSegmentCount;
4736
+ return {
4737
+ x: centerX + Math.cos(theta) * radius,
4738
+ y: topCenterY + Math.sin(theta) * radius
4739
+ };
4740
+ });
4741
+ const bottomArc = Array.from({ length: arcSegmentCount + 1 }, (_, i) => {
4742
+ const theta = i * Math.PI / arcSegmentCount;
4743
+ return {
4744
+ x: centerX + Math.cos(theta) * radius,
4745
+ y: bottomCenterY - Math.sin(theta) * radius
4746
+ };
4747
+ });
4748
+ return [
4749
+ { x: centerX - radius, y: bottomCenterY },
4750
+ { x: centerX - radius, y: topCenterY },
4751
+ ...topArc.slice(1, -1),
4752
+ { x: centerX + radius, y: topCenterY },
4753
+ { x: centerX + radius, y: bottomCenterY },
4754
+ ...bottomArc.slice(1, -1)
4755
+ ];
4756
+ };
4757
+
4758
+ // src/fn/hc49.ts
4688
4759
  var generate_u_curve = (centerX, centerY, radius, direction) => {
4689
4760
  return Array.from({ length: 25 }, (_, i) => {
4690
4761
  const theta = i / 24 * Math.PI - Math.PI / 2;
@@ -4729,18 +4800,20 @@ var hc49 = (raw_params) => {
4729
4800
  pcb_silkscreen_path_id: ""
4730
4801
  };
4731
4802
  const silkscreenRefText = silkscreenRef(0, p / 4, 0.5);
4732
- const courtyardPadding = 0.25;
4733
- const crtMinX = -(w / 2 + radius + courtyardPadding);
4734
- const crtMaxX = w / 2 + radius + courtyardPadding;
4735
- const crtMinY = -(radius + courtyardPadding);
4736
- const crtMaxY = radius + courtyardPadding;
4803
+ const padRowHalfWidth = p / 2 + od / 2;
4804
+ const courtyardCapsuleStraightHalfLength = padRowHalfWidth;
4805
+ const courtyardCapsuleRadius = Math.max(h / 2 + 0.25, w / 2 + 0.03);
4737
4806
  const courtyard = {
4738
- type: "pcb_courtyard_rect",
4739
- pcb_courtyard_rect_id: "",
4807
+ type: "pcb_courtyard_outline",
4808
+ pcb_courtyard_outline_id: "",
4740
4809
  pcb_component_id: "",
4741
- center: { x: (crtMinX + crtMaxX) / 2, y: (crtMinY + crtMaxY) / 2 },
4742
- width: crtMaxX - crtMinX,
4743
- height: crtMaxY - crtMinY,
4810
+ outline: createCapsuleOutline({
4811
+ centerX: 0,
4812
+ centerY: 0,
4813
+ straightHalfLength: courtyardCapsuleStraightHalfLength,
4814
+ radius: courtyardCapsuleRadius,
4815
+ arcSegmentCount: 9
4816
+ }),
4744
4817
  layer: "top"
4745
4818
  };
4746
4819
  return {
@@ -5060,12 +5133,11 @@ var sop8 = (raw_params) => {
5060
5133
  ],
5061
5134
  stroke_width: 0.1
5062
5135
  };
5063
- const roundToCourtyardGrid = (value) => Math.round(value / 0.01) * 0.01;
5064
5136
  const pinRowSpanY = (parameters.num_pins / 2 - 1) * parameters.p + parameters.pw;
5065
- const courtyardStepInnerHalfX = roundToCourtyardGrid(parameters.w / 2 - 1.395);
5066
- const courtyardStepOuterHalfX = roundToCourtyardGrid(parameters.w / 2 + 0.255);
5067
- const courtyardStepInnerHalfY = roundToCourtyardGrid(pinRowSpanY / 2 + 0.25);
5068
- const courtyardStepOuterHalfY = roundToCourtyardGrid(pinRowSpanY / 2 + 0.5);
5137
+ const courtyardStepInnerHalfWidth = parameters.w / 2 - 1.395;
5138
+ const courtyardStepOuterHalfWidth = parameters.w / 2 + 0.255;
5139
+ const courtyardStepInnerHalfHeight = pinRowSpanY / 2 + 0.25;
5140
+ const courtyardStepOuterHalfHeight = pinRowSpanY / 2 + 0.5;
5069
5141
  const courtyard = {
5070
5142
  type: "pcb_courtyard_outline",
5071
5143
  pcb_courtyard_outline_id: "",
@@ -5073,16 +5145,16 @@ var sop8 = (raw_params) => {
5073
5145
  layer: "top",
5074
5146
  outline: createRectUnionOutline([
5075
5147
  {
5076
- minX: -courtyardStepOuterHalfX,
5077
- maxX: courtyardStepOuterHalfX,
5078
- minY: -courtyardStepInnerHalfY,
5079
- maxY: courtyardStepInnerHalfY
5148
+ minX: -courtyardStepOuterHalfWidth,
5149
+ maxX: courtyardStepOuterHalfWidth,
5150
+ minY: -courtyardStepInnerHalfHeight,
5151
+ maxY: courtyardStepInnerHalfHeight
5080
5152
  },
5081
5153
  {
5082
- minX: -courtyardStepInnerHalfX,
5083
- maxX: courtyardStepInnerHalfX,
5084
- minY: -courtyardStepOuterHalfY,
5085
- maxY: courtyardStepOuterHalfY
5154
+ minX: -courtyardStepInnerHalfWidth,
5155
+ maxX: courtyardStepInnerHalfWidth,
5156
+ minY: -courtyardStepOuterHalfHeight,
5157
+ maxY: courtyardStepOuterHalfHeight
5086
5158
  }
5087
5159
  ])
5088
5160
  };
@@ -5412,43 +5484,36 @@ var sod923 = (raw_params) => {
5412
5484
  stroke_width: 0.1,
5413
5485
  pcb_silkscreen_path_id: ""
5414
5486
  };
5415
- const roundToCourtyardGrid = (value) => Math.round(value / 0.01) * 0.01;
5416
5487
  const pinRowSpanX = p + pl;
5417
5488
  const pinRowSpanY = pw;
5418
5489
  const bodyHalfX = w / 2;
5419
5490
  const bodyHalfY = h / 2;
5420
5491
  const pinToeHalfX = pinRowSpanX / 2;
5421
5492
  const pinRowHalfY = pinRowSpanY / 2;
5422
- const courtyardEnvelopeHalfX = Math.max(bodyHalfX, pinToeHalfX);
5423
- const courtyardEnvelopeHalfY = Math.max(bodyHalfY, pinRowHalfY);
5424
- const courtyardNarrowHalfX = Math.min(bodyHalfX, pinToeHalfX);
5425
- const courtyardNarrowHalfY = Math.min(bodyHalfY, pinRowHalfY);
5426
- const courtyardStepOuterHalfX = roundToCourtyardGrid(
5427
- courtyardEnvelopeHalfX + 0.05
5428
- );
5429
- const courtyardStepInnerHalfX = roundToCourtyardGrid(
5430
- courtyardNarrowHalfX - 0.055
5431
- );
5432
- const courtyardStepOuterHalfY = roundToCourtyardGrid(courtyardEnvelopeHalfY);
5433
- const courtyardStepInnerHalfY = roundToCourtyardGrid(
5434
- courtyardNarrowHalfY + 0.155
5435
- );
5493
+ const courtyardEnvelopeHalfWidth = Math.max(bodyHalfX, pinToeHalfX);
5494
+ const courtyardEnvelopeHalfHeight = Math.max(bodyHalfY, pinRowHalfY);
5495
+ const courtyardNarrowHalfWidth = Math.min(bodyHalfX, pinToeHalfX);
5496
+ const courtyardNarrowHalfHeight = Math.min(bodyHalfY, pinRowHalfY);
5497
+ const courtyardStepOuterHalfWidth = courtyardEnvelopeHalfWidth + 0.05;
5498
+ const courtyardStepInnerHalfWidth = courtyardNarrowHalfWidth - 0.055;
5499
+ const courtyardStepOuterHalfHeight = courtyardEnvelopeHalfHeight;
5500
+ const courtyardStepInnerHalfHeight = courtyardNarrowHalfHeight + 0.155;
5436
5501
  const courtyard = {
5437
5502
  type: "pcb_courtyard_outline",
5438
5503
  pcb_courtyard_outline_id: "",
5439
5504
  pcb_component_id: "",
5440
5505
  outline: createRectUnionOutline([
5441
5506
  {
5442
- minX: -courtyardStepOuterHalfX,
5443
- maxX: courtyardStepOuterHalfX,
5444
- minY: -courtyardStepInnerHalfY,
5445
- maxY: courtyardStepInnerHalfY
5507
+ minX: -courtyardStepOuterHalfWidth,
5508
+ maxX: courtyardStepOuterHalfWidth,
5509
+ minY: -courtyardStepInnerHalfHeight,
5510
+ maxY: courtyardStepInnerHalfHeight
5446
5511
  },
5447
5512
  {
5448
- minX: -courtyardStepInnerHalfX,
5449
- maxX: courtyardStepInnerHalfX,
5450
- minY: -courtyardStepOuterHalfY,
5451
- maxY: courtyardStepOuterHalfY
5513
+ minX: -courtyardStepInnerHalfWidth,
5514
+ maxX: courtyardStepInnerHalfWidth,
5515
+ minY: -courtyardStepOuterHalfHeight,
5516
+ maxY: courtyardStepOuterHalfHeight
5452
5517
  }
5453
5518
  ]),
5454
5519
  layer: "top"
@@ -6279,11 +6344,19 @@ var to220 = (raw_params) => {
6279
6344
  }
6280
6345
  ];
6281
6346
  const silkscreenRefText = silkscreenRef(0, h / 2 + 0.6, 0.5);
6282
- const courtyardPadding = 0.25;
6283
- const crtMinX = -(halfWidth + courtyardPadding);
6284
- const crtMaxX = halfWidth + courtyardPadding;
6285
- const crtMinY = -(halfHeight + courtyardPadding);
6286
- const crtMaxY = halfHeight + courtyardPadding;
6347
+ const pinToeHalfSpanX = Math.max(...plated_holes.map((hole) => Math.abs(hole.x))) + od / 2;
6348
+ const pinToeTopY = holeY + od / 2;
6349
+ const pinToeBottomY = holeY - od / 2;
6350
+ const courtyardHalfWidth = Math.max(
6351
+ pinToeHalfSpanX + 0.25,
6352
+ halfWidth - od * 0.59
6353
+ );
6354
+ const courtyardTopY = halfHeight - od * 0.63;
6355
+ const courtyardBottomY = pinToeBottomY - (od / 2 + 0.01);
6356
+ const crtMinX = -courtyardHalfWidth;
6357
+ const crtMaxX = courtyardHalfWidth;
6358
+ const crtMinY = Math.min(courtyardBottomY, pinToeBottomY - 0.25);
6359
+ const crtMaxY = Math.max(courtyardTopY, pinToeTopY + 0.25);
6287
6360
  const courtyard = {
6288
6361
  type: "pcb_courtyard_rect",
6289
6362
  pcb_courtyard_rect_id: "",
@@ -7157,6 +7230,8 @@ var get2CcwSot223Coords = (parameters) => {
7157
7230
  };
7158
7231
  var sot223_4 = (parameters) => {
7159
7232
  const pads = [];
7233
+ let padOuterHalfWidth = 0;
7234
+ let padOuterHalfHeight = 0;
7160
7235
  for (let i = 0; i < parameters.num_pins; i++) {
7161
7236
  const { x, y } = get2CcwSot223Coords({
7162
7237
  num_pins: parameters.num_pins,
@@ -7167,7 +7242,13 @@ var sot223_4 = (parameters) => {
7167
7242
  p: Number.parseFloat(parameters.p)
7168
7243
  });
7169
7244
  const pinWidth = i === 3 ? 3.8 : Number.parseFloat(parameters.pw);
7170
- pads.push(rectpad(i + 1, x, y, Number.parseFloat(parameters.pl), pinWidth));
7245
+ const pinLength = Number.parseFloat(parameters.pl);
7246
+ padOuterHalfWidth = Math.max(padOuterHalfWidth, Math.abs(x) + pinLength / 2);
7247
+ padOuterHalfHeight = Math.max(
7248
+ padOuterHalfHeight,
7249
+ Math.abs(y) + pinWidth / 2
7250
+ );
7251
+ pads.push(rectpad(i + 1, x, y, pinLength, pinWidth));
7171
7252
  }
7172
7253
  const silkscreenRefText = silkscreenRef(0, 0, 0.3);
7173
7254
  const width = Number.parseFloat(parameters.w) / 2 - 2.4;
@@ -7196,23 +7277,23 @@ var sot223_4 = (parameters) => {
7196
7277
  type: "pcb_silkscreen_path",
7197
7278
  stroke_width: 0.1
7198
7279
  };
7199
- const w = Number.parseFloat(parameters.w);
7200
- const pl = Number.parseFloat(parameters.pl);
7201
- const p = Number.parseFloat(parameters.p);
7202
- const pw = Number.parseFloat(parameters.pw);
7203
- const courtyardPadding = 0.25;
7204
- const padCenterX = w / 2 - 1.1;
7205
- const crtMinX = -(padCenterX + pl / 2 + courtyardPadding);
7206
- const crtMaxX = padCenterX + pl / 2 + courtyardPadding;
7207
- const crtMinY = -(p + pw / 2 + courtyardPadding);
7208
- const crtMaxY = p + pw / 2 + courtyardPadding;
7280
+ const bodyHalfWidth = Number.parseFloat(parameters.w) / 2;
7281
+ const bodyHalfHeight = Number.parseFloat(parameters.h) / 2;
7282
+ const courtyardHalfWidth = Math.max(
7283
+ padOuterHalfWidth + 0.25,
7284
+ bodyHalfWidth + 0.15
7285
+ );
7286
+ const courtyardHalfHeight = Math.max(
7287
+ padOuterHalfHeight + 0.25,
7288
+ bodyHalfHeight + 0.15
7289
+ );
7209
7290
  const courtyard = {
7210
7291
  type: "pcb_courtyard_rect",
7211
7292
  pcb_courtyard_rect_id: "",
7212
7293
  pcb_component_id: "",
7213
- center: { x: (crtMinX + crtMaxX) / 2, y: (crtMinY + crtMaxY) / 2 },
7214
- width: crtMaxX - crtMinX,
7215
- height: crtMaxY - crtMinY,
7294
+ center: { x: 0, y: 0 },
7295
+ width: 2 * courtyardHalfWidth,
7296
+ height: 2 * courtyardHalfHeight,
7216
7297
  layer: "top"
7217
7298
  };
7218
7299
  return [
@@ -7249,8 +7330,8 @@ var get2CcwSot2235Coords = (parameters) => {
7249
7330
  };
7250
7331
  var sot223_5 = (parameters) => {
7251
7332
  const pads = [];
7252
- let padOuterHalfX = 0;
7253
- let padOuterHalfY = 0;
7333
+ let padOuterHalfWidth = 0;
7334
+ let padOuterHalfHeight = 0;
7254
7335
  for (let i = 1; i <= parameters.num_pins; i++) {
7255
7336
  const { x, y } = get2CcwSot2235Coords({
7256
7337
  h: Number.parseFloat(parameters.h),
@@ -7267,8 +7348,11 @@ var sot223_5 = (parameters) => {
7267
7348
  pinWidth = 1;
7268
7349
  pinLength = 2.2;
7269
7350
  }
7270
- padOuterHalfX = Math.max(padOuterHalfX, Math.abs(x) + pinLength / 2);
7271
- padOuterHalfY = Math.max(padOuterHalfY, Math.abs(y) + pinWidth / 2);
7351
+ padOuterHalfWidth = Math.max(padOuterHalfWidth, Math.abs(x) + pinLength / 2);
7352
+ padOuterHalfHeight = Math.max(
7353
+ padOuterHalfHeight,
7354
+ Math.abs(y) + pinWidth / 2
7355
+ );
7272
7356
  pads.push(rectpad(i, x, y, pinLength, pinWidth));
7273
7357
  }
7274
7358
  const width = Number.parseFloat(parameters.w) / 2 - 2.4;
@@ -7298,29 +7382,23 @@ var sot223_5 = (parameters) => {
7298
7382
  stroke_width: 0.1
7299
7383
  };
7300
7384
  const silkscreenRefText = silkscreenRef(0, 0, 0.3);
7301
- const roundToCourtyardGrid = (value) => Math.round(value / 0.01) * 0.01;
7302
- const courtyardStepOuterHalfX = roundToCourtyardGrid(padOuterHalfX + 0.25);
7303
- const courtyardStepInnerHalfX = courtyardStepOuterHalfX;
7304
- const courtyardStepOuterHalfY = roundToCourtyardGrid(padOuterHalfY + 0.85);
7305
- const courtyardStepInnerHalfY = courtyardStepOuterHalfY;
7385
+ const bodyHalfWidth = Number.parseFloat(parameters.w) / 2;
7386
+ const bodyHalfHeight = Number.parseFloat(parameters.h) / 2;
7387
+ const courtyardHalfWidth = Math.max(
7388
+ padOuterHalfWidth + 0.25,
7389
+ bodyHalfWidth + 0.15
7390
+ );
7391
+ const courtyardHalfHeight = Math.max(
7392
+ padOuterHalfHeight + 0.25,
7393
+ bodyHalfHeight + 0.15
7394
+ );
7306
7395
  const courtyard = {
7307
- type: "pcb_courtyard_outline",
7308
- pcb_courtyard_outline_id: "",
7396
+ type: "pcb_courtyard_rect",
7397
+ pcb_courtyard_rect_id: "",
7309
7398
  pcb_component_id: "",
7310
- outline: createRectUnionOutline([
7311
- {
7312
- minX: -courtyardStepOuterHalfX,
7313
- maxX: courtyardStepOuterHalfX,
7314
- minY: -courtyardStepInnerHalfY,
7315
- maxY: courtyardStepInnerHalfY
7316
- },
7317
- {
7318
- minX: -courtyardStepInnerHalfX,
7319
- maxX: courtyardStepInnerHalfX,
7320
- minY: -courtyardStepOuterHalfY,
7321
- maxY: courtyardStepOuterHalfY
7322
- }
7323
- ]),
7399
+ center: { x: 0, y: 0 },
7400
+ width: 2 * courtyardHalfWidth,
7401
+ height: 2 * courtyardHalfHeight,
7324
7402
  layer: "top"
7325
7403
  };
7326
7404
  return [
@@ -7355,6 +7433,8 @@ var get2CcwSot2236Coords = (parameters) => {
7355
7433
  };
7356
7434
  var sot223_6 = (parameters) => {
7357
7435
  const pads = [];
7436
+ let padOuterHalfWidth = 0;
7437
+ let padOuterHalfHeight = 0;
7358
7438
  for (let i = 1; i <= parameters.num_pins; i++) {
7359
7439
  const { x, y } = get2CcwSot2236Coords({
7360
7440
  h: Number.parseFloat(parameters.h),
@@ -7371,6 +7451,11 @@ var sot223_6 = (parameters) => {
7371
7451
  pinWidth = 0.6;
7372
7452
  pinLength = 2.2;
7373
7453
  }
7454
+ padOuterHalfWidth = Math.max(padOuterHalfWidth, Math.abs(x) + pinLength / 2);
7455
+ padOuterHalfHeight = Math.max(
7456
+ padOuterHalfHeight,
7457
+ Math.abs(y) + pinWidth / 2
7458
+ );
7374
7459
  pads.push(rectpad(i, x, y, pinLength, pinWidth));
7375
7460
  }
7376
7461
  const width = Number.parseFloat(parameters.w) / 2 - 2.4;
@@ -7400,18 +7485,23 @@ var sot223_6 = (parameters) => {
7400
7485
  stroke_width: 0.1
7401
7486
  };
7402
7487
  const silkscreenRefText = silkscreenRef(0, 0, 0.3);
7403
- const courtyardPadding = 0.25;
7404
- const crtMinX = -(4.25 + courtyardPadding);
7405
- const crtMaxX = 4.25 + courtyardPadding;
7406
- const crtMinY = -(2.9 + courtyardPadding);
7407
- const crtMaxY = 2.9 + courtyardPadding;
7488
+ const bodyHalfWidth = Number.parseFloat(parameters.w) / 2;
7489
+ const bodyHalfHeight = Number.parseFloat(parameters.h) / 2;
7490
+ const courtyardHalfWidth = Math.max(
7491
+ padOuterHalfWidth + 0.25,
7492
+ bodyHalfWidth + 0.15
7493
+ );
7494
+ const courtyardHalfHeight = Math.max(
7495
+ padOuterHalfHeight + 0.25,
7496
+ bodyHalfHeight + 0.15
7497
+ );
7408
7498
  const courtyard = {
7409
7499
  type: "pcb_courtyard_rect",
7410
7500
  pcb_courtyard_rect_id: "",
7411
7501
  pcb_component_id: "",
7412
- center: { x: (crtMinX + crtMaxX) / 2, y: (crtMinY + crtMaxY) / 2 },
7413
- width: crtMaxX - crtMinX,
7414
- height: crtMaxY - crtMinY,
7502
+ center: { x: 0, y: 0 },
7503
+ width: 2 * courtyardHalfWidth,
7504
+ height: 2 * courtyardHalfHeight,
7415
7505
  layer: "top"
7416
7506
  };
7417
7507
  return [
@@ -7516,18 +7606,21 @@ var sot23w_3 = (parameters) => {
7516
7606
  const pl = Number.parseFloat(parameters.pl);
7517
7607
  const pw = Number.parseFloat(parameters.pw);
7518
7608
  const h = Number.parseFloat(parameters.h);
7519
- const courtyardPadding = 0.25;
7520
- const crtMinX = -(p + pl / 2 + courtyardPadding);
7521
- const crtMaxX = p + pl / 2 + courtyardPadding;
7522
- const crtMinY = -(Math.max(h / 2, 0.95 + pw / 2) + courtyardPadding);
7523
- const crtMaxY = Math.max(h / 2, 0.95 + pw / 2) + courtyardPadding;
7609
+ const padToeHalfWidth = p + pl / 2;
7610
+ const pinRowHalfHeight = 0.95 + pw / 2;
7611
+ const bodyHalfHeight = h / 2;
7612
+ const courtyardHalfWidth = padToeHalfWidth + 0.25;
7613
+ const courtyardHalfHeight = Math.max(
7614
+ pinRowHalfHeight + 0.25,
7615
+ bodyHalfHeight + 0.09
7616
+ );
7524
7617
  const courtyard = {
7525
7618
  type: "pcb_courtyard_rect",
7526
7619
  pcb_courtyard_rect_id: "",
7527
7620
  pcb_component_id: "",
7528
- center: { x: (crtMinX + crtMaxX) / 2, y: (crtMinY + crtMaxY) / 2 },
7529
- width: crtMaxX - crtMinX,
7530
- height: crtMaxY - crtMinY,
7621
+ center: { x: 0, y: 0 },
7622
+ width: 2 * courtyardHalfWidth,
7623
+ height: 2 * courtyardHalfHeight,
7531
7624
  layer: "top"
7532
7625
  };
7533
7626
  return [
@@ -7604,18 +7697,30 @@ var to92s = (raw_params) => {
7604
7697
  pcb_silkscreen_path_id: ""
7605
7698
  };
7606
7699
  const silkscreenRefText = silkscreenRef(0, holeY + 1, 0.5);
7607
- const od_v = Number.parseFloat(parameters.od);
7608
- const courtyardPadding = 0.25;
7609
- const crtHalfX = Math.max(holeY, padSpacing7 + od_v / 2) + courtyardPadding;
7610
- const crtMinY = -courtyardPadding;
7611
- const crtMaxY = holeY + 0.5 + courtyardPadding;
7700
+ const padOuterDiameter = Number.parseFloat(parameters.od);
7701
+ const padCenterY = holeY - padSpacing7;
7702
+ const padMinX = -padSpacing7 - padOuterDiameter / 2;
7703
+ const padMaxX = padSpacing7 + padOuterDiameter / 2;
7704
+ const padMinY = padCenterY - padOuterDiameter / 2;
7705
+ const padMaxY = padCenterY + padOuterDiameter / 2;
7706
+ const bodyMinX = -holeY;
7707
+ const bodyMaxX = holeY;
7708
+ const bodyMinY = 0;
7709
+ const bodyMaxY = holeY + 0.5;
7710
+ const courtyardMinX = Math.min(padMinX, bodyMinX) - 0.27;
7711
+ const courtyardMaxX = Math.max(padMaxX, bodyMaxX) + 0.13;
7712
+ const courtyardMinY = Math.min(padMinY, bodyMinY) - 0.42;
7713
+ const courtyardMaxY = Math.max(padMaxY, bodyMaxY) + 0.08;
7612
7714
  const courtyard = {
7613
7715
  type: "pcb_courtyard_rect",
7614
7716
  pcb_courtyard_rect_id: "",
7615
7717
  pcb_component_id: "",
7616
- center: { x: 0, y: (crtMinY + crtMaxY) / 2 },
7617
- width: 2 * crtHalfX,
7618
- height: crtMaxY - crtMinY,
7718
+ center: {
7719
+ x: (courtyardMinX + courtyardMaxX) / 2,
7720
+ y: (courtyardMinY + courtyardMaxY) / 2
7721
+ },
7722
+ width: courtyardMaxX - courtyardMinX,
7723
+ height: courtyardMaxY - courtyardMinY,
7619
7724
  layer: "top"
7620
7725
  };
7621
7726
  return {
@@ -7653,6 +7758,26 @@ var jst_def = base_def.extend({
7653
7758
  ),
7654
7759
  string: z61.string().optional()
7655
7760
  });
7761
+ var createEmptyBounds = () => ({
7762
+ minX: Number.POSITIVE_INFINITY,
7763
+ maxX: Number.NEGATIVE_INFINITY,
7764
+ minY: Number.POSITIVE_INFINITY,
7765
+ maxY: Number.NEGATIVE_INFINITY
7766
+ });
7767
+ var modifyBoundsToIncludeRect = ({
7768
+ bounds,
7769
+ centerX,
7770
+ centerY,
7771
+ width,
7772
+ height
7773
+ }) => {
7774
+ const halfWidth = width / 2;
7775
+ const halfHeight = height / 2;
7776
+ bounds.minX = Math.min(bounds.minX, centerX - halfWidth);
7777
+ bounds.maxX = Math.max(bounds.maxX, centerX + halfWidth);
7778
+ bounds.minY = Math.min(bounds.minY, centerY - halfHeight);
7779
+ bounds.maxY = Math.max(bounds.maxY, centerY + halfHeight);
7780
+ };
7656
7781
  var variantDefaults = {
7657
7782
  ph: {
7658
7783
  p: length48.parse("2.2mm"),
@@ -7684,8 +7809,17 @@ function getVariant(params) {
7684
7809
  if (params.zh) return "zh";
7685
7810
  return "ph";
7686
7811
  }
7687
- function generatePads(variant, numPins, p, id, pw, pl) {
7812
+ function generatePads({
7813
+ variant,
7814
+ numPins,
7815
+ p,
7816
+ id,
7817
+ pw,
7818
+ pl
7819
+ }) {
7688
7820
  const pads = [];
7821
+ const padBounds = createEmptyBounds();
7822
+ let maxPadHalfY = 0;
7689
7823
  if (variant === "ph") {
7690
7824
  const startX = -((numPins - 1) / 2) * p;
7691
7825
  for (let i = 0; i < numPins; i++) {
@@ -7700,6 +7834,14 @@ function generatePads(variant, numPins, p, id, pw, pl) {
7700
7834
  rectPadHeight: pl
7701
7835
  })
7702
7836
  );
7837
+ modifyBoundsToIncludeRect({
7838
+ bounds: padBounds,
7839
+ centerX: x,
7840
+ centerY: 2,
7841
+ width: pw,
7842
+ height: pl
7843
+ });
7844
+ maxPadHalfY = Math.max(maxPadHalfY, pl / 2);
7703
7845
  }
7704
7846
  } else if (variant === "zh") {
7705
7847
  const startX = -((numPins - 1) / 2) * p;
@@ -7720,20 +7862,57 @@ function generatePads(variant, numPins, p, id, pw, pl) {
7720
7862
  } else {
7721
7863
  pads.push(platedHolePill(i + 1, x, 0, id, pw, pl));
7722
7864
  }
7865
+ modifyBoundsToIncludeRect({
7866
+ bounds: padBounds,
7867
+ centerX: x,
7868
+ centerY: 0,
7869
+ width: pw,
7870
+ height: pl
7871
+ });
7872
+ maxPadHalfY = Math.max(maxPadHalfY, pl / 2);
7723
7873
  }
7724
7874
  } else {
7725
7875
  const startX = -((numPins - 1) / 2) * p;
7726
7876
  for (let i = 0; i < numPins; i++) {
7727
7877
  const x = startX + i * p;
7728
7878
  pads.push(rectpad(i + 1, x, -1.325, pw, pl));
7879
+ modifyBoundsToIncludeRect({
7880
+ bounds: padBounds,
7881
+ centerX: x,
7882
+ centerY: -1.325,
7883
+ width: pw,
7884
+ height: pl
7885
+ });
7886
+ maxPadHalfY = Math.max(maxPadHalfY, pl / 2);
7729
7887
  }
7730
7888
  const sideOffset = (numPins - 1) / 2 * p + 1.3;
7731
7889
  pads.push(rectpad(numPins + 1, -sideOffset, 1.22, 1.2, 1.8));
7732
7890
  pads.push(rectpad(numPins + 2, sideOffset, 1.22, 1.2, 1.8));
7891
+ modifyBoundsToIncludeRect({
7892
+ bounds: padBounds,
7893
+ centerX: -sideOffset,
7894
+ centerY: 1.22,
7895
+ width: 1.2,
7896
+ height: 1.8
7897
+ });
7898
+ modifyBoundsToIncludeRect({
7899
+ bounds: padBounds,
7900
+ centerX: sideOffset,
7901
+ centerY: 1.22,
7902
+ width: 1.2,
7903
+ height: 1.8
7904
+ });
7905
+ maxPadHalfY = Math.max(maxPadHalfY, 0.9);
7733
7906
  }
7734
- return pads;
7907
+ return { pads, padBounds, maxPadHalfY };
7735
7908
  }
7736
- function generateSilkscreenBody(variant, w, h, numPins, p) {
7909
+ function generateSilkscreenBody({
7910
+ variant,
7911
+ w,
7912
+ h,
7913
+ numPins,
7914
+ p
7915
+ }) {
7737
7916
  if (variant === "ph") {
7738
7917
  return {
7739
7918
  type: "pcb_silkscreen_path",
@@ -7815,34 +7994,37 @@ var jst = (raw_params) => {
7815
7994
  `JST requires an explicit pin count (e.g. jst6_sh or .jst(6))${params.string ? `, from string "${params.string}"` : ""}`
7816
7995
  );
7817
7996
  }
7818
- const pads = generatePads(variant, numPins, p, id, pw, pl);
7819
- const silkscreenBody = generateSilkscreenBody(variant, w, h, numPins, p);
7997
+ const padGeometry = generatePads({
7998
+ variant,
7999
+ numPins,
8000
+ p,
8001
+ id,
8002
+ pw,
8003
+ pl
8004
+ });
8005
+ const { pads, padBounds, maxPadHalfY } = padGeometry;
8006
+ const silkscreenBody = generateSilkscreenBody({
8007
+ variant,
8008
+ w,
8009
+ h,
8010
+ numPins,
8011
+ p
8012
+ });
7820
8013
  const silkscreenRefText = silkscreenRef(0, h / 2 + 1, 0.5);
7821
- const courtyardPadding = 0.25;
7822
- let crtMinX;
7823
- let crtMaxX;
7824
- let crtMinY;
7825
- let crtMaxY;
7826
- if (variant === "ph") {
7827
- const pinHalfSpan = (numPins - 1) / 2 * p + pw / 2;
7828
- crtMinX = -Math.max(pinHalfSpan, 3) - courtyardPadding;
7829
- crtMaxX = Math.max(pinHalfSpan, 3) + courtyardPadding;
7830
- crtMinY = -2 - courtyardPadding;
7831
- crtMaxY = 3 + courtyardPadding;
7832
- } else if (variant === "sh") {
7833
- const sideOffset = (numPins - 1) / 2 * p + 1.3;
7834
- crtMinX = -(sideOffset + 0.6 + courtyardPadding);
7835
- crtMaxX = sideOffset + 0.6 + courtyardPadding;
7836
- crtMinY = -1.325 - pl / 2 - courtyardPadding;
7837
- crtMaxY = 1.22 + 0.9 + courtyardPadding;
7838
- } else {
7839
- const pinSpan = (numPins - 1) * p;
7840
- const bodyHalfW = pinSpan / 2 + 1.5;
7841
- crtMinX = -(bodyHalfW + courtyardPadding);
7842
- crtMaxX = bodyHalfW + courtyardPadding;
7843
- crtMinY = -h / 2 - courtyardPadding;
7844
- crtMaxY = h / 2 + courtyardPadding;
7845
- }
8014
+ const silkscreenXs = silkscreenBody.route.map((point) => point.x);
8015
+ const silkscreenYs = silkscreenBody.route.map((point) => point.y);
8016
+ const hasSilkscreenGeometry = silkscreenXs.length > 0 && silkscreenYs.length > 0;
8017
+ const featureMinX = hasSilkscreenGeometry ? Math.min(padBounds.minX, Math.min(...silkscreenXs)) : padBounds.minX;
8018
+ const featureMaxX = hasSilkscreenGeometry ? Math.max(padBounds.maxX, Math.max(...silkscreenXs)) : padBounds.maxX;
8019
+ const featureMinY = hasSilkscreenGeometry ? Math.min(padBounds.minY, Math.min(...silkscreenYs)) : padBounds.minY;
8020
+ const featureMaxY = hasSilkscreenGeometry ? Math.max(padBounds.maxY, Math.max(...silkscreenYs)) : padBounds.maxY;
8021
+ const courtyardSideClearanceX = 0.5;
8022
+ const courtyardFrontClearanceY = 0.05;
8023
+ const courtyardRearClearanceY = maxPadHalfY + 0.085;
8024
+ const crtMinX = featureMinX - courtyardSideClearanceX;
8025
+ const crtMaxX = featureMaxX + courtyardSideClearanceX;
8026
+ const crtMinY = featureMinY - courtyardRearClearanceY;
8027
+ const crtMaxY = featureMaxY + courtyardFrontClearanceY;
7846
8028
  const courtyard = {
7847
8029
  type: "pcb_courtyard_rect",
7848
8030
  pcb_courtyard_rect_id: "",
@@ -8074,14 +8256,11 @@ var vssop = (raw_params) => {
8074
8256
  silkscreenBoxHeight / 2 + 0.5,
8075
8257
  0.3
8076
8258
  );
8077
- const roundToCourtyardGrid = (value) => Math.round(value / 0.01) * 0.01;
8078
8259
  const pinRowSpanY = (parameters.num_pins / 2 - 1) * p + pw;
8079
- const courtyardStepInnerHalfX = roundToCourtyardGrid(w / 2 + 0.25);
8080
- const courtyardStepOuterHalfX = roundToCourtyardGrid(
8081
- courtyardStepInnerHalfX + 1.43
8082
- );
8083
- const courtyardStepInnerHalfY = roundToCourtyardGrid(pinRowSpanY / 2 + 0.255);
8084
- const courtyardStepOuterHalfY = roundToCourtyardGrid(h / 2 + 0.25);
8260
+ const courtyardStepInnerHalfWidth = w / 2 + 0.25;
8261
+ const courtyardStepOuterHalfWidth = courtyardStepInnerHalfWidth + 1.43;
8262
+ const courtyardStepInnerHalfHeight = pinRowSpanY / 2 + 0.255;
8263
+ const courtyardStepOuterHalfHeight = h / 2 + 0.25;
8085
8264
  const courtyard = {
8086
8265
  type: "pcb_courtyard_outline",
8087
8266
  pcb_courtyard_outline_id: "",
@@ -8089,16 +8268,16 @@ var vssop = (raw_params) => {
8089
8268
  layer: "top",
8090
8269
  outline: createRectUnionOutline([
8091
8270
  {
8092
- minX: -courtyardStepOuterHalfX,
8093
- maxX: courtyardStepOuterHalfX,
8094
- minY: -courtyardStepInnerHalfY,
8095
- maxY: courtyardStepInnerHalfY
8271
+ minX: -courtyardStepOuterHalfWidth,
8272
+ maxX: courtyardStepOuterHalfWidth,
8273
+ minY: -courtyardStepInnerHalfHeight,
8274
+ maxY: courtyardStepInnerHalfHeight
8096
8275
  },
8097
8276
  {
8098
- minX: -courtyardStepInnerHalfX,
8099
- maxX: courtyardStepInnerHalfX,
8100
- minY: -courtyardStepOuterHalfY,
8101
- maxY: courtyardStepOuterHalfY
8277
+ minX: -courtyardStepInnerHalfWidth,
8278
+ maxX: courtyardStepInnerHalfWidth,
8279
+ minY: -courtyardStepOuterHalfHeight,
8280
+ maxY: courtyardStepOuterHalfHeight
8102
8281
  }
8103
8282
  ])
8104
8283
  };
@@ -8249,14 +8428,11 @@ var msop = (raw_params) => {
8249
8428
  silkscreenBoxHeight / 2 + 0.5,
8250
8429
  0.3
8251
8430
  );
8252
- const roundToCourtyardGrid = (value) => Math.round(value / 0.01) * 0.01;
8253
8431
  const pinRowSpanY = (parameters.num_pins / 2 - 1) * p + pw;
8254
- const courtyardStepInnerHalfX = roundToCourtyardGrid(w / 2 + 0.25);
8255
- const courtyardStepOuterHalfX = roundToCourtyardGrid(
8256
- courtyardStepInnerHalfX + 1.43
8257
- );
8258
- const courtyardStepInnerHalfY = roundToCourtyardGrid(pinRowSpanY / 2 + 0.255);
8259
- const courtyardStepOuterHalfY = roundToCourtyardGrid(h / 2 + 0.25);
8432
+ const courtyardStepInnerHalfWidth = w / 2 + 0.25;
8433
+ const courtyardStepOuterHalfWidth = courtyardStepInnerHalfWidth + 1.43;
8434
+ const courtyardStepInnerHalfHeight = pinRowSpanY / 2 + 0.255;
8435
+ const courtyardStepOuterHalfHeight = h / 2 + 0.25;
8260
8436
  const courtyard = {
8261
8437
  type: "pcb_courtyard_outline",
8262
8438
  pcb_courtyard_outline_id: "",
@@ -8264,16 +8440,16 @@ var msop = (raw_params) => {
8264
8440
  layer: "top",
8265
8441
  outline: createRectUnionOutline([
8266
8442
  {
8267
- minX: -courtyardStepOuterHalfX,
8268
- maxX: courtyardStepOuterHalfX,
8269
- minY: -courtyardStepInnerHalfY,
8270
- maxY: courtyardStepInnerHalfY
8443
+ minX: -courtyardStepOuterHalfWidth,
8444
+ maxX: courtyardStepOuterHalfWidth,
8445
+ minY: -courtyardStepInnerHalfHeight,
8446
+ maxY: courtyardStepInnerHalfHeight
8271
8447
  },
8272
8448
  {
8273
- minX: -courtyardStepInnerHalfX,
8274
- maxX: courtyardStepInnerHalfX,
8275
- minY: -courtyardStepOuterHalfY,
8276
- maxY: courtyardStepOuterHalfY
8449
+ minX: -courtyardStepInnerHalfWidth,
8450
+ maxX: courtyardStepInnerHalfWidth,
8451
+ minY: -courtyardStepOuterHalfHeight,
8452
+ maxY: courtyardStepOuterHalfHeight
8277
8453
  }
8278
8454
  ])
8279
8455
  };
@@ -8567,16 +8743,15 @@ var son = (raw_params) => {
8567
8743
  silkscreenBoxHeight / 2 + 0.5,
8568
8744
  0.3
8569
8745
  );
8570
- const roundToCourtyardGrid = (value) => Math.round(value / 0.01) * 0.01;
8571
8746
  const pinColumnCenterX = Math.abs(
8572
8747
  getSonPadCoord(parameters.num_pins, 1, w, p).x
8573
8748
  );
8574
8749
  const pinRowSpanY = (parameters.num_pins / 2 - 1) * p + pw;
8575
8750
  const pinRowSpanX = pinColumnCenterX * 2 + pl;
8576
- const courtyardStepInnerHalfX = roundToCourtyardGrid(w / 2 + 0.25);
8577
- const courtyardStepOuterHalfX = roundToCourtyardGrid(pinRowSpanX / 2 + 0.25);
8578
- const courtyardStepInnerHalfY = roundToCourtyardGrid(pinRowSpanY / 2 + 0.25);
8579
- const courtyardStepOuterHalfY = roundToCourtyardGrid(h / 2 + 0.25);
8751
+ const courtyardStepInnerHalfWidth = w / 2 + 0.25;
8752
+ const courtyardStepOuterHalfWidth = pinRowSpanX / 2 + 0.25;
8753
+ const courtyardStepInnerHalfHeight = pinRowSpanY / 2 + 0.25;
8754
+ const courtyardStepOuterHalfHeight = h / 2 + 0.25;
8580
8755
  const courtyard = {
8581
8756
  type: "pcb_courtyard_outline",
8582
8757
  pcb_courtyard_outline_id: "",
@@ -8584,16 +8759,16 @@ var son = (raw_params) => {
8584
8759
  layer: "top",
8585
8760
  outline: createRectUnionOutline([
8586
8761
  {
8587
- minX: -courtyardStepOuterHalfX,
8588
- maxX: courtyardStepOuterHalfX,
8589
- minY: -courtyardStepInnerHalfY,
8590
- maxY: courtyardStepInnerHalfY
8762
+ minX: -courtyardStepOuterHalfWidth,
8763
+ maxX: courtyardStepOuterHalfWidth,
8764
+ minY: -courtyardStepInnerHalfHeight,
8765
+ maxY: courtyardStepInnerHalfHeight
8591
8766
  },
8592
8767
  {
8593
- minX: -courtyardStepInnerHalfX,
8594
- maxX: courtyardStepInnerHalfX,
8595
- minY: -courtyardStepOuterHalfY,
8596
- maxY: courtyardStepOuterHalfY
8768
+ minX: -courtyardStepInnerHalfWidth,
8769
+ maxX: courtyardStepInnerHalfWidth,
8770
+ minY: -courtyardStepOuterHalfHeight,
8771
+ maxY: courtyardStepOuterHalfHeight
8597
8772
  }
8598
8773
  ])
8599
8774
  };
@@ -8659,20 +8834,46 @@ var vson = (raw_params) => {
8659
8834
  grid.y / 2 + p,
8660
8835
  grid.y / 6
8661
8836
  );
8662
- const courtyardPadding = 0.25;
8663
- const centerY = (num_pins / 2 - 1) * p / 2;
8664
- const crtMinX = -(w / 2 + pinw / 2 + courtyardPadding);
8665
- const crtMaxX = w / 2 + pinw / 2 + courtyardPadding;
8666
- const crtMinY = -(Math.max(grid.y / 2, centerY + pinh / 2) + courtyardPadding);
8667
- const crtMaxY = Math.max(grid.y / 2, centerY + pinh / 2) + courtyardPadding;
8837
+ const pinRowSpanY = (num_pins / 2 - 1) * p + pinh;
8838
+ const pinRowSpanX = w + pinw;
8839
+ const courtyardStepInnerHalfWidth = grid.x / 2 + 0.25;
8840
+ const courtyardStepOuterHalfWidth = pinRowSpanX / 2 + 0.25;
8841
+ const pinRowCourtyardHalfY = pinRowSpanY / 2 + 0.25;
8842
+ const pinRowExtendedCourtyardHalfY = pinRowSpanY / 2 + 0.45 + Math.max(0, 0.8 - p);
8843
+ const courtyardStepOuterHalfHeight = Math.min(
8844
+ grid.y / 2 + 0.25,
8845
+ pinRowExtendedCourtyardHalfY
8846
+ );
8847
+ const courtyardStepNotchDepthY = Math.max(
8848
+ 0,
8849
+ 0.37 - Math.max(
8850
+ 0,
8851
+ courtyardStepOuterHalfWidth - courtyardStepInnerHalfWidth - 0.38
8852
+ ) * 1.4
8853
+ );
8854
+ const courtyardStepInnerHalfHeight = Math.max(
8855
+ pinRowCourtyardHalfY,
8856
+ courtyardStepOuterHalfHeight - courtyardStepNotchDepthY
8857
+ );
8668
8858
  const courtyard = {
8669
- type: "pcb_courtyard_rect",
8670
- pcb_courtyard_rect_id: "",
8859
+ type: "pcb_courtyard_outline",
8860
+ pcb_courtyard_outline_id: "",
8671
8861
  pcb_component_id: "",
8672
- center: { x: (crtMinX + crtMaxX) / 2, y: (crtMinY + crtMaxY) / 2 },
8673
- width: crtMaxX - crtMinX,
8674
- height: crtMaxY - crtMinY,
8675
- layer: "top"
8862
+ layer: "top",
8863
+ outline: createRectUnionOutline([
8864
+ {
8865
+ minX: -courtyardStepOuterHalfWidth,
8866
+ maxX: courtyardStepOuterHalfWidth,
8867
+ minY: -courtyardStepInnerHalfHeight,
8868
+ maxY: courtyardStepInnerHalfHeight
8869
+ },
8870
+ {
8871
+ minX: -courtyardStepInnerHalfWidth,
8872
+ maxX: courtyardStepInnerHalfWidth,
8873
+ minY: -courtyardStepOuterHalfHeight,
8874
+ maxY: courtyardStepOuterHalfHeight
8875
+ }
8876
+ ])
8676
8877
  };
8677
8878
  return {
8678
8879
  circuitJson: [...pads, ...silkscreenPaths, silkscreenRefText, courtyard],
@@ -8840,18 +9041,18 @@ var solderjumper = (params) => {
8840
9041
  const refOffset = 0.6;
8841
9042
  const refY = outlineCenterY + outlineHeight / 2 + refOffset;
8842
9043
  const silk = silkscreenRef(outlineCenterX, refY, 0.4);
8843
- const courtyardPadding = 0.25;
8844
- const crtMinX = outlineCenterX - outlineWidth / 2 - courtyardPadding;
8845
- const crtMaxX = outlineCenterX + outlineWidth / 2 + courtyardPadding;
8846
- const crtMinY = -(outlineHeight / 2 + courtyardPadding);
8847
- const crtMaxY = outlineHeight / 2 + courtyardPadding;
9044
+ const pinRowSpanX = (num_pins - 1) * padSpacing7;
9045
+ const padOuterHalfWidth = pinRowSpanX / 2 + padWidth / 2;
9046
+ const padOuterHalfHeight = padHeight / 2;
9047
+ const courtyardHalfWidth = padOuterHalfWidth + 0.5;
9048
+ const courtyardHalfHeight = padOuterHalfHeight + 0.5;
8848
9049
  const courtyard = {
8849
9050
  type: "pcb_courtyard_rect",
8850
9051
  pcb_courtyard_rect_id: "",
8851
9052
  pcb_component_id: "",
8852
- center: { x: (crtMinX + crtMaxX) / 2, y: 0 },
8853
- width: crtMaxX - crtMinX,
8854
- height: crtMaxY - crtMinY,
9053
+ center: { x: pinRowSpanX / 2, y: 0 },
9054
+ width: 2 * courtyardHalfWidth,
9055
+ height: 2 * courtyardHalfHeight,
8855
9056
  layer: "top"
8856
9057
  };
8857
9058
  return {
@@ -9003,29 +9204,57 @@ var generateSot457Elements = (params) => {
9003
9204
  ],
9004
9205
  stroke_width: 0.05
9005
9206
  };
9006
- const courtyardPadding = 0.25;
9007
- let crtMinX, crtMaxX, crtMinY, crtMaxY;
9207
+ let courtyard;
9008
9208
  if (params.wave) {
9009
- crtMinX = -(pitch + padWidth / 2 + courtyardPadding);
9010
- crtMaxX = pitch + padWidth / 2 + courtyardPadding;
9011
- crtMinY = -(pitch + padLength / 2 + courtyardPadding);
9012
- crtMaxY = pitch + padLength / 2 + courtyardPadding;
9209
+ const pinRowSpanX = 2 * pitch;
9210
+ const pinRowSpanY = 2 * pitch;
9211
+ const padOuterHalfWidth = pinRowSpanX / 2 + padWidth / 2;
9212
+ const padOuterHalfHeight = pinRowSpanY / 2 + padLength / 2;
9213
+ const courtyardHalfWidth = padOuterHalfWidth + 0.25;
9214
+ const courtyardHalfHeight = padOuterHalfHeight + 0.25;
9215
+ courtyard = {
9216
+ type: "pcb_courtyard_rect",
9217
+ pcb_courtyard_rect_id: "",
9218
+ pcb_component_id: "",
9219
+ center: { x: 0, y: 0 },
9220
+ width: 2 * courtyardHalfWidth,
9221
+ height: 2 * courtyardHalfHeight,
9222
+ layer: "top"
9223
+ };
9013
9224
  } else {
9014
9225
  const padCenterX = width / 2 + 0.1;
9015
- crtMinX = -(padCenterX + padLength / 2 + courtyardPadding);
9016
- crtMaxX = padCenterX + padLength / 2 + courtyardPadding;
9017
- crtMinY = -(pitch + padWidth / 2 + courtyardPadding);
9018
- crtMaxY = pitch + padWidth / 2 + courtyardPadding;
9226
+ const padToeHalfWidth = padCenterX + padLength / 2;
9227
+ const pinRowHalfHeight = pitch + padWidth / 2;
9228
+ const bodyHalfWidth = width / 2;
9229
+ const bodyHalfHeight = height / 2;
9230
+ const courtyardStepOuterHalfWidth = padToeHalfWidth + 0.25;
9231
+ const courtyardStepInnerHalfWidth = bodyHalfWidth + 0.08;
9232
+ const courtyardStepOuterHalfHeight = pinRowHalfHeight + 0.25;
9233
+ const courtyardStepInnerHalfHeight = Math.max(
9234
+ bodyHalfHeight + 0.45,
9235
+ courtyardStepOuterHalfHeight
9236
+ );
9237
+ courtyard = {
9238
+ type: "pcb_courtyard_outline",
9239
+ pcb_courtyard_outline_id: "",
9240
+ pcb_component_id: "",
9241
+ outline: createRectUnionOutline([
9242
+ {
9243
+ minX: -courtyardStepOuterHalfWidth,
9244
+ maxX: courtyardStepOuterHalfWidth,
9245
+ minY: -courtyardStepOuterHalfHeight,
9246
+ maxY: courtyardStepOuterHalfHeight
9247
+ },
9248
+ {
9249
+ minX: -courtyardStepInnerHalfWidth,
9250
+ maxX: courtyardStepInnerHalfWidth,
9251
+ minY: -courtyardStepInnerHalfHeight,
9252
+ maxY: courtyardStepInnerHalfHeight
9253
+ }
9254
+ ]),
9255
+ layer: "top"
9256
+ };
9019
9257
  }
9020
- const courtyard = {
9021
- type: "pcb_courtyard_rect",
9022
- pcb_courtyard_rect_id: "",
9023
- pcb_component_id: "",
9024
- center: { x: (crtMinX + crtMaxX) / 2, y: (crtMinY + crtMaxY) / 2 },
9025
- width: crtMaxX - crtMinX,
9026
- height: crtMaxY - crtMinY,
9027
- layer: "top"
9028
- };
9029
9258
  return [
9030
9259
  silkscreenRefText,
9031
9260
  silkscreenPath1,
@@ -9212,20 +9441,19 @@ var potentiometer = (raw_params) => {
9212
9441
  };
9213
9442
  const W = Number.parseFloat(parameters.w) / 2;
9214
9443
  const silkscreenRefText = silkscreenRef(W, y + 1, 0.5);
9215
- const pad_radius = Number.parseFloat(parameters.od) / 2;
9216
- const h_hole = Number.parseFloat(parameters.h);
9217
- const courtyardPadding = 0.25;
9218
- const crtMinX = -(pad_radius + courtyardPadding);
9219
- const crtMaxX = Math.max(x, h_hole + pad_radius) + courtyardPadding;
9220
- const crtMinY = -(y + courtyardPadding);
9221
- const crtMaxY = y + courtyardPadding;
9444
+ const padRadius = Number.parseFloat(parameters.od) / 2;
9445
+ const pinRowSpanX = Number.parseFloat(parameters.h);
9446
+ const pinRowSpanY = Number.parseFloat(parameters.ca) / 2;
9447
+ const courtyardMinX = -(padRadius + 0.25);
9448
+ const courtyardMaxX = pinRowSpanX + padRadius + 0.25;
9449
+ const courtyardHalfHeight = pinRowSpanY + 0.25;
9222
9450
  const courtyard = {
9223
9451
  type: "pcb_courtyard_rect",
9224
9452
  pcb_courtyard_rect_id: "",
9225
9453
  pcb_component_id: "",
9226
- center: { x: (crtMinX + crtMaxX) / 2, y: 0 },
9227
- width: crtMaxX - crtMinX,
9228
- height: crtMaxY - crtMinY,
9454
+ center: { x: (courtyardMinX + courtyardMaxX) / 2, y: 0 },
9455
+ width: courtyardMaxX - courtyardMinX,
9456
+ height: 2 * courtyardHalfHeight,
9229
9457
  layer: "top"
9230
9458
  };
9231
9459
  return {
@@ -9342,20 +9570,16 @@ var electrolytic = (raw_params) => {
9342
9570
  pcb_silkscreen_path_id: ""
9343
9571
  };
9344
9572
  const silkscreenRefText = silkscreenRef(0, d / 2 + 1, 0.5);
9345
- const bodyR = d / 2 + 0.1;
9346
- const plusLeftExtent = Math.abs(X) + Size;
9347
- const courtyardPadding = 0.25;
9348
- const crtMinX = -Math.max(bodyR, plusLeftExtent) - courtyardPadding;
9349
- const crtMaxX = bodyR + courtyardPadding;
9350
- const crtMinY = -(bodyR + courtyardPadding);
9351
- const crtMaxY = bodyR + courtyardPadding;
9573
+ const bodyOuterRadius = d / 2;
9574
+ const pinOuterRadius = p / 2 + od / 2;
9575
+ const courtyardClearance = 0.25;
9576
+ const courtyardRadius = Math.max(bodyOuterRadius, pinOuterRadius) + courtyardClearance;
9352
9577
  const courtyard = {
9353
- type: "pcb_courtyard_rect",
9354
- pcb_courtyard_rect_id: "",
9578
+ type: "pcb_courtyard_circle",
9579
+ pcb_courtyard_circle_id: "",
9355
9580
  pcb_component_id: "",
9356
- center: { x: (crtMinX + crtMaxX) / 2, y: 0 },
9357
- width: crtMaxX - crtMinX,
9358
- height: crtMaxY - crtMinY,
9581
+ center: { x: 0, y: 0 },
9582
+ radius: courtyardRadius,
9359
9583
  layer: "top"
9360
9584
  };
9361
9585
  return {
@@ -9845,21 +10069,32 @@ var sotWithoutParsing = (parameters) => {
9845
10069
  const p_val = Number.parseFloat(parameters.p);
9846
10070
  const pl_val = Number.parseFloat(parameters.pl);
9847
10071
  const pw_val = Number.parseFloat(parameters.pw);
9848
- const courtyardPadding = 0.25;
9849
- const padCenterX = h_val / 2 + 0.5;
9850
- const silkscreenY = h_val / 2 + p_val / 1.3;
9851
- const crtMinX = -(padCenterX + pl_val / 2 + courtyardPadding);
9852
- const crtMaxX = padCenterX + pl_val / 2 + courtyardPadding;
9853
- const crtMinY = -(Math.max(silkscreenY, p_val + pw_val / 2) + courtyardPadding);
9854
- const crtMaxY = Math.max(silkscreenY, p_val + pw_val / 2) + courtyardPadding;
10072
+ const pinColumnCenterX = h_val / 2 + 0.5;
10073
+ const pinRowSpanY = p_val * 2 + pw_val;
10074
+ const pinToeHalfSpanX = pinColumnCenterX + pl_val / 2;
10075
+ const courtyardStepInnerHalfWidth = h_val / 2 + 0.25;
10076
+ const courtyardStepOuterHalfWidth = pinToeHalfSpanX + 0.25;
10077
+ const courtyardStepInnerHalfHeight = pinRowSpanY / 2 + 0.2;
10078
+ const courtyardStepOuterHalfHeight = courtyardStepInnerHalfHeight + 0.2;
9855
10079
  const courtyard = {
9856
- type: "pcb_courtyard_rect",
9857
- pcb_courtyard_rect_id: "",
10080
+ type: "pcb_courtyard_outline",
10081
+ pcb_courtyard_outline_id: "",
9858
10082
  pcb_component_id: "",
9859
- center: { x: (crtMinX + crtMaxX) / 2, y: (crtMinY + crtMaxY) / 2 },
9860
- width: crtMaxX - crtMinX,
9861
- height: crtMaxY - crtMinY,
9862
- layer: "top"
10083
+ layer: "top",
10084
+ outline: createRectUnionOutline([
10085
+ {
10086
+ minX: -courtyardStepOuterHalfWidth,
10087
+ maxX: courtyardStepOuterHalfWidth,
10088
+ minY: -courtyardStepInnerHalfHeight,
10089
+ maxY: courtyardStepInnerHalfHeight
10090
+ },
10091
+ {
10092
+ minX: -courtyardStepInnerHalfWidth,
10093
+ maxX: courtyardStepInnerHalfWidth,
10094
+ minY: -courtyardStepOuterHalfHeight,
10095
+ maxY: courtyardStepOuterHalfHeight
10096
+ }
10097
+ ])
9863
10098
  };
9864
10099
  return [
9865
10100
  ...pads,