easyeda 0.0.340 → 0.0.342
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/browser/index.js +81 -13
- package/dist/browser/index.js.map +1 -1
- package/dist/index.js +81 -13
- package/dist/index.js.map +1 -1
- package/dist/main.cjs +82 -14
- package/dist/main.cjs.map +1 -1
- package/package.json +1 -1
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
|
|
6278
|
-
const
|
|
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 =
|
|
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}`,
|
|
@@ -7129,6 +7187,9 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
7129
7187
|
circuitElements.push(handleCutout(sr, index));
|
|
7130
7188
|
});
|
|
7131
7189
|
let hasFoundDesignator = false;
|
|
7190
|
+
const silkscreenTracks = easyEdaJson.packageDetail.dataStr.shape.filter(
|
|
7191
|
+
(shape) => shape.type === "TRACK" && isSilkscreenLayer(shape.layer)
|
|
7192
|
+
);
|
|
7132
7193
|
easyEdaJson.packageDetail.dataStr.shape.forEach((shape, index) => {
|
|
7133
7194
|
if (shape.type === "TRACK") {
|
|
7134
7195
|
if (isSilkscreenLayer(shape.layer)) {
|
|
@@ -7147,7 +7208,14 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
7147
7208
|
circuitElements.push(handleRect(shape, index));
|
|
7148
7209
|
} else if (shape.type === "ARC") {
|
|
7149
7210
|
if (!isCourtyardLayer(shape.layer)) {
|
|
7150
|
-
circuitElements.push(
|
|
7211
|
+
circuitElements.push(
|
|
7212
|
+
handleSilkscreenArc(
|
|
7213
|
+
shape,
|
|
7214
|
+
index,
|
|
7215
|
+
easyEdaJson.packageDetail.dataStr.head,
|
|
7216
|
+
silkscreenTracks
|
|
7217
|
+
)
|
|
7218
|
+
);
|
|
7151
7219
|
}
|
|
7152
7220
|
} else if (shape.type === "TEXT") {
|
|
7153
7221
|
if (isCourtyardLayer(shape.layer)) return;
|