circuit-to-svg 0.0.125 → 0.0.127
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 +268 -125
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// lib/pcb/convert-circuit-json-to-pcb-svg.ts
|
|
2
2
|
import { stringify } from "svgson";
|
|
3
3
|
import {
|
|
4
|
-
applyToPoint as
|
|
5
|
-
compose as
|
|
4
|
+
applyToPoint as applyToPoint17,
|
|
5
|
+
compose as compose4,
|
|
6
6
|
scale as scale2,
|
|
7
|
-
translate as
|
|
7
|
+
translate as translate4
|
|
8
8
|
} from "transformation-matrix";
|
|
9
9
|
|
|
10
10
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace-error.ts
|
|
@@ -578,7 +578,8 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, transform) {
|
|
|
578
578
|
text,
|
|
579
579
|
font_size = 1,
|
|
580
580
|
layer = "top",
|
|
581
|
-
ccw_rotation = 0
|
|
581
|
+
ccw_rotation = 0,
|
|
582
|
+
anchor_alignment = "center"
|
|
582
583
|
} = pcbSilkscreenText;
|
|
583
584
|
if (!anchor_position || typeof anchor_position.x !== "number" || typeof anchor_position.y !== "number") {
|
|
584
585
|
console.error("Invalid anchor_position:", anchor_position);
|
|
@@ -589,6 +590,33 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, transform) {
|
|
|
589
590
|
anchor_position.y
|
|
590
591
|
]);
|
|
591
592
|
const transformedFontSize = font_size * Math.abs(transform.a);
|
|
593
|
+
let textAnchor = "middle";
|
|
594
|
+
let dominantBaseline = "central";
|
|
595
|
+
let dx = 0;
|
|
596
|
+
let dy = 0;
|
|
597
|
+
switch (anchor_alignment) {
|
|
598
|
+
case "top_left":
|
|
599
|
+
textAnchor = "start";
|
|
600
|
+
dominantBaseline = "text-before-edge";
|
|
601
|
+
break;
|
|
602
|
+
case "top_right":
|
|
603
|
+
textAnchor = "end";
|
|
604
|
+
dominantBaseline = "text-before-edge";
|
|
605
|
+
break;
|
|
606
|
+
case "bottom_left":
|
|
607
|
+
textAnchor = "start";
|
|
608
|
+
dominantBaseline = "text-after-edge";
|
|
609
|
+
break;
|
|
610
|
+
case "bottom_right":
|
|
611
|
+
textAnchor = "end";
|
|
612
|
+
dominantBaseline = "text-after-edge";
|
|
613
|
+
break;
|
|
614
|
+
case "center":
|
|
615
|
+
default:
|
|
616
|
+
textAnchor = "middle";
|
|
617
|
+
dominantBaseline = "central";
|
|
618
|
+
break;
|
|
619
|
+
}
|
|
592
620
|
const textTransform = compose2(
|
|
593
621
|
translate2(transformedX, transformedY),
|
|
594
622
|
rotate2(ccw_rotation * Math.PI / 180),
|
|
@@ -601,11 +629,13 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, transform) {
|
|
|
601
629
|
attributes: {
|
|
602
630
|
x: "0",
|
|
603
631
|
y: "0",
|
|
632
|
+
dx: dx.toString(),
|
|
633
|
+
dy: dy.toString(),
|
|
604
634
|
fill: color,
|
|
605
635
|
"font-family": "Arial, sans-serif",
|
|
606
636
|
"font-size": transformedFontSize.toString(),
|
|
607
|
-
"text-anchor":
|
|
608
|
-
"dominant-baseline":
|
|
637
|
+
"text-anchor": textAnchor,
|
|
638
|
+
"dominant-baseline": dominantBaseline,
|
|
609
639
|
transform: matrixToString2(textTransform),
|
|
610
640
|
class: `pcb-silkscreen-text pcb-silkscreen-${layer}`,
|
|
611
641
|
"data-pcb-silkscreen-text-id": pcbSilkscreenText.pcb_component_id,
|
|
@@ -1157,6 +1187,91 @@ function createSvgObjectsForRatsNest(circuitJson, transform) {
|
|
|
1157
1187
|
return svgObjects;
|
|
1158
1188
|
}
|
|
1159
1189
|
|
|
1190
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-cutout.ts
|
|
1191
|
+
import {
|
|
1192
|
+
applyToPoint as applyToPoint16,
|
|
1193
|
+
compose as compose3,
|
|
1194
|
+
rotate as rotate3,
|
|
1195
|
+
translate as translate3,
|
|
1196
|
+
toString as matrixToString6
|
|
1197
|
+
} from "transformation-matrix";
|
|
1198
|
+
function createSvgObjectsFromPcbCutout(cutout, transform) {
|
|
1199
|
+
if (cutout.shape === "rect") {
|
|
1200
|
+
const rectCutout = cutout;
|
|
1201
|
+
const [cx, cy] = applyToPoint16(transform, [
|
|
1202
|
+
rectCutout.center.x,
|
|
1203
|
+
rectCutout.center.y
|
|
1204
|
+
]);
|
|
1205
|
+
const scaledWidth = rectCutout.width * Math.abs(transform.a);
|
|
1206
|
+
const scaledHeight = rectCutout.height * Math.abs(transform.d);
|
|
1207
|
+
const svgRotation = -(rectCutout.rotation ?? 0);
|
|
1208
|
+
return [
|
|
1209
|
+
{
|
|
1210
|
+
name: "rect",
|
|
1211
|
+
type: "element",
|
|
1212
|
+
attributes: {
|
|
1213
|
+
class: "pcb-cutout pcb-cutout-rect",
|
|
1214
|
+
x: (-scaledWidth / 2).toString(),
|
|
1215
|
+
y: (-scaledHeight / 2).toString(),
|
|
1216
|
+
width: scaledWidth.toString(),
|
|
1217
|
+
height: scaledHeight.toString(),
|
|
1218
|
+
fill: HOLE_COLOR,
|
|
1219
|
+
transform: matrixToString6(
|
|
1220
|
+
compose3(translate3(cx, cy), rotate3(svgRotation * Math.PI / 180))
|
|
1221
|
+
)
|
|
1222
|
+
},
|
|
1223
|
+
children: [],
|
|
1224
|
+
value: ""
|
|
1225
|
+
}
|
|
1226
|
+
];
|
|
1227
|
+
}
|
|
1228
|
+
if (cutout.shape === "circle") {
|
|
1229
|
+
const circleCutout = cutout;
|
|
1230
|
+
const [cx, cy] = applyToPoint16(transform, [
|
|
1231
|
+
circleCutout.center.x,
|
|
1232
|
+
circleCutout.center.y
|
|
1233
|
+
]);
|
|
1234
|
+
const scaledRadius = circleCutout.radius * Math.abs(transform.a);
|
|
1235
|
+
return [
|
|
1236
|
+
{
|
|
1237
|
+
name: "circle",
|
|
1238
|
+
type: "element",
|
|
1239
|
+
attributes: {
|
|
1240
|
+
class: "pcb-cutout pcb-cutout-circle",
|
|
1241
|
+
cx: cx.toString(),
|
|
1242
|
+
cy: cy.toString(),
|
|
1243
|
+
r: scaledRadius.toString(),
|
|
1244
|
+
fill: HOLE_COLOR
|
|
1245
|
+
},
|
|
1246
|
+
children: [],
|
|
1247
|
+
value: ""
|
|
1248
|
+
}
|
|
1249
|
+
];
|
|
1250
|
+
}
|
|
1251
|
+
if (cutout.shape === "polygon") {
|
|
1252
|
+
const polygonCutout = cutout;
|
|
1253
|
+
if (!polygonCutout.points || polygonCutout.points.length === 0) return [];
|
|
1254
|
+
const transformedPoints = polygonCutout.points.map(
|
|
1255
|
+
(p) => applyToPoint16(transform, [p.x, p.y])
|
|
1256
|
+
);
|
|
1257
|
+
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
1258
|
+
return [
|
|
1259
|
+
{
|
|
1260
|
+
name: "polygon",
|
|
1261
|
+
type: "element",
|
|
1262
|
+
attributes: {
|
|
1263
|
+
class: "pcb-cutout pcb-cutout-polygon",
|
|
1264
|
+
points: pointsString,
|
|
1265
|
+
fill: HOLE_COLOR
|
|
1266
|
+
},
|
|
1267
|
+
children: [],
|
|
1268
|
+
value: ""
|
|
1269
|
+
}
|
|
1270
|
+
];
|
|
1271
|
+
}
|
|
1272
|
+
return [];
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1160
1275
|
// lib/pcb/convert-circuit-json-to-pcb-svg.ts
|
|
1161
1276
|
var OBJECT_ORDER = [
|
|
1162
1277
|
"pcb_trace_error",
|
|
@@ -1166,6 +1281,7 @@ var OBJECT_ORDER = [
|
|
|
1166
1281
|
"pcb_silkscreen_text",
|
|
1167
1282
|
"pcb_silkscreen_path",
|
|
1168
1283
|
"pcb_via",
|
|
1284
|
+
"pcb_cutout",
|
|
1169
1285
|
"pcb_trace",
|
|
1170
1286
|
"pcb_smtpad",
|
|
1171
1287
|
"pcb_component",
|
|
@@ -1206,8 +1322,8 @@ function convertCircuitJsonToPcbSvg(soup, options) {
|
|
|
1206
1322
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
1207
1323
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
1208
1324
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
1209
|
-
const transform =
|
|
1210
|
-
|
|
1325
|
+
const transform = compose4(
|
|
1326
|
+
translate4(
|
|
1211
1327
|
offsetX - minX * scaleFactor + padding * scaleFactor,
|
|
1212
1328
|
svgHeight - offsetY + minY * scaleFactor - padding * scaleFactor
|
|
1213
1329
|
),
|
|
@@ -1308,6 +1424,15 @@ function convertCircuitJsonToPcbSvg(soup, options) {
|
|
|
1308
1424
|
} else if (item.type === "pcb_silkscreen_line") {
|
|
1309
1425
|
updateBounds({ x: item.x1, y: item.y1 }, 0, 0);
|
|
1310
1426
|
updateBounds({ x: item.x2, y: item.y2 }, 0, 0);
|
|
1427
|
+
} else if (item.type === "pcb_cutout") {
|
|
1428
|
+
const cutout = item;
|
|
1429
|
+
if (cutout.shape === "rect") {
|
|
1430
|
+
updateBounds(cutout.center, cutout.width, cutout.height);
|
|
1431
|
+
} else if (cutout.shape === "circle") {
|
|
1432
|
+
updateBounds(cutout.center, cutout.radius * 2, cutout.radius * 2);
|
|
1433
|
+
} else if (cutout.shape === "polygon") {
|
|
1434
|
+
updateTraceBounds(cutout.points);
|
|
1435
|
+
}
|
|
1311
1436
|
}
|
|
1312
1437
|
}
|
|
1313
1438
|
}
|
|
@@ -1348,13 +1473,15 @@ function createSvgObjects(elm, transform, soup, shouldDrawErrors) {
|
|
|
1348
1473
|
return createSvgObjectsFromPcbBoard(elm, transform);
|
|
1349
1474
|
case "pcb_via":
|
|
1350
1475
|
return createSvgObjectsFromPcbVia(elm, transform);
|
|
1476
|
+
case "pcb_cutout":
|
|
1477
|
+
return createSvgObjectsFromPcbCutout(elm, transform);
|
|
1351
1478
|
default:
|
|
1352
1479
|
return [];
|
|
1353
1480
|
}
|
|
1354
1481
|
}
|
|
1355
1482
|
function createSvgObjectsFromPcbComponent(component, transform) {
|
|
1356
1483
|
const { center, width, height, rotation = 0 } = component;
|
|
1357
|
-
const [x, y] =
|
|
1484
|
+
const [x, y] = applyToPoint17(transform, [center.x, center.y]);
|
|
1358
1485
|
const scaledWidth = width * Math.abs(transform.a);
|
|
1359
1486
|
const scaledHeight = height * Math.abs(transform.d);
|
|
1360
1487
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
@@ -1389,8 +1516,8 @@ function createSvgObjectsFromPcbComponent(component, transform) {
|
|
|
1389
1516
|
};
|
|
1390
1517
|
}
|
|
1391
1518
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
1392
|
-
const [x1, y1] =
|
|
1393
|
-
const [x2, y2] =
|
|
1519
|
+
const [x1, y1] = applyToPoint17(transform, [minX, minY]);
|
|
1520
|
+
const [x2, y2] = applyToPoint17(transform, [maxX, maxY]);
|
|
1394
1521
|
const width = Math.abs(x2 - x1);
|
|
1395
1522
|
const height = Math.abs(y2 - y1);
|
|
1396
1523
|
const x = Math.min(x1, x2);
|
|
@@ -1418,14 +1545,14 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
1418
1545
|
import { stringify as stringify2 } from "svgson";
|
|
1419
1546
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
1420
1547
|
import {
|
|
1421
|
-
applyToPoint as
|
|
1422
|
-
compose as
|
|
1548
|
+
applyToPoint as applyToPoint21,
|
|
1549
|
+
compose as compose5,
|
|
1423
1550
|
scale as scale3,
|
|
1424
|
-
translate as
|
|
1551
|
+
translate as translate5
|
|
1425
1552
|
} from "transformation-matrix";
|
|
1426
1553
|
|
|
1427
1554
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
1428
|
-
import { applyToPoint as
|
|
1555
|
+
import { applyToPoint as applyToPoint18 } from "transformation-matrix";
|
|
1429
1556
|
var DEFAULT_BOARD_STYLE = {
|
|
1430
1557
|
fill: "none",
|
|
1431
1558
|
stroke: "rgb(0,0,0)",
|
|
@@ -1437,25 +1564,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
1437
1564
|
let path;
|
|
1438
1565
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
1439
1566
|
path = outline.map((point, index) => {
|
|
1440
|
-
const [x, y] =
|
|
1567
|
+
const [x, y] = applyToPoint18(transform, [point.x, point.y]);
|
|
1441
1568
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
1442
1569
|
}).join(" ");
|
|
1443
1570
|
} else {
|
|
1444
1571
|
const halfWidth = width / 2;
|
|
1445
1572
|
const halfHeight = height / 2;
|
|
1446
|
-
const topLeft =
|
|
1573
|
+
const topLeft = applyToPoint18(transform, [
|
|
1447
1574
|
center.x - halfWidth,
|
|
1448
1575
|
center.y - halfHeight
|
|
1449
1576
|
]);
|
|
1450
|
-
const topRight =
|
|
1577
|
+
const topRight = applyToPoint18(transform, [
|
|
1451
1578
|
center.x + halfWidth,
|
|
1452
1579
|
center.y - halfHeight
|
|
1453
1580
|
]);
|
|
1454
|
-
const bottomRight =
|
|
1581
|
+
const bottomRight = applyToPoint18(transform, [
|
|
1455
1582
|
center.x + halfWidth,
|
|
1456
1583
|
center.y + halfHeight
|
|
1457
1584
|
]);
|
|
1458
|
-
const bottomLeft =
|
|
1585
|
+
const bottomLeft = applyToPoint18(transform, [
|
|
1459
1586
|
center.x - halfWidth,
|
|
1460
1587
|
center.y + halfHeight
|
|
1461
1588
|
]);
|
|
@@ -1481,7 +1608,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
1481
1608
|
}
|
|
1482
1609
|
|
|
1483
1610
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
1484
|
-
import { applyToPoint as
|
|
1611
|
+
import { applyToPoint as applyToPoint20 } from "transformation-matrix";
|
|
1485
1612
|
|
|
1486
1613
|
// lib/utils/get-sch-font-size.ts
|
|
1487
1614
|
import "transformation-matrix";
|
|
@@ -1499,8 +1626,8 @@ function createSvgObjectsFromAssemblyComponent(params, ctx) {
|
|
|
1499
1626
|
const { center, width, height, rotation = 0, layer = "top" } = elm;
|
|
1500
1627
|
if (!center || typeof width !== "number" || typeof height !== "number")
|
|
1501
1628
|
return null;
|
|
1502
|
-
const [x, y] =
|
|
1503
|
-
const [pinX, pinY] =
|
|
1629
|
+
const [x, y] = applyToPoint20(transform, [center.x, center.y]);
|
|
1630
|
+
const [pinX, pinY] = applyToPoint20(transform, [portPosition.x, portPosition.y]);
|
|
1504
1631
|
const scaledWidth = width * Math.abs(transform.a);
|
|
1505
1632
|
const scaledHeight = height * Math.abs(transform.d);
|
|
1506
1633
|
const isTopLayer = layer === "top";
|
|
@@ -1689,8 +1816,8 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
1689
1816
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
1690
1817
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
1691
1818
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
1692
|
-
const transform =
|
|
1693
|
-
|
|
1819
|
+
const transform = compose5(
|
|
1820
|
+
translate5(
|
|
1694
1821
|
offsetX - minX * scaleFactor + padding * scaleFactor,
|
|
1695
1822
|
svgHeight - offsetY + minY * scaleFactor - padding * scaleFactor
|
|
1696
1823
|
),
|
|
@@ -1797,8 +1924,8 @@ function createSvgObjects2(elm, transform, soup) {
|
|
|
1797
1924
|
}
|
|
1798
1925
|
}
|
|
1799
1926
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
1800
|
-
const [x1, y1] =
|
|
1801
|
-
const [x2, y2] =
|
|
1927
|
+
const [x1, y1] = applyToPoint21(transform, [minX, minY]);
|
|
1928
|
+
const [x2, y2] = applyToPoint21(transform, [maxX, maxY]);
|
|
1802
1929
|
const width = Math.abs(x2 - x1);
|
|
1803
1930
|
const height = Math.abs(y2 - y1);
|
|
1804
1931
|
const x = Math.min(x1, x2);
|
|
@@ -2064,14 +2191,14 @@ import {
|
|
|
2064
2191
|
} from "transformation-matrix";
|
|
2065
2192
|
|
|
2066
2193
|
// lib/sch/draw-schematic-grid.ts
|
|
2067
|
-
import { applyToPoint as
|
|
2194
|
+
import { applyToPoint as applyToPoint22 } from "transformation-matrix";
|
|
2068
2195
|
function drawSchematicGrid(params) {
|
|
2069
2196
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
2070
2197
|
const cellSize = params.cellSize ?? 1;
|
|
2071
2198
|
const labelCells = params.labelCells ?? false;
|
|
2072
2199
|
const gridLines = [];
|
|
2073
2200
|
const transformPoint = (x, y) => {
|
|
2074
|
-
const [transformedX, transformedY] =
|
|
2201
|
+
const [transformedX, transformedY] = applyToPoint22(params.transform, [x, y]);
|
|
2075
2202
|
return { x: transformedX, y: transformedY };
|
|
2076
2203
|
};
|
|
2077
2204
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -2152,15 +2279,15 @@ function drawSchematicGrid(params) {
|
|
|
2152
2279
|
}
|
|
2153
2280
|
|
|
2154
2281
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
2155
|
-
import { applyToPoint as
|
|
2282
|
+
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
2156
2283
|
function drawSchematicLabeledPoints(params) {
|
|
2157
2284
|
const { points, transform } = params;
|
|
2158
2285
|
const labeledPointsGroup = [];
|
|
2159
2286
|
for (const point of points) {
|
|
2160
|
-
const [x1, y1] =
|
|
2161
|
-
const [x2, y2] =
|
|
2162
|
-
const [x3, y3] =
|
|
2163
|
-
const [x4, y4] =
|
|
2287
|
+
const [x1, y1] = applyToPoint23(transform, [point.x - 0.1, point.y - 0.1]);
|
|
2288
|
+
const [x2, y2] = applyToPoint23(transform, [point.x + 0.1, point.y + 0.1]);
|
|
2289
|
+
const [x3, y3] = applyToPoint23(transform, [point.x - 0.1, point.y + 0.1]);
|
|
2290
|
+
const [x4, y4] = applyToPoint23(transform, [point.x + 0.1, point.y - 0.1]);
|
|
2164
2291
|
labeledPointsGroup.push({
|
|
2165
2292
|
name: "path",
|
|
2166
2293
|
type: "element",
|
|
@@ -2171,7 +2298,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
2171
2298
|
"stroke-opacity": "0.7"
|
|
2172
2299
|
}
|
|
2173
2300
|
});
|
|
2174
|
-
const [labelX, labelY] =
|
|
2301
|
+
const [labelX, labelY] = applyToPoint23(transform, [
|
|
2175
2302
|
point.x + 0.15,
|
|
2176
2303
|
point.y - 0.15
|
|
2177
2304
|
]);
|
|
@@ -2274,8 +2401,8 @@ import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
|
2274
2401
|
import { symbols } from "schematic-symbols";
|
|
2275
2402
|
import "svgson";
|
|
2276
2403
|
import {
|
|
2277
|
-
applyToPoint as
|
|
2278
|
-
compose as
|
|
2404
|
+
applyToPoint as applyToPoint25,
|
|
2405
|
+
compose as compose7
|
|
2279
2406
|
} from "transformation-matrix";
|
|
2280
2407
|
|
|
2281
2408
|
// lib/utils/get-sch-stroke-size.ts
|
|
@@ -2345,26 +2472,26 @@ var matchSchPortsToSymbolPorts = ({
|
|
|
2345
2472
|
};
|
|
2346
2473
|
|
|
2347
2474
|
// lib/utils/point-pairs-to-matrix.ts
|
|
2348
|
-
import { compose as
|
|
2475
|
+
import { compose as compose6, scale as scale4, translate as translate6 } from "transformation-matrix";
|
|
2349
2476
|
function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
2350
2477
|
const tx = a2.x - a1.x;
|
|
2351
2478
|
const ty = a2.y - a1.y;
|
|
2352
2479
|
const originalDistance = Math.sqrt((b1.x - a1.x) ** 2 + (b1.y - a1.y) ** 2);
|
|
2353
2480
|
const transformedDistance = Math.sqrt((b2.x - a2.x) ** 2 + (b2.y - a2.y) ** 2);
|
|
2354
2481
|
const a = transformedDistance / originalDistance;
|
|
2355
|
-
const translateMatrix =
|
|
2482
|
+
const translateMatrix = translate6(tx, ty);
|
|
2356
2483
|
const scaleMatrix = scale4(a, a);
|
|
2357
|
-
return
|
|
2484
|
+
return compose6(translateMatrix, scaleMatrix);
|
|
2358
2485
|
}
|
|
2359
2486
|
|
|
2360
2487
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
2361
|
-
import { applyToPoint as
|
|
2488
|
+
import { applyToPoint as applyToPoint24 } from "transformation-matrix";
|
|
2362
2489
|
var createSvgSchErrorText = ({
|
|
2363
2490
|
text,
|
|
2364
2491
|
realCenter,
|
|
2365
2492
|
realToScreenTransform
|
|
2366
2493
|
}) => {
|
|
2367
|
-
const screenCenter =
|
|
2494
|
+
const screenCenter = applyToPoint24(realToScreenTransform, realCenter);
|
|
2368
2495
|
return {
|
|
2369
2496
|
type: "element",
|
|
2370
2497
|
name: "text",
|
|
@@ -2455,12 +2582,12 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2455
2582
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
2456
2583
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
2457
2584
|
};
|
|
2458
|
-
const [screenMinX, screenMinY] =
|
|
2459
|
-
|
|
2585
|
+
const [screenMinX, screenMinY] = applyToPoint25(
|
|
2586
|
+
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
2460
2587
|
[bounds.minX, bounds.minY]
|
|
2461
2588
|
);
|
|
2462
|
-
const [screenMaxX, screenMaxY] =
|
|
2463
|
-
|
|
2589
|
+
const [screenMaxX, screenMaxY] = applyToPoint25(
|
|
2590
|
+
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
2464
2591
|
[bounds.maxX, bounds.maxY]
|
|
2465
2592
|
);
|
|
2466
2593
|
const rectHeight = Math.abs(screenMaxY - screenMinY);
|
|
@@ -2488,8 +2615,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2488
2615
|
name: "path",
|
|
2489
2616
|
attributes: {
|
|
2490
2617
|
d: points.map((p, i) => {
|
|
2491
|
-
const [x, y] =
|
|
2492
|
-
|
|
2618
|
+
const [x, y] = applyToPoint25(
|
|
2619
|
+
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
2493
2620
|
[p.x, p.y]
|
|
2494
2621
|
);
|
|
2495
2622
|
return `${i === 0 ? "M" : "L"} ${x} ${y}`;
|
|
@@ -2503,8 +2630,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2503
2630
|
});
|
|
2504
2631
|
}
|
|
2505
2632
|
for (const text of texts) {
|
|
2506
|
-
const screenTextPos =
|
|
2507
|
-
|
|
2633
|
+
const screenTextPos = applyToPoint25(
|
|
2634
|
+
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
2508
2635
|
text
|
|
2509
2636
|
);
|
|
2510
2637
|
let textValue = "";
|
|
@@ -2549,11 +2676,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2549
2676
|
});
|
|
2550
2677
|
}
|
|
2551
2678
|
for (const box of boxes) {
|
|
2552
|
-
const screenBoxPos =
|
|
2553
|
-
|
|
2679
|
+
const screenBoxPos = applyToPoint25(
|
|
2680
|
+
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
2554
2681
|
box
|
|
2555
2682
|
);
|
|
2556
|
-
const symbolToScreenScale =
|
|
2683
|
+
const symbolToScreenScale = compose7(
|
|
2557
2684
|
realToScreenTransform,
|
|
2558
2685
|
transformFromSymbolToReal
|
|
2559
2686
|
).a;
|
|
@@ -2572,8 +2699,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2572
2699
|
});
|
|
2573
2700
|
}
|
|
2574
2701
|
for (const port of symbol.ports) {
|
|
2575
|
-
const screenPortPos =
|
|
2576
|
-
|
|
2702
|
+
const screenPortPos = applyToPoint25(
|
|
2703
|
+
compose7(realToScreenTransform, transformFromSymbolToReal),
|
|
2577
2704
|
port
|
|
2578
2705
|
);
|
|
2579
2706
|
svgObjects.push({
|
|
@@ -2598,14 +2725,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2598
2725
|
import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
2599
2726
|
import "schematic-symbols";
|
|
2600
2727
|
import "svgson";
|
|
2601
|
-
import { applyToPoint as
|
|
2728
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
2602
2729
|
|
|
2603
2730
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
2604
2731
|
import "transformation-matrix";
|
|
2605
2732
|
import "@tscircuit/circuit-json-util";
|
|
2606
2733
|
|
|
2607
2734
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
2608
|
-
import { applyToPoint as
|
|
2735
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
2609
2736
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
2610
2737
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
2611
2738
|
var createSvgObjectsForSchPortBoxLine = ({
|
|
@@ -2635,8 +2762,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
2635
2762
|
realEdgePos.y += realPinLineLength;
|
|
2636
2763
|
break;
|
|
2637
2764
|
}
|
|
2638
|
-
const screenSchPortPos =
|
|
2639
|
-
const screenRealEdgePos =
|
|
2765
|
+
const screenSchPortPos = applyToPoint26(transform, schPort.center);
|
|
2766
|
+
const screenRealEdgePos = applyToPoint26(transform, realEdgePos);
|
|
2640
2767
|
const realLineEnd = { ...schPort.center };
|
|
2641
2768
|
switch (schPort.side_of_component) {
|
|
2642
2769
|
case "left":
|
|
@@ -2652,7 +2779,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
2652
2779
|
realLineEnd.y += PIN_CIRCLE_RADIUS_MM;
|
|
2653
2780
|
break;
|
|
2654
2781
|
}
|
|
2655
|
-
const screenLineEnd =
|
|
2782
|
+
const screenLineEnd = applyToPoint26(transform, realLineEnd);
|
|
2656
2783
|
svgObjects.push({
|
|
2657
2784
|
name: "line",
|
|
2658
2785
|
type: "element",
|
|
@@ -2699,7 +2826,7 @@ var getUnitVectorFromOutsideToEdge = (side) => {
|
|
|
2699
2826
|
};
|
|
2700
2827
|
|
|
2701
2828
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
2702
|
-
import { applyToPoint as
|
|
2829
|
+
import { applyToPoint as applyToPoint27 } from "transformation-matrix";
|
|
2703
2830
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
2704
2831
|
const svgObjects = [];
|
|
2705
2832
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -2717,7 +2844,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
2717
2844
|
} else {
|
|
2718
2845
|
realPinNumberPos.y += 0.02;
|
|
2719
2846
|
}
|
|
2720
|
-
const screenPinNumberTextPos =
|
|
2847
|
+
const screenPinNumberTextPos = applyToPoint27(transform, realPinNumberPos);
|
|
2721
2848
|
svgObjects.push({
|
|
2722
2849
|
name: "text",
|
|
2723
2850
|
type: "element",
|
|
@@ -2747,7 +2874,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
2747
2874
|
};
|
|
2748
2875
|
|
|
2749
2876
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
2750
|
-
import { applyToPoint as
|
|
2877
|
+
import { applyToPoint as applyToPoint28 } from "transformation-matrix";
|
|
2751
2878
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
2752
2879
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
2753
2880
|
const svgObjects = [];
|
|
@@ -2761,7 +2888,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
2761
2888
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
2762
2889
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
2763
2890
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
2764
|
-
const screenPinNumberTextPos =
|
|
2891
|
+
const screenPinNumberTextPos = applyToPoint28(transform, realPinNumberPos);
|
|
2765
2892
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
2766
2893
|
if (!label) return [];
|
|
2767
2894
|
svgObjects.push({
|
|
@@ -2803,26 +2930,42 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
2803
2930
|
};
|
|
2804
2931
|
|
|
2805
2932
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
2806
|
-
import { applyToPoint as
|
|
2933
|
+
import { applyToPoint as applyToPoint30 } from "transformation-matrix";
|
|
2807
2934
|
var createSvgSchText = ({
|
|
2808
2935
|
elm,
|
|
2809
2936
|
transform,
|
|
2810
2937
|
colorMap: colorMap2
|
|
2811
2938
|
}) => {
|
|
2812
|
-
const center =
|
|
2939
|
+
const center = applyToPoint30(transform, elm.position);
|
|
2813
2940
|
const textAnchorMap = {
|
|
2814
2941
|
center: "middle",
|
|
2815
2942
|
left: "start",
|
|
2816
2943
|
right: "end",
|
|
2817
2944
|
top: "middle",
|
|
2818
|
-
bottom: "middle"
|
|
2945
|
+
bottom: "middle",
|
|
2946
|
+
top_left: "start",
|
|
2947
|
+
top_center: "middle",
|
|
2948
|
+
top_right: "end",
|
|
2949
|
+
center_left: "start",
|
|
2950
|
+
center_right: "end",
|
|
2951
|
+
bottom_left: "start",
|
|
2952
|
+
bottom_center: "middle",
|
|
2953
|
+
bottom_right: "end"
|
|
2819
2954
|
};
|
|
2820
2955
|
const dominantBaselineMap = {
|
|
2821
2956
|
center: "middle",
|
|
2822
2957
|
left: "middle",
|
|
2823
2958
|
right: "middle",
|
|
2824
2959
|
top: "hanging",
|
|
2825
|
-
bottom: "ideographic"
|
|
2960
|
+
bottom: "ideographic",
|
|
2961
|
+
top_left: "hanging",
|
|
2962
|
+
top_center: "hanging",
|
|
2963
|
+
top_right: "hanging",
|
|
2964
|
+
center_left: "middle",
|
|
2965
|
+
center_right: "middle",
|
|
2966
|
+
bottom_left: "ideographic",
|
|
2967
|
+
bottom_center: "ideographic",
|
|
2968
|
+
bottom_right: "ideographic"
|
|
2826
2969
|
};
|
|
2827
2970
|
return {
|
|
2828
2971
|
type: "element",
|
|
@@ -2858,11 +3001,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
2858
3001
|
colorMap: colorMap2
|
|
2859
3002
|
}) => {
|
|
2860
3003
|
const svgObjects = [];
|
|
2861
|
-
const componentScreenTopLeft =
|
|
3004
|
+
const componentScreenTopLeft = applyToPoint31(transform, {
|
|
2862
3005
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
2863
3006
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
2864
3007
|
});
|
|
2865
|
-
const componentScreenBottomRight =
|
|
3008
|
+
const componentScreenBottomRight = applyToPoint31(transform, {
|
|
2866
3009
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
2867
3010
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
2868
3011
|
});
|
|
@@ -2945,13 +3088,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
2945
3088
|
}
|
|
2946
3089
|
|
|
2947
3090
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
2948
|
-
import { applyToPoint as
|
|
3091
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
2949
3092
|
function createSvgObjectsFromSchVoltageProbe({
|
|
2950
3093
|
probe,
|
|
2951
3094
|
transform,
|
|
2952
3095
|
colorMap: colorMap2
|
|
2953
3096
|
}) {
|
|
2954
|
-
const [screenX, screenY] =
|
|
3097
|
+
const [screenX, screenY] = applyToPoint32(transform, [
|
|
2955
3098
|
probe.position.x,
|
|
2956
3099
|
probe.position.y
|
|
2957
3100
|
]);
|
|
@@ -3011,17 +3154,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
3011
3154
|
}
|
|
3012
3155
|
|
|
3013
3156
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
3014
|
-
import { applyToPoint as
|
|
3157
|
+
import { applyToPoint as applyToPoint33 } from "transformation-matrix";
|
|
3015
3158
|
function createSvgObjectsFromSchDebugObject({
|
|
3016
3159
|
debugObject,
|
|
3017
3160
|
transform
|
|
3018
3161
|
}) {
|
|
3019
3162
|
if (debugObject.shape === "rect") {
|
|
3020
|
-
let [screenLeft, screenTop] =
|
|
3163
|
+
let [screenLeft, screenTop] = applyToPoint33(transform, [
|
|
3021
3164
|
debugObject.center.x - debugObject.size.width / 2,
|
|
3022
3165
|
debugObject.center.y - debugObject.size.height / 2
|
|
3023
3166
|
]);
|
|
3024
|
-
let [screenRight, screenBottom] =
|
|
3167
|
+
let [screenRight, screenBottom] = applyToPoint33(transform, [
|
|
3025
3168
|
debugObject.center.x + debugObject.size.width / 2,
|
|
3026
3169
|
debugObject.center.y + debugObject.size.height / 2
|
|
3027
3170
|
]);
|
|
@@ -3031,7 +3174,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
3031
3174
|
];
|
|
3032
3175
|
const width = Math.abs(screenRight - screenLeft);
|
|
3033
3176
|
const height = Math.abs(screenBottom - screenTop);
|
|
3034
|
-
const [screenCenterX, screenCenterY] =
|
|
3177
|
+
const [screenCenterX, screenCenterY] = applyToPoint33(transform, [
|
|
3035
3178
|
debugObject.center.x,
|
|
3036
3179
|
debugObject.center.y
|
|
3037
3180
|
]);
|
|
@@ -3077,11 +3220,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
3077
3220
|
];
|
|
3078
3221
|
}
|
|
3079
3222
|
if (debugObject.shape === "line") {
|
|
3080
|
-
const [screenStartX, screenStartY] =
|
|
3223
|
+
const [screenStartX, screenStartY] = applyToPoint33(transform, [
|
|
3081
3224
|
debugObject.start.x,
|
|
3082
3225
|
debugObject.start.y
|
|
3083
3226
|
]);
|
|
3084
|
-
const [screenEndX, screenEndY] =
|
|
3227
|
+
const [screenEndX, screenEndY] = applyToPoint33(transform, [
|
|
3085
3228
|
debugObject.end.x,
|
|
3086
3229
|
debugObject.end.y
|
|
3087
3230
|
]);
|
|
@@ -3131,7 +3274,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
3131
3274
|
}
|
|
3132
3275
|
|
|
3133
3276
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
3134
|
-
import { applyToPoint as
|
|
3277
|
+
import { applyToPoint as applyToPoint34 } from "transformation-matrix";
|
|
3135
3278
|
function createSchematicTrace({
|
|
3136
3279
|
trace,
|
|
3137
3280
|
transform,
|
|
@@ -3144,11 +3287,11 @@ function createSchematicTrace({
|
|
|
3144
3287
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
3145
3288
|
const edge = edges[edgeIndex];
|
|
3146
3289
|
if (edge.is_crossing) continue;
|
|
3147
|
-
const [screenFromX, screenFromY] =
|
|
3290
|
+
const [screenFromX, screenFromY] = applyToPoint34(transform, [
|
|
3148
3291
|
edge.from.x,
|
|
3149
3292
|
edge.from.y
|
|
3150
3293
|
]);
|
|
3151
|
-
const [screenToX, screenToY] =
|
|
3294
|
+
const [screenToX, screenToY] = applyToPoint34(transform, [
|
|
3152
3295
|
edge.to.x,
|
|
3153
3296
|
edge.to.y
|
|
3154
3297
|
]);
|
|
@@ -3160,11 +3303,11 @@ function createSchematicTrace({
|
|
|
3160
3303
|
}
|
|
3161
3304
|
for (const edge of edges) {
|
|
3162
3305
|
if (!edge.is_crossing) continue;
|
|
3163
|
-
const [screenFromX, screenFromY] =
|
|
3306
|
+
const [screenFromX, screenFromY] = applyToPoint34(transform, [
|
|
3164
3307
|
edge.from.x,
|
|
3165
3308
|
edge.from.y
|
|
3166
3309
|
]);
|
|
3167
|
-
const [screenToX, screenToY] =
|
|
3310
|
+
const [screenToX, screenToY] = applyToPoint34(transform, [
|
|
3168
3311
|
edge.to.x,
|
|
3169
3312
|
edge.to.y
|
|
3170
3313
|
]);
|
|
@@ -3240,7 +3383,7 @@ function createSchematicTrace({
|
|
|
3240
3383
|
}
|
|
3241
3384
|
if (trace.junctions) {
|
|
3242
3385
|
for (const junction of trace.junctions) {
|
|
3243
|
-
const [screenX, screenY] =
|
|
3386
|
+
const [screenX, screenY] = applyToPoint34(transform, [
|
|
3244
3387
|
junction.x,
|
|
3245
3388
|
junction.y
|
|
3246
3389
|
]);
|
|
@@ -3275,11 +3418,11 @@ function createSchematicTrace({
|
|
|
3275
3418
|
|
|
3276
3419
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
3277
3420
|
import {
|
|
3278
|
-
applyToPoint as
|
|
3279
|
-
compose as
|
|
3280
|
-
rotate as
|
|
3421
|
+
applyToPoint as applyToPoint36,
|
|
3422
|
+
compose as compose9,
|
|
3423
|
+
rotate as rotate5,
|
|
3281
3424
|
scale as scale6,
|
|
3282
|
-
translate as
|
|
3425
|
+
translate as translate9
|
|
3283
3426
|
} from "transformation-matrix";
|
|
3284
3427
|
|
|
3285
3428
|
// lib/sch/arial-text-metrics.ts
|
|
@@ -4063,11 +4206,11 @@ var estimateTextWidth = (text) => {
|
|
|
4063
4206
|
|
|
4064
4207
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
4065
4208
|
import {
|
|
4066
|
-
applyToPoint as
|
|
4067
|
-
compose as
|
|
4068
|
-
rotate as
|
|
4209
|
+
applyToPoint as applyToPoint35,
|
|
4210
|
+
compose as compose8,
|
|
4211
|
+
rotate as rotate4,
|
|
4069
4212
|
scale as scale5,
|
|
4070
|
-
translate as
|
|
4213
|
+
translate as translate8
|
|
4071
4214
|
} from "transformation-matrix";
|
|
4072
4215
|
import { symbols as symbols3 } from "schematic-symbols";
|
|
4073
4216
|
|
|
@@ -4160,7 +4303,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4160
4303
|
bottom: 90,
|
|
4161
4304
|
right: 180
|
|
4162
4305
|
}[schNetLabel.anchor_side];
|
|
4163
|
-
const rotationMatrix =
|
|
4306
|
+
const rotationMatrix = rotate4(pathRotation / 180 * Math.PI);
|
|
4164
4307
|
const symbolBounds = {
|
|
4165
4308
|
minX: Math.min(
|
|
4166
4309
|
...symbol.primitives.flatMap(
|
|
@@ -4187,9 +4330,9 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4187
4330
|
x: symbolBounds.minX,
|
|
4188
4331
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
4189
4332
|
};
|
|
4190
|
-
const rotatedSymbolEnd =
|
|
4191
|
-
const symbolToRealTransform =
|
|
4192
|
-
|
|
4333
|
+
const rotatedSymbolEnd = applyToPoint35(rotationMatrix, symbolEndPoint);
|
|
4334
|
+
const symbolToRealTransform = compose8(
|
|
4335
|
+
translate8(
|
|
4193
4336
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
4194
4337
|
realAnchorPosition.y - rotatedSymbolEnd.y
|
|
4195
4338
|
),
|
|
@@ -4197,12 +4340,12 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4197
4340
|
scale5(1)
|
|
4198
4341
|
// Use full symbol size
|
|
4199
4342
|
);
|
|
4200
|
-
const [screenMinX, screenMinY] =
|
|
4201
|
-
|
|
4343
|
+
const [screenMinX, screenMinY] = applyToPoint35(
|
|
4344
|
+
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4202
4345
|
[bounds.minX, bounds.minY]
|
|
4203
4346
|
);
|
|
4204
|
-
const [screenMaxX, screenMaxY] =
|
|
4205
|
-
|
|
4347
|
+
const [screenMaxX, screenMaxY] = applyToPoint35(
|
|
4348
|
+
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4206
4349
|
[bounds.maxX, bounds.maxY]
|
|
4207
4350
|
);
|
|
4208
4351
|
const rectHeight = Math.abs(screenMaxY - screenMinY);
|
|
@@ -4225,8 +4368,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4225
4368
|
});
|
|
4226
4369
|
for (const path of symbolPaths) {
|
|
4227
4370
|
const symbolPath = path.points.map((p, i) => {
|
|
4228
|
-
const [x, y] =
|
|
4229
|
-
|
|
4371
|
+
const [x, y] = applyToPoint35(
|
|
4372
|
+
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4230
4373
|
[p.x, p.y]
|
|
4231
4374
|
);
|
|
4232
4375
|
return `${i === 0 ? "M" : "L"} ${x} ${y}`;
|
|
@@ -4245,8 +4388,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4245
4388
|
});
|
|
4246
4389
|
}
|
|
4247
4390
|
for (const text of symbolTexts) {
|
|
4248
|
-
const screenTextPos =
|
|
4249
|
-
|
|
4391
|
+
const screenTextPos = applyToPoint35(
|
|
4392
|
+
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4250
4393
|
text
|
|
4251
4394
|
);
|
|
4252
4395
|
let textValue = text.text;
|
|
@@ -4287,11 +4430,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4287
4430
|
});
|
|
4288
4431
|
}
|
|
4289
4432
|
for (const box of symbolBoxes) {
|
|
4290
|
-
const screenBoxPos =
|
|
4291
|
-
|
|
4433
|
+
const screenBoxPos = applyToPoint35(
|
|
4434
|
+
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4292
4435
|
box
|
|
4293
4436
|
);
|
|
4294
|
-
const symbolToScreenScale =
|
|
4437
|
+
const symbolToScreenScale = compose8(
|
|
4295
4438
|
realToScreenTransform,
|
|
4296
4439
|
symbolToRealTransform
|
|
4297
4440
|
).a;
|
|
@@ -4310,11 +4453,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
4310
4453
|
});
|
|
4311
4454
|
}
|
|
4312
4455
|
for (const circle of symbolCircles) {
|
|
4313
|
-
const screenCirclePos =
|
|
4314
|
-
|
|
4456
|
+
const screenCirclePos = applyToPoint35(
|
|
4457
|
+
compose8(realToScreenTransform, symbolToRealTransform),
|
|
4315
4458
|
circle
|
|
4316
4459
|
);
|
|
4317
|
-
const symbolToScreenScale =
|
|
4460
|
+
const symbolToScreenScale = compose8(
|
|
4318
4461
|
realToScreenTransform,
|
|
4319
4462
|
symbolToRealTransform
|
|
4320
4463
|
).a;
|
|
@@ -4354,14 +4497,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4354
4497
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
4355
4498
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
4356
4499
|
const textWidthFSR = estimateTextWidth(schNetLabel.text || "");
|
|
4357
|
-
const screenCenter =
|
|
4500
|
+
const screenCenter = applyToPoint36(realToScreenTransform, schNetLabel.center);
|
|
4358
4501
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
4359
4502
|
schNetLabel.anchor_side
|
|
4360
4503
|
);
|
|
4361
4504
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
4362
4505
|
screenTextGrowthVec.y *= -1;
|
|
4363
4506
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + END_PADDING_FSR;
|
|
4364
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
4507
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint36(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
4365
4508
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
4366
4509
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
4367
4510
|
};
|
|
@@ -4402,12 +4545,12 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
4402
4545
|
y: -0.6
|
|
4403
4546
|
}
|
|
4404
4547
|
].map(
|
|
4405
|
-
(fontRelativePoint) =>
|
|
4406
|
-
|
|
4548
|
+
(fontRelativePoint) => applyToPoint36(
|
|
4549
|
+
compose9(
|
|
4407
4550
|
realToScreenTransform,
|
|
4408
|
-
|
|
4551
|
+
translate9(realAnchorPosition.x, realAnchorPosition.y),
|
|
4409
4552
|
scale6(fontSizeMm),
|
|
4410
|
-
|
|
4553
|
+
rotate5(pathRotation / 180 * Math.PI)
|
|
4411
4554
|
),
|
|
4412
4555
|
fontRelativePoint
|
|
4413
4556
|
)
|
|
@@ -4670,16 +4813,16 @@ var circuitJsonToSchematicSvg = convertCircuitJsonToSchematicSvg;
|
|
|
4670
4813
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
4671
4814
|
import { stringify as stringify4 } from "svgson";
|
|
4672
4815
|
import {
|
|
4673
|
-
applyToPoint as
|
|
4674
|
-
compose as
|
|
4816
|
+
applyToPoint as applyToPoint39,
|
|
4817
|
+
compose as compose11,
|
|
4675
4818
|
scale as scale8,
|
|
4676
|
-
translate as
|
|
4819
|
+
translate as translate11
|
|
4677
4820
|
} from "transformation-matrix";
|
|
4678
4821
|
|
|
4679
4822
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
4680
|
-
import { applyToPoint as
|
|
4823
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
4681
4824
|
function createSvgObjectsFromSolderPaste(solderPaste, transform) {
|
|
4682
|
-
const [x, y] =
|
|
4825
|
+
const [x, y] = applyToPoint38(transform, [solderPaste.x, solderPaste.y]);
|
|
4683
4826
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
4684
4827
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
4685
4828
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -4787,8 +4930,8 @@ function convertCircuitJsonToSolderPasteMask(soup, options) {
|
|
|
4787
4930
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
4788
4931
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
4789
4932
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
4790
|
-
const transform =
|
|
4791
|
-
|
|
4933
|
+
const transform = compose11(
|
|
4934
|
+
translate11(
|
|
4792
4935
|
offsetX - minX * scaleFactor + padding * scaleFactor,
|
|
4793
4936
|
svgHeight - offsetY + minY * scaleFactor - padding * scaleFactor
|
|
4794
4937
|
),
|
|
@@ -4868,8 +5011,8 @@ function createSvgObjects3(elm, transform) {
|
|
|
4868
5011
|
}
|
|
4869
5012
|
}
|
|
4870
5013
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
4871
|
-
const [x1, y1] =
|
|
4872
|
-
const [x2, y2] =
|
|
5014
|
+
const [x1, y1] = applyToPoint39(transform, [minX, minY]);
|
|
5015
|
+
const [x2, y2] = applyToPoint39(transform, [maxX, maxY]);
|
|
4873
5016
|
const width = Math.abs(x2 - x1);
|
|
4874
5017
|
const height = Math.abs(y2 - y1);
|
|
4875
5018
|
const x = Math.min(x1, x2);
|