easyeda 0.0.341 → 0.0.343

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
@@ -6274,8 +6274,9 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
6274
6274
  }
6275
6275
  const h = Math.sqrt(radius * radius - distance3 * distance3 / 4);
6276
6276
  const angle = Math.atan2(dy, dx);
6277
- const centerX = midX + h * Math.sin(angle) * (sweepFlag ? -1 : 1);
6278
- const centerY = midY - h * Math.cos(angle) * (sweepFlag ? -1 : 1);
6277
+ const centerDirection = (sweepFlag ? -1 : 1) * (largeArcFlag ? -1 : 1);
6278
+ const centerX = midX + h * Math.sin(angle) * centerDirection;
6279
+ const centerY = midY - h * Math.cos(angle) * centerDirection;
6279
6280
  const startAngle = Math.atan2(startY - centerY, startX - centerX);
6280
6281
  let endAngle = Math.atan2(endY - centerY, endX - centerX);
6281
6282
  if (sweepFlag && endAngle > startAngle) {
@@ -6308,6 +6309,71 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
6308
6309
  // lib/utils/easyeda-unit-to-mm.ts
6309
6310
  var mil10ToMm = (value) => value * 10 * 0.0254;
6310
6311
 
6312
+ // lib/utils/get-silkscreen-arc-path.ts
6313
+ var classifySemicircle = (arc, silkscreenTracks) => {
6314
+ const chord = {
6315
+ x: arc.end.x - arc.start.x,
6316
+ y: arc.end.y - arc.start.y
6317
+ };
6318
+ const chordLength = Math.hypot(chord.x, chord.y);
6319
+ const isSemicircle = !arc.largeArc && Math.abs(chordLength - 2 * arc.radiusX) <= Math.max(1e-6, arc.radiusX * 1e-4);
6320
+ if (!isSemicircle) return null;
6321
+ const endpointTolerance = Math.max(0.05, arc.radiusX * 0.02);
6322
+ const isNearEndpoint = (point2) => Math.hypot(point2.x - arc.start.x, point2.y - arc.start.y) <= endpointTolerance || Math.hypot(point2.x - arc.end.x, point2.y - arc.end.y) <= endpointTolerance;
6323
+ let hasConnectedSegment = false;
6324
+ for (const track of silkscreenTracks) {
6325
+ if (track.layer !== arc.layer) continue;
6326
+ for (const [pointIndex, point2] of track.points.entries()) {
6327
+ if (!isNearEndpoint(point2)) continue;
6328
+ const neighbors = [
6329
+ track.points[pointIndex - 1],
6330
+ track.points[pointIndex + 1]
6331
+ ];
6332
+ for (const neighbor of neighbors) {
6333
+ if (!neighbor) continue;
6334
+ hasConnectedSegment = true;
6335
+ const segment = {
6336
+ x: neighbor.x - point2.x,
6337
+ y: neighbor.y - point2.y
6338
+ };
6339
+ const segmentLength = Math.hypot(segment.x, segment.y);
6340
+ if (segmentLength === 0) continue;
6341
+ const normalizedDot = Math.abs(segment.x * chord.x + segment.y * chord.y) / (segmentLength * chordLength);
6342
+ if (normalizedDot < 0.25) return "end_cap";
6343
+ }
6344
+ }
6345
+ }
6346
+ return hasConnectedSegment ? "notch" : null;
6347
+ };
6348
+ var distanceFromRouteMidpoint = (route, point2) => {
6349
+ const midpoint2 = route[Math.floor(route.length / 2)];
6350
+ return Math.hypot(midpoint2.x - point2.x, midpoint2.y - point2.y);
6351
+ };
6352
+ var getSilkscreenArcPath = (arc, footprintCenter, silkscreenTracks) => {
6353
+ const generateArcPath = (sweepFlag2) => generateArcFromSweep(
6354
+ arc.start.x,
6355
+ arc.start.y,
6356
+ arc.end.x,
6357
+ arc.end.y,
6358
+ arc.radiusX,
6359
+ arc.largeArc,
6360
+ sweepFlag2
6361
+ );
6362
+ const sweepFlag = arc.sweepDirection === "CW";
6363
+ const arcPath = generateArcPath(sweepFlag);
6364
+ const semicircleRole = classifySemicircle(arc, silkscreenTracks);
6365
+ if (!semicircleRole) return arcPath;
6366
+ const oppositeArcPath = generateArcPath(!sweepFlag);
6367
+ const arcDistance = distanceFromRouteMidpoint(arcPath, footprintCenter);
6368
+ const oppositeDistance = distanceFromRouteMidpoint(
6369
+ oppositeArcPath,
6370
+ footprintCenter
6371
+ );
6372
+ const originalArcIsInward = arcDistance <= oppositeDistance;
6373
+ const shouldBowInward = semicircleRole === "notch";
6374
+ return originalArcIsInward === shouldBowInward ? arcPath : oppositeArcPath;
6375
+ };
6376
+
6311
6377
  // lib/utils/get-polarized-pin-metadata.ts
6312
6378
  var getPinLabelValues = (labels) => {
6313
6379
  if (typeof labels === "string") return [labels];
@@ -6770,16 +6836,8 @@ var getSideFromLayer = (layer) => {
6770
6836
  if (layer === 4 || layer === 14) return "bottom";
6771
6837
  return "top";
6772
6838
  };
6773
- var handleSilkscreenArc = (arc, index) => {
6774
- const arcPath = generateArcFromSweep(
6775
- arc.start.x,
6776
- arc.start.y,
6777
- arc.end.x,
6778
- arc.end.y,
6779
- arc.radiusX,
6780
- arc.largeArc,
6781
- arc.sweepDirection === "CW"
6782
- );
6839
+ var handleSilkscreenArc = (arc, index, footprintCenter, silkscreenTracks) => {
6840
+ const arcPath = getSilkscreenArcPath(arc, footprintCenter, silkscreenTracks);
6783
6841
  return pcb_silkscreen_path.parse({
6784
6842
  type: "pcb_silkscreen_path",
6785
6843
  pcb_silkscreen_path_id: `pcb_silkscreen_arc_${index + 1}`,
@@ -7048,10 +7106,15 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
7048
7106
  };
7049
7107
  } else {
7050
7108
  additionalPlatedHoleProps = {
7051
- shape: "circle",
7052
- hole_diameter: holeDiameter,
7053
- outer_diameter: Math.max(padWidth, padHeight),
7054
- radius: holeDiameter / 2
7109
+ shape: "rotated_pill_hole_with_rect_pad",
7110
+ hole_shape: "rotated_pill",
7111
+ pad_shape: "rect",
7112
+ hole_width: holeDiameter,
7113
+ hole_height: holeDiameter,
7114
+ hole_ccw_rotation: pad.rotation || 0,
7115
+ rect_ccw_rotation: pad.rotation || 0,
7116
+ rect_pad_width: padWidth,
7117
+ rect_pad_height: padHeight
7055
7118
  };
7056
7119
  }
7057
7120
  } else {
@@ -7129,6 +7192,9 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
7129
7192
  circuitElements.push(handleCutout(sr, index));
7130
7193
  });
7131
7194
  let hasFoundDesignator = false;
7195
+ const silkscreenTracks = easyEdaJson.packageDetail.dataStr.shape.filter(
7196
+ (shape) => shape.type === "TRACK" && isSilkscreenLayer(shape.layer)
7197
+ );
7132
7198
  easyEdaJson.packageDetail.dataStr.shape.forEach((shape, index) => {
7133
7199
  if (shape.type === "TRACK") {
7134
7200
  if (isSilkscreenLayer(shape.layer)) {
@@ -7147,7 +7213,14 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
7147
7213
  circuitElements.push(handleRect(shape, index));
7148
7214
  } else if (shape.type === "ARC") {
7149
7215
  if (!isCourtyardLayer(shape.layer)) {
7150
- circuitElements.push(handleSilkscreenArc(shape, index));
7216
+ circuitElements.push(
7217
+ handleSilkscreenArc(
7218
+ shape,
7219
+ index,
7220
+ easyEdaJson.packageDetail.dataStr.head,
7221
+ silkscreenTracks
7222
+ )
7223
+ );
7151
7224
  }
7152
7225
  } else if (shape.type === "TEXT") {
7153
7226
  if (isCourtyardLayer(shape.layer)) return;