circuit-to-svg 0.0.238 → 0.0.240
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 +36 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2346,8 +2346,18 @@ function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
|
2346
2346
|
if (hole.hole_shape === "pill") {
|
|
2347
2347
|
const scaledWidth = hole.hole_width * Math.abs(transform.a);
|
|
2348
2348
|
const scaledHeight = hole.hole_height * Math.abs(transform.a);
|
|
2349
|
-
const
|
|
2350
|
-
const
|
|
2349
|
+
const isHorizontal = scaledWidth > scaledHeight;
|
|
2350
|
+
const radius = Math.min(scaledWidth, scaledHeight) / 2;
|
|
2351
|
+
const straightLength = Math.abs(
|
|
2352
|
+
isHorizontal ? scaledWidth - scaledHeight : scaledHeight - scaledWidth
|
|
2353
|
+
);
|
|
2354
|
+
const pathD = isHorizontal ? (
|
|
2355
|
+
// Horizontal pill (wider than tall)
|
|
2356
|
+
`M${x - straightLength / 2},${y - radius} h${straightLength} a${radius},${radius} 0 0 1 0,${scaledHeight} h-${straightLength} a${radius},${radius} 0 0 1 0,-${scaledHeight} z`
|
|
2357
|
+
) : (
|
|
2358
|
+
// Vertical pill (taller than wide)
|
|
2359
|
+
`M${x - radius},${y - straightLength / 2} v${straightLength} a${radius},${radius} 0 0 0 ${scaledWidth},0 v-${straightLength} a${radius},${radius} 0 0 0 -${scaledWidth},0 z`
|
|
2360
|
+
);
|
|
2351
2361
|
return [
|
|
2352
2362
|
{
|
|
2353
2363
|
name: "path",
|
|
@@ -2355,7 +2365,7 @@ function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
|
2355
2365
|
attributes: {
|
|
2356
2366
|
class: "pcb-hole",
|
|
2357
2367
|
fill: colorMap2.drill,
|
|
2358
|
-
d:
|
|
2368
|
+
d: pathD,
|
|
2359
2369
|
"data-type": "pcb_hole",
|
|
2360
2370
|
"data-pcb-layer": "drill"
|
|
2361
2371
|
},
|
|
@@ -2367,9 +2377,19 @@ function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
|
2367
2377
|
if (hole.hole_shape === "rotated_pill") {
|
|
2368
2378
|
const scaledWidth = hole.hole_width * Math.abs(transform.a);
|
|
2369
2379
|
const scaledHeight = hole.hole_height * Math.abs(transform.a);
|
|
2370
|
-
const radiusX = scaledWidth / 2;
|
|
2371
|
-
const straightLength = scaledHeight - scaledWidth;
|
|
2372
2380
|
const rotation = "ccw_rotation" in hole ? hole.ccw_rotation ?? 0 : 0;
|
|
2381
|
+
const isHorizontal = scaledWidth > scaledHeight;
|
|
2382
|
+
const radius = Math.min(scaledWidth, scaledHeight) / 2;
|
|
2383
|
+
const straightLength = Math.abs(
|
|
2384
|
+
isHorizontal ? scaledWidth - scaledHeight : scaledHeight - scaledWidth
|
|
2385
|
+
);
|
|
2386
|
+
const pathD = isHorizontal ? (
|
|
2387
|
+
// Horizontal pill (wider than tall)
|
|
2388
|
+
`M${-straightLength / 2},${-radius} h${straightLength} a${radius},${radius} 0 0 1 0,${scaledHeight} h-${straightLength} a${radius},${radius} 0 0 1 0,-${scaledHeight} z`
|
|
2389
|
+
) : (
|
|
2390
|
+
// Vertical pill (taller than wide)
|
|
2391
|
+
`M${-radius},${-straightLength / 2} v${straightLength} a${radius},${radius} 0 0 0 ${scaledWidth},0 v-${straightLength} a${radius},${radius} 0 0 0 -${scaledWidth},0 z`
|
|
2392
|
+
);
|
|
2373
2393
|
return [
|
|
2374
2394
|
{
|
|
2375
2395
|
name: "path",
|
|
@@ -2377,7 +2397,7 @@ function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
|
2377
2397
|
attributes: {
|
|
2378
2398
|
class: "pcb-hole",
|
|
2379
2399
|
fill: colorMap2.drill,
|
|
2380
|
-
d:
|
|
2400
|
+
d: pathD,
|
|
2381
2401
|
transform: `translate(${x} ${y}) rotate(${-rotation})`,
|
|
2382
2402
|
"data-type": "pcb_hole",
|
|
2383
2403
|
"data-pcb-layer": "drill"
|
|
@@ -2913,7 +2933,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
2913
2933
|
var package_default = {
|
|
2914
2934
|
name: "circuit-to-svg",
|
|
2915
2935
|
type: "module",
|
|
2916
|
-
version: "0.0.
|
|
2936
|
+
version: "0.0.239",
|
|
2917
2937
|
description: "Convert Circuit JSON to SVG",
|
|
2918
2938
|
main: "dist/index.js",
|
|
2919
2939
|
files: [
|
|
@@ -3111,6 +3131,15 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
3111
3131
|
circuitJsonElm.width,
|
|
3112
3132
|
circuitJsonElm.height
|
|
3113
3133
|
);
|
|
3134
|
+
} else if (circuitJsonElm.type === "pcb_cutout") {
|
|
3135
|
+
const cutout = circuitJsonElm;
|
|
3136
|
+
if (cutout.shape === "rect") {
|
|
3137
|
+
updateBounds(cutout.center, cutout.width, cutout.height);
|
|
3138
|
+
} else if (cutout.shape === "circle") {
|
|
3139
|
+
updateBounds(cutout.center, cutout.radius * 2, cutout.radius * 2);
|
|
3140
|
+
} else if (cutout.shape === "polygon") {
|
|
3141
|
+
updateTraceBounds(cutout.points);
|
|
3142
|
+
}
|
|
3114
3143
|
} else if (circuitJsonElm.type === "pcb_silkscreen_text" || circuitJsonElm.type === "pcb_silkscreen_rect" || circuitJsonElm.type === "pcb_silkscreen_circle" || circuitJsonElm.type === "pcb_silkscreen_line") {
|
|
3115
3144
|
updateSilkscreenBounds(circuitJsonElm);
|
|
3116
3145
|
} else if (circuitJsonElm.type === "pcb_copper_pour") {
|