circuit-to-svg 0.0.290 → 0.0.292
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 +76 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5562,7 +5562,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
5562
5562
|
var package_default = {
|
|
5563
5563
|
name: "circuit-to-svg",
|
|
5564
5564
|
type: "module",
|
|
5565
|
-
version: "0.0.
|
|
5565
|
+
version: "0.0.291",
|
|
5566
5566
|
description: "Convert Circuit JSON to SVG",
|
|
5567
5567
|
main: "dist/index.js",
|
|
5568
5568
|
files: [
|
|
@@ -5585,7 +5585,7 @@ var package_default = {
|
|
|
5585
5585
|
"@vitejs/plugin-react": "5.0.0",
|
|
5586
5586
|
biome: "^0.3.3",
|
|
5587
5587
|
"bun-match-svg": "^0.0.12",
|
|
5588
|
-
"circuit-json": "^0.0.
|
|
5588
|
+
"circuit-json": "^0.0.333",
|
|
5589
5589
|
esbuild: "^0.20.2",
|
|
5590
5590
|
"performance-now": "^2.1.0",
|
|
5591
5591
|
react: "19.1.0",
|
|
@@ -10523,19 +10523,86 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
10523
10523
|
const probeColor = probe.color ?? colorMap2.schematic.reference;
|
|
10524
10524
|
const arrowLength = Math.abs(transform.a) * 0.6;
|
|
10525
10525
|
const arrowWidth = Math.abs(transform.a) * 0.28;
|
|
10526
|
-
const
|
|
10527
|
-
|
|
10526
|
+
const labelAlignment = probe.label_alignment ?? "top_right";
|
|
10527
|
+
let baseAngleRad;
|
|
10528
|
+
let textAnchor;
|
|
10529
|
+
let textOffsetX;
|
|
10530
|
+
let textOffsetY;
|
|
10531
|
+
switch (labelAlignment) {
|
|
10532
|
+
case "top_left":
|
|
10533
|
+
baseAngleRad = -135 * Math.PI / 180;
|
|
10534
|
+
textAnchor = "end";
|
|
10535
|
+
textOffsetX = -8;
|
|
10536
|
+
textOffsetY = -8;
|
|
10537
|
+
break;
|
|
10538
|
+
case "top_center":
|
|
10539
|
+
baseAngleRad = -90 * Math.PI / 180;
|
|
10540
|
+
textAnchor = "middle";
|
|
10541
|
+
textOffsetX = 0;
|
|
10542
|
+
textOffsetY = -8;
|
|
10543
|
+
break;
|
|
10544
|
+
case "top_right":
|
|
10545
|
+
baseAngleRad = -45 * Math.PI / 180;
|
|
10546
|
+
textAnchor = "start";
|
|
10547
|
+
textOffsetX = 8;
|
|
10548
|
+
textOffsetY = -8;
|
|
10549
|
+
break;
|
|
10550
|
+
case "center_left":
|
|
10551
|
+
baseAngleRad = 180 * Math.PI / 180;
|
|
10552
|
+
textAnchor = "end";
|
|
10553
|
+
textOffsetX = -8;
|
|
10554
|
+
textOffsetY = 0;
|
|
10555
|
+
break;
|
|
10556
|
+
case "center":
|
|
10557
|
+
baseAngleRad = -90 * Math.PI / 180;
|
|
10558
|
+
textAnchor = "middle";
|
|
10559
|
+
textOffsetX = 0;
|
|
10560
|
+
textOffsetY = -8;
|
|
10561
|
+
break;
|
|
10562
|
+
case "center_right":
|
|
10563
|
+
baseAngleRad = 0 * Math.PI / 180;
|
|
10564
|
+
textAnchor = "start";
|
|
10565
|
+
textOffsetX = 8;
|
|
10566
|
+
textOffsetY = 0;
|
|
10567
|
+
break;
|
|
10568
|
+
case "bottom_left":
|
|
10569
|
+
baseAngleRad = 135 * Math.PI / 180;
|
|
10570
|
+
textAnchor = "end";
|
|
10571
|
+
textOffsetX = -8;
|
|
10572
|
+
textOffsetY = 8;
|
|
10573
|
+
break;
|
|
10574
|
+
case "bottom_center":
|
|
10575
|
+
baseAngleRad = 90 * Math.PI / 180;
|
|
10576
|
+
textAnchor = "middle";
|
|
10577
|
+
textOffsetX = 0;
|
|
10578
|
+
textOffsetY = 8;
|
|
10579
|
+
break;
|
|
10580
|
+
case "bottom_right":
|
|
10581
|
+
baseAngleRad = 45 * Math.PI / 180;
|
|
10582
|
+
textAnchor = "start";
|
|
10583
|
+
textOffsetX = 8;
|
|
10584
|
+
textOffsetY = 8;
|
|
10585
|
+
break;
|
|
10586
|
+
default:
|
|
10587
|
+
baseAngleRad = -50 * Math.PI / 180;
|
|
10588
|
+
textAnchor = "start";
|
|
10589
|
+
textOffsetX = 8;
|
|
10590
|
+
textOffsetY = 0;
|
|
10591
|
+
}
|
|
10592
|
+
const baseX = screenX + arrowLength * Math.cos(baseAngleRad);
|
|
10593
|
+
const baseY = screenY + arrowLength * Math.sin(baseAngleRad);
|
|
10528
10594
|
const tipX = screenX;
|
|
10529
10595
|
const tipY = screenY;
|
|
10530
10596
|
const arrowPath = [
|
|
10531
10597
|
`M ${baseX},${baseY}`,
|
|
10532
10598
|
`L ${tipX},${tipY}`,
|
|
10533
10599
|
`M ${tipX},${tipY}`,
|
|
10534
|
-
`L ${tipX - arrowWidth * Math.cos((
|
|
10535
|
-
`L ${tipX - arrowWidth * Math.cos((
|
|
10600
|
+
`L ${tipX - arrowWidth * Math.cos((baseAngleRad * 180 / Math.PI + 150) * Math.PI / 180)},${tipY - arrowWidth * Math.sin((baseAngleRad * 180 / Math.PI + 150) * Math.PI / 180)}`,
|
|
10601
|
+
`L ${tipX - arrowWidth * Math.cos((baseAngleRad * 180 / Math.PI + 210) * Math.PI / 180)},${tipY - arrowWidth * Math.sin((baseAngleRad * 180 / Math.PI + 210) * Math.PI / 180)}`,
|
|
10536
10602
|
"Z"
|
|
10537
10603
|
].join(" ");
|
|
10538
|
-
const x = (baseX +
|
|
10604
|
+
const x = (baseX + textOffsetX).toString();
|
|
10605
|
+
const y = (baseY + textOffsetY).toString();
|
|
10539
10606
|
const textChildren = [];
|
|
10540
10607
|
if (probe.name && probe.voltage !== void 0) {
|
|
10541
10608
|
textChildren.push({
|
|
@@ -10608,9 +10675,9 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
10608
10675
|
value: "",
|
|
10609
10676
|
attributes: {
|
|
10610
10677
|
x,
|
|
10611
|
-
y
|
|
10678
|
+
y,
|
|
10612
10679
|
fill: probeColor,
|
|
10613
|
-
"text-anchor":
|
|
10680
|
+
"text-anchor": textAnchor,
|
|
10614
10681
|
"dominant-baseline": "middle",
|
|
10615
10682
|
"font-family": "sans-serif",
|
|
10616
10683
|
"font-size": `${getSchScreenFontSize(transform, "reference_designator")}px`,
|