easyeda 0.0.176 → 0.0.178

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.
@@ -2921,7 +2921,7 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
2921
2921
  }
2922
2922
 
2923
2923
  // lib/convert-easyeda-json-to-tscircuit-soup-json.ts
2924
- import { compose, scale, translate } from "transformation-matrix";
2924
+ import { compose, scale, translate, applyToPoint as applyToPoint2 } from "transformation-matrix";
2925
2925
 
2926
2926
  // lib/compute-center-offset.ts
2927
2927
  import { mm as mm2 } from "@tscircuit/mm";
@@ -3001,6 +3001,26 @@ var handleHole = (hole, index) => {
3001
3001
  pcb_hole_id: `pcb_hole_${index + 1}`
3002
3002
  });
3003
3003
  };
3004
+ var handleHoleCutout = (hole, index) => {
3005
+ return pcb_cutout.parse({
3006
+ type: "pcb_cutout",
3007
+ pcb_cutout_id: `pcb_cutout_from_hole_${index + 1}`,
3008
+ shape: "circle",
3009
+ center: { x: milx10(hole.center.x), y: milx10(hole.center.y) },
3010
+ radius: milx10(hole.radius)
3011
+ });
3012
+ };
3013
+ var handleCutout = (solidRegion, index) => {
3014
+ return pcb_cutout.parse({
3015
+ type: "pcb_cutout",
3016
+ pcb_cutout_id: `pcb_cutout_${index + 1}`,
3017
+ shape: "polygon",
3018
+ points: solidRegion.points.map((p) => ({
3019
+ x: milx10(p.x),
3020
+ y: milx10(p.y)
3021
+ }))
3022
+ });
3023
+ };
3004
3024
  var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecenter = true } = {}) => {
3005
3025
  const soupElements = [];
3006
3026
  const centerOffset = computeCenterOffset(easyEdaJson);
@@ -3134,6 +3154,12 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
3134
3154
  (shape) => shape.type === "HOLE"
3135
3155
  ).forEach((h, index) => {
3136
3156
  soupElements.push(handleHole(h, index));
3157
+ soupElements.push(handleHoleCutout(h, index));
3158
+ });
3159
+ easyEdaJson.packageDetail.dataStr.shape.filter(
3160
+ (shape) => shape.type === "SOLIDREGION" && shape.fillStyle === "cutout"
3161
+ ).forEach((sr, index) => {
3162
+ soupElements.push(handleCutout(sr, index));
3137
3163
  });
3138
3164
  easyEdaJson.packageDetail.dataStr.shape.forEach((shape, index) => {
3139
3165
  if (shape.type === "TRACK") {
@@ -3187,10 +3213,20 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
3187
3213
  // we set it to (0,0)
3188
3214
  soupElements.filter((e) => e.type !== "pcb_component")
3189
3215
  );
3190
- transformPCBElements(
3191
- soupElements,
3192
- compose(translate(-bounds.center.x, bounds.center.y), scale(1, -1))
3216
+ const matrix = compose(
3217
+ translate(-bounds.center.x, bounds.center.y),
3218
+ scale(1, -1)
3193
3219
  );
3220
+ transformPCBElements(soupElements, matrix);
3221
+ soupElements.forEach((e) => {
3222
+ if (e.type === "pcb_cutout") {
3223
+ if (e.shape === "polygon") {
3224
+ e.points = e.points.map((p) => applyToPoint2(matrix, p));
3225
+ } else {
3226
+ e.center = applyToPoint2(matrix, e.center);
3227
+ }
3228
+ }
3229
+ });
3194
3230
  pcb_component2.center = { x: 0, y: 0 };
3195
3231
  }
3196
3232
  return soupElements;