circuit-to-svg 0.0.289 → 0.0.290
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 +47 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5445,8 +5445,25 @@ import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
|
5445
5445
|
var DEFAULT_GROUP_COLOR = "rgba(100, 200, 255, 0.6)";
|
|
5446
5446
|
var DEFAULT_STROKE_WIDTH = 0.1;
|
|
5447
5447
|
function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
5448
|
-
const { transform } = ctx;
|
|
5448
|
+
const { transform, circuitJson } = ctx;
|
|
5449
5449
|
const { center, width, height } = pcbGroup;
|
|
5450
|
+
const svgObjects = [];
|
|
5451
|
+
if (ctx.showAnchorOffsets && pcbGroup.position_mode === "relative_to_group_anchor" && circuitJson) {
|
|
5452
|
+
const anchorPosition = getAnchorPosition2(pcbGroup, circuitJson);
|
|
5453
|
+
if (anchorPosition) {
|
|
5454
|
+
svgObjects.push(
|
|
5455
|
+
...createAnchorOffsetIndicators({
|
|
5456
|
+
groupAnchorPosition: anchorPosition,
|
|
5457
|
+
componentPosition: pcbGroup.center,
|
|
5458
|
+
transform,
|
|
5459
|
+
componentWidth: pcbGroup.width,
|
|
5460
|
+
componentHeight: pcbGroup.height,
|
|
5461
|
+
displayXOffset: pcbGroup.display_offset_x,
|
|
5462
|
+
displayYOffset: pcbGroup.display_offset_y
|
|
5463
|
+
})
|
|
5464
|
+
);
|
|
5465
|
+
}
|
|
5466
|
+
}
|
|
5450
5467
|
const outline = Array.isArray(pcbGroup.outline) ? pcbGroup.outline : void 0;
|
|
5451
5468
|
const transformedStrokeWidth = DEFAULT_STROKE_WIDTH * Math.abs(transform.a);
|
|
5452
5469
|
const dashLength = 0.3 * Math.abs(transform.a);
|
|
@@ -5471,22 +5488,21 @@ function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
|
5471
5488
|
const [x, y] = applyToPoint32(transform, [point.x, point.y]);
|
|
5472
5489
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
5473
5490
|
}).join(" ");
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5480
|
-
|
|
5481
|
-
|
|
5482
|
-
d: `${path} Z`
|
|
5483
|
-
}
|
|
5491
|
+
svgObjects.push({
|
|
5492
|
+
name: "path",
|
|
5493
|
+
type: "element",
|
|
5494
|
+
value: "",
|
|
5495
|
+
children: [],
|
|
5496
|
+
attributes: {
|
|
5497
|
+
...baseAttributes,
|
|
5498
|
+
d: `${path} Z`
|
|
5484
5499
|
}
|
|
5485
|
-
|
|
5500
|
+
});
|
|
5501
|
+
return svgObjects;
|
|
5486
5502
|
}
|
|
5487
5503
|
if (!center || typeof center.x !== "number" || typeof center.y !== "number" || typeof width !== "number" || typeof height !== "number") {
|
|
5488
5504
|
console.error("Invalid pcb_group data", { center, width, height });
|
|
5489
|
-
return
|
|
5505
|
+
return svgObjects;
|
|
5490
5506
|
}
|
|
5491
5507
|
const halfWidth = width / 2;
|
|
5492
5508
|
const halfHeight = height / 2;
|
|
@@ -5515,7 +5531,23 @@ function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
|
5515
5531
|
},
|
|
5516
5532
|
children: []
|
|
5517
5533
|
};
|
|
5518
|
-
|
|
5534
|
+
svgObjects.push(svgObject);
|
|
5535
|
+
return svgObjects;
|
|
5536
|
+
}
|
|
5537
|
+
function getAnchorPosition2(group, circuitJson) {
|
|
5538
|
+
if (group.positioned_relative_to_pcb_group_id) {
|
|
5539
|
+
const pcbGroup = circuitJson.find(
|
|
5540
|
+
(elm) => elm.type === "pcb_group" && elm.pcb_group_id === group.positioned_relative_to_pcb_group_id
|
|
5541
|
+
);
|
|
5542
|
+
if (pcbGroup?.center) return pcbGroup.center;
|
|
5543
|
+
}
|
|
5544
|
+
if (group.positioned_relative_to_pcb_board_id) {
|
|
5545
|
+
const pcbBoard = circuitJson.find(
|
|
5546
|
+
(elm) => elm.type === "pcb_board" && elm.pcb_board_id === group.positioned_relative_to_pcb_board_id
|
|
5547
|
+
);
|
|
5548
|
+
if (pcbBoard?.center) return pcbBoard.center;
|
|
5549
|
+
}
|
|
5550
|
+
return void 0;
|
|
5519
5551
|
}
|
|
5520
5552
|
|
|
5521
5553
|
// lib/utils/get-software-used-string.ts
|
|
@@ -5530,7 +5562,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
5530
5562
|
var package_default = {
|
|
5531
5563
|
name: "circuit-to-svg",
|
|
5532
5564
|
type: "module",
|
|
5533
|
-
version: "0.0.
|
|
5565
|
+
version: "0.0.289",
|
|
5534
5566
|
description: "Convert Circuit JSON to SVG",
|
|
5535
5567
|
main: "dist/index.js",
|
|
5536
5568
|
files: [
|