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/browser/index.js
CHANGED
|
@@ -10117,8 +10117,9 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
10117
10117
|
}
|
|
10118
10118
|
const h = Math.sqrt(radius * radius - distance3 * distance3 / 4);
|
|
10119
10119
|
const angle = Math.atan2(dy, dx);
|
|
10120
|
-
const
|
|
10121
|
-
const
|
|
10120
|
+
const centerDirection = (sweepFlag ? -1 : 1) * (largeArcFlag ? -1 : 1);
|
|
10121
|
+
const centerX = midX + h * Math.sin(angle) * centerDirection;
|
|
10122
|
+
const centerY = midY - h * Math.cos(angle) * centerDirection;
|
|
10122
10123
|
const startAngle = Math.atan2(startY - centerY, startX - centerX);
|
|
10123
10124
|
let endAngle = Math.atan2(endY - centerY, endX - centerX);
|
|
10124
10125
|
if (sweepFlag && endAngle > startAngle) {
|
|
@@ -10151,6 +10152,71 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
10151
10152
|
// lib/utils/easyeda-unit-to-mm.ts
|
|
10152
10153
|
var mil10ToMm = (value) => value * 10 * 0.0254;
|
|
10153
10154
|
|
|
10155
|
+
// lib/utils/get-silkscreen-arc-path.ts
|
|
10156
|
+
var classifySemicircle = (arc, silkscreenTracks) => {
|
|
10157
|
+
const chord = {
|
|
10158
|
+
x: arc.end.x - arc.start.x,
|
|
10159
|
+
y: arc.end.y - arc.start.y
|
|
10160
|
+
};
|
|
10161
|
+
const chordLength = Math.hypot(chord.x, chord.y);
|
|
10162
|
+
const isSemicircle = !arc.largeArc && Math.abs(chordLength - 2 * arc.radiusX) <= Math.max(1e-6, arc.radiusX * 1e-4);
|
|
10163
|
+
if (!isSemicircle) return null;
|
|
10164
|
+
const endpointTolerance = Math.max(0.05, arc.radiusX * 0.02);
|
|
10165
|
+
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;
|
|
10166
|
+
let hasConnectedSegment = false;
|
|
10167
|
+
for (const track of silkscreenTracks) {
|
|
10168
|
+
if (track.layer !== arc.layer) continue;
|
|
10169
|
+
for (const [pointIndex, point2] of track.points.entries()) {
|
|
10170
|
+
if (!isNearEndpoint(point2)) continue;
|
|
10171
|
+
const neighbors = [
|
|
10172
|
+
track.points[pointIndex - 1],
|
|
10173
|
+
track.points[pointIndex + 1]
|
|
10174
|
+
];
|
|
10175
|
+
for (const neighbor of neighbors) {
|
|
10176
|
+
if (!neighbor) continue;
|
|
10177
|
+
hasConnectedSegment = true;
|
|
10178
|
+
const segment = {
|
|
10179
|
+
x: neighbor.x - point2.x,
|
|
10180
|
+
y: neighbor.y - point2.y
|
|
10181
|
+
};
|
|
10182
|
+
const segmentLength = Math.hypot(segment.x, segment.y);
|
|
10183
|
+
if (segmentLength === 0) continue;
|
|
10184
|
+
const normalizedDot = Math.abs(segment.x * chord.x + segment.y * chord.y) / (segmentLength * chordLength);
|
|
10185
|
+
if (normalizedDot < 0.25) return "end_cap";
|
|
10186
|
+
}
|
|
10187
|
+
}
|
|
10188
|
+
}
|
|
10189
|
+
return hasConnectedSegment ? "notch" : null;
|
|
10190
|
+
};
|
|
10191
|
+
var distanceFromRouteMidpoint = (route, point2) => {
|
|
10192
|
+
const midpoint2 = route[Math.floor(route.length / 2)];
|
|
10193
|
+
return Math.hypot(midpoint2.x - point2.x, midpoint2.y - point2.y);
|
|
10194
|
+
};
|
|
10195
|
+
var getSilkscreenArcPath = (arc, footprintCenter, silkscreenTracks) => {
|
|
10196
|
+
const generateArcPath = (sweepFlag2) => generateArcFromSweep(
|
|
10197
|
+
arc.start.x,
|
|
10198
|
+
arc.start.y,
|
|
10199
|
+
arc.end.x,
|
|
10200
|
+
arc.end.y,
|
|
10201
|
+
arc.radiusX,
|
|
10202
|
+
arc.largeArc,
|
|
10203
|
+
sweepFlag2
|
|
10204
|
+
);
|
|
10205
|
+
const sweepFlag = arc.sweepDirection === "CW";
|
|
10206
|
+
const arcPath = generateArcPath(sweepFlag);
|
|
10207
|
+
const semicircleRole = classifySemicircle(arc, silkscreenTracks);
|
|
10208
|
+
if (!semicircleRole) return arcPath;
|
|
10209
|
+
const oppositeArcPath = generateArcPath(!sweepFlag);
|
|
10210
|
+
const arcDistance = distanceFromRouteMidpoint(arcPath, footprintCenter);
|
|
10211
|
+
const oppositeDistance = distanceFromRouteMidpoint(
|
|
10212
|
+
oppositeArcPath,
|
|
10213
|
+
footprintCenter
|
|
10214
|
+
);
|
|
10215
|
+
const originalArcIsInward = arcDistance <= oppositeDistance;
|
|
10216
|
+
const shouldBowInward = semicircleRole === "notch";
|
|
10217
|
+
return originalArcIsInward === shouldBowInward ? arcPath : oppositeArcPath;
|
|
10218
|
+
};
|
|
10219
|
+
|
|
10154
10220
|
// lib/utils/get-polarized-pin-metadata.ts
|
|
10155
10221
|
var getPinLabelValues = (labels) => {
|
|
10156
10222
|
if (typeof labels === "string") return [labels];
|
|
@@ -10613,16 +10679,8 @@ var getSideFromLayer = (layer) => {
|
|
|
10613
10679
|
if (layer === 4 || layer === 14) return "bottom";
|
|
10614
10680
|
return "top";
|
|
10615
10681
|
};
|
|
10616
|
-
var handleSilkscreenArc = (arc, index) => {
|
|
10617
|
-
const arcPath =
|
|
10618
|
-
arc.start.x,
|
|
10619
|
-
arc.start.y,
|
|
10620
|
-
arc.end.x,
|
|
10621
|
-
arc.end.y,
|
|
10622
|
-
arc.radiusX,
|
|
10623
|
-
arc.largeArc,
|
|
10624
|
-
arc.sweepDirection === "CW"
|
|
10625
|
-
);
|
|
10682
|
+
var handleSilkscreenArc = (arc, index, footprintCenter, silkscreenTracks) => {
|
|
10683
|
+
const arcPath = getSilkscreenArcPath(arc, footprintCenter, silkscreenTracks);
|
|
10626
10684
|
return pcb_silkscreen_path.parse({
|
|
10627
10685
|
type: "pcb_silkscreen_path",
|
|
10628
10686
|
pcb_silkscreen_path_id: `pcb_silkscreen_arc_${index + 1}`,
|
|
@@ -10972,6 +11030,9 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
10972
11030
|
circuitElements.push(handleCutout(sr, index));
|
|
10973
11031
|
});
|
|
10974
11032
|
let hasFoundDesignator = false;
|
|
11033
|
+
const silkscreenTracks = easyEdaJson.packageDetail.dataStr.shape.filter(
|
|
11034
|
+
(shape) => shape.type === "TRACK" && isSilkscreenLayer(shape.layer)
|
|
11035
|
+
);
|
|
10975
11036
|
easyEdaJson.packageDetail.dataStr.shape.forEach((shape, index) => {
|
|
10976
11037
|
if (shape.type === "TRACK") {
|
|
10977
11038
|
if (isSilkscreenLayer(shape.layer)) {
|
|
@@ -10990,7 +11051,14 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, {
|
|
|
10990
11051
|
circuitElements.push(handleRect(shape, index));
|
|
10991
11052
|
} else if (shape.type === "ARC") {
|
|
10992
11053
|
if (!isCourtyardLayer(shape.layer)) {
|
|
10993
|
-
circuitElements.push(
|
|
11054
|
+
circuitElements.push(
|
|
11055
|
+
handleSilkscreenArc(
|
|
11056
|
+
shape,
|
|
11057
|
+
index,
|
|
11058
|
+
easyEdaJson.packageDetail.dataStr.head,
|
|
11059
|
+
silkscreenTracks
|
|
11060
|
+
)
|
|
11061
|
+
);
|
|
10994
11062
|
}
|
|
10995
11063
|
} else if (shape.type === "TEXT") {
|
|
10996
11064
|
if (isCourtyardLayer(shape.layer)) return;
|