circuit-to-svg 0.0.185 → 0.0.187
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 +281 -147
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
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 applyToPoint20,
|
|
5
|
+
compose as compose5,
|
|
6
6
|
scale as scale2,
|
|
7
|
-
translate as
|
|
7
|
+
translate as translate5
|
|
8
8
|
} from "transformation-matrix";
|
|
9
9
|
|
|
10
10
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace-error.ts
|
|
@@ -1446,12 +1446,133 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
1446
1446
|
return [];
|
|
1447
1447
|
}
|
|
1448
1448
|
|
|
1449
|
-
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-
|
|
1449
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-copper-pour.ts
|
|
1450
|
+
import {
|
|
1451
|
+
applyToPoint as applyToPoint18,
|
|
1452
|
+
compose as compose4,
|
|
1453
|
+
rotate as rotate4,
|
|
1454
|
+
toString as matrixToString7,
|
|
1455
|
+
translate as translate4
|
|
1456
|
+
} from "transformation-matrix";
|
|
1457
|
+
|
|
1458
|
+
// lib/utils/ring-to-path-d.ts
|
|
1450
1459
|
import { applyToPoint as applyToPoint17 } from "transformation-matrix";
|
|
1460
|
+
function ringToPathD(vertices, transform) {
|
|
1461
|
+
if (vertices.length === 0) return "";
|
|
1462
|
+
const transformedVertices = vertices.map((v) => {
|
|
1463
|
+
const [x, y] = applyToPoint17(transform, [v.x, v.y]);
|
|
1464
|
+
return { ...v, x, y };
|
|
1465
|
+
});
|
|
1466
|
+
let d = `M ${transformedVertices[0].x} ${transformedVertices[0].y}`;
|
|
1467
|
+
for (let i = 0; i < transformedVertices.length; i++) {
|
|
1468
|
+
const start = transformedVertices[i];
|
|
1469
|
+
const end = transformedVertices[(i + 1) % transformedVertices.length];
|
|
1470
|
+
if (start.bulge) {
|
|
1471
|
+
if (Math.hypot(end.x - start.x, end.y - start.y) < 1e-9) continue;
|
|
1472
|
+
const bulge = start.bulge;
|
|
1473
|
+
const dx = end.x - start.x;
|
|
1474
|
+
const dy = end.y - start.y;
|
|
1475
|
+
const dist = Math.hypot(dx, dy);
|
|
1476
|
+
const radius = Math.abs(dist / 4 / bulge * (bulge * bulge + 1));
|
|
1477
|
+
const sweepFlag = bulge < 0 ? 0 : 1;
|
|
1478
|
+
const largeArcFlag = Math.abs(bulge) > 1 ? 1 : 0;
|
|
1479
|
+
d += ` A ${radius} ${radius} 0 ${largeArcFlag} ${sweepFlag} ${end.x} ${end.y}`;
|
|
1480
|
+
} else {
|
|
1481
|
+
d += ` L ${end.x} ${end.y}`;
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
d += " Z";
|
|
1485
|
+
return d;
|
|
1486
|
+
}
|
|
1487
|
+
|
|
1488
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-copper-pour.ts
|
|
1489
|
+
function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
1490
|
+
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1491
|
+
const { layer } = pour;
|
|
1492
|
+
if (layerFilter && layer !== layerFilter) return [];
|
|
1493
|
+
const color = layerNameToColor(layer, colorMap2);
|
|
1494
|
+
const opacity = "0.5";
|
|
1495
|
+
if (pour.shape === "rect") {
|
|
1496
|
+
const [cx, cy] = applyToPoint18(transform, [pour.center.x, pour.center.y]);
|
|
1497
|
+
const scaledWidth = pour.width * Math.abs(transform.a);
|
|
1498
|
+
const scaledHeight = pour.height * Math.abs(transform.d);
|
|
1499
|
+
const svgRotation = -(pour.rotation ?? 0);
|
|
1500
|
+
return [
|
|
1501
|
+
{
|
|
1502
|
+
name: "rect",
|
|
1503
|
+
type: "element",
|
|
1504
|
+
attributes: {
|
|
1505
|
+
class: "pcb-copper-pour pcb-copper-pour-rect",
|
|
1506
|
+
x: (-scaledWidth / 2).toString(),
|
|
1507
|
+
y: (-scaledHeight / 2).toString(),
|
|
1508
|
+
width: scaledWidth.toString(),
|
|
1509
|
+
height: scaledHeight.toString(),
|
|
1510
|
+
fill: color,
|
|
1511
|
+
"fill-opacity": opacity,
|
|
1512
|
+
transform: matrixToString7(
|
|
1513
|
+
compose4(translate4(cx, cy), rotate4(svgRotation * Math.PI / 180))
|
|
1514
|
+
),
|
|
1515
|
+
"data-layer": layer
|
|
1516
|
+
},
|
|
1517
|
+
children: [],
|
|
1518
|
+
value: ""
|
|
1519
|
+
}
|
|
1520
|
+
];
|
|
1521
|
+
}
|
|
1522
|
+
if (pour.shape === "polygon") {
|
|
1523
|
+
if (!pour.points || pour.points.length === 0) return [];
|
|
1524
|
+
const transformedPoints = pour.points.map(
|
|
1525
|
+
(p) => applyToPoint18(transform, [p.x, p.y])
|
|
1526
|
+
);
|
|
1527
|
+
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
1528
|
+
return [
|
|
1529
|
+
{
|
|
1530
|
+
name: "polygon",
|
|
1531
|
+
type: "element",
|
|
1532
|
+
attributes: {
|
|
1533
|
+
class: "pcb-copper-pour pcb-copper-pour-polygon",
|
|
1534
|
+
points: pointsString,
|
|
1535
|
+
fill: color,
|
|
1536
|
+
"fill-opacity": opacity,
|
|
1537
|
+
"data-layer": layer
|
|
1538
|
+
},
|
|
1539
|
+
children: [],
|
|
1540
|
+
value: ""
|
|
1541
|
+
}
|
|
1542
|
+
];
|
|
1543
|
+
}
|
|
1544
|
+
if (pour.shape === "brep") {
|
|
1545
|
+
const { brep_shape } = pour;
|
|
1546
|
+
let d = ringToPathD(brep_shape.outer_ring.vertices, transform);
|
|
1547
|
+
for (const inner_ring of brep_shape.inner_rings ?? []) {
|
|
1548
|
+
d += ` ${ringToPathD(inner_ring.vertices, transform)}`;
|
|
1549
|
+
}
|
|
1550
|
+
return [
|
|
1551
|
+
{
|
|
1552
|
+
name: "path",
|
|
1553
|
+
type: "element",
|
|
1554
|
+
attributes: {
|
|
1555
|
+
class: "pcb-copper-pour pcb-copper-pour-brep",
|
|
1556
|
+
d,
|
|
1557
|
+
fill: color,
|
|
1558
|
+
"fill-rule": "evenodd",
|
|
1559
|
+
"fill-opacity": opacity,
|
|
1560
|
+
"data-layer": layer
|
|
1561
|
+
},
|
|
1562
|
+
children: [],
|
|
1563
|
+
value: ""
|
|
1564
|
+
}
|
|
1565
|
+
];
|
|
1566
|
+
}
|
|
1567
|
+
return [];
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-component.ts
|
|
1571
|
+
import { applyToPoint as applyToPoint19 } from "transformation-matrix";
|
|
1451
1572
|
function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
1452
1573
|
const { transform } = ctx;
|
|
1453
1574
|
const { center, width, height, rotation = 0 } = component;
|
|
1454
|
-
const [x, y] =
|
|
1575
|
+
const [x, y] = applyToPoint19(transform, [center.x, center.y]);
|
|
1455
1576
|
const scaledWidth = width * Math.abs(transform.a);
|
|
1456
1577
|
const scaledHeight = height * Math.abs(transform.d);
|
|
1457
1578
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
@@ -1520,10 +1641,10 @@ var package_default = {
|
|
|
1520
1641
|
esbuild: "^0.20.2",
|
|
1521
1642
|
"performance-now": "^2.1.0",
|
|
1522
1643
|
react: "19.1.0",
|
|
1523
|
-
"react-dom": "19.1.0",
|
|
1524
1644
|
"react-cosmos": "7.0.0",
|
|
1525
1645
|
"react-cosmos-plugin-vite": "7.0.0",
|
|
1526
|
-
|
|
1646
|
+
"react-dom": "19.1.0",
|
|
1647
|
+
tscircuit: "^0.0.624",
|
|
1527
1648
|
tsup: "^8.0.2",
|
|
1528
1649
|
typescript: "^5.4.5",
|
|
1529
1650
|
"vite-tsconfig-paths": "^5.0.1"
|
|
@@ -1552,6 +1673,7 @@ var OBJECT_ORDER = [
|
|
|
1552
1673
|
"pcb_silkscreen_path",
|
|
1553
1674
|
"pcb_via",
|
|
1554
1675
|
"pcb_cutout",
|
|
1676
|
+
"pcb_copper_pour",
|
|
1555
1677
|
// Draw traces before SMT pads so pads appear on top
|
|
1556
1678
|
"pcb_smtpad",
|
|
1557
1679
|
"pcb_trace",
|
|
@@ -1622,6 +1744,16 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
1622
1744
|
updateTraceBounds(circuitJsonElm.route);
|
|
1623
1745
|
} else if (circuitJsonElm.type === "pcb_silkscreen_text" || circuitJsonElm.type === "pcb_silkscreen_rect" || circuitJsonElm.type === "pcb_silkscreen_circle" || circuitJsonElm.type === "pcb_silkscreen_line") {
|
|
1624
1746
|
updateSilkscreenBounds(circuitJsonElm);
|
|
1747
|
+
} else if (circuitJsonElm.type === "pcb_copper_pour") {
|
|
1748
|
+
if (circuitJsonElm.shape === "rect") {
|
|
1749
|
+
updateBounds(
|
|
1750
|
+
circuitJsonElm.center,
|
|
1751
|
+
circuitJsonElm.width,
|
|
1752
|
+
circuitJsonElm.height
|
|
1753
|
+
);
|
|
1754
|
+
} else if (circuitJsonElm.shape === "polygon") {
|
|
1755
|
+
updateTraceBounds(circuitJsonElm.points);
|
|
1756
|
+
}
|
|
1625
1757
|
}
|
|
1626
1758
|
}
|
|
1627
1759
|
const padding = drawPaddingOutsideBoard ? 1 : 0;
|
|
@@ -1658,8 +1790,8 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
1658
1790
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
1659
1791
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
1660
1792
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
1661
|
-
const transform =
|
|
1662
|
-
|
|
1793
|
+
const transform = compose5(
|
|
1794
|
+
translate5(
|
|
1663
1795
|
offsetX - boundsMinX * scaleFactor + padding * scaleFactor,
|
|
1664
1796
|
svgHeight - offsetY + boundsMinY * scaleFactor - padding * scaleFactor
|
|
1665
1797
|
),
|
|
@@ -1852,6 +1984,8 @@ function createSvgObjects({
|
|
|
1852
1984
|
return createSvgObjectsFromPcbComponent(elm, ctx).filter(Boolean);
|
|
1853
1985
|
case "pcb_trace":
|
|
1854
1986
|
return createSvgObjectsFromPcbTrace(elm, ctx);
|
|
1987
|
+
case "pcb_copper_pour":
|
|
1988
|
+
return createSvgObjectsFromPcbCopperPour(elm, ctx);
|
|
1855
1989
|
case "pcb_plated_hole":
|
|
1856
1990
|
return createSvgObjectsFromPcbPlatedHole(elm, ctx).filter(Boolean);
|
|
1857
1991
|
case "pcb_hole":
|
|
@@ -1883,8 +2017,8 @@ function createSvgObjects({
|
|
|
1883
2017
|
}
|
|
1884
2018
|
}
|
|
1885
2019
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
1886
|
-
const [x1, y1] =
|
|
1887
|
-
const [x2, y2] =
|
|
2020
|
+
const [x1, y1] = applyToPoint20(transform, [minX, minY]);
|
|
2021
|
+
const [x2, y2] = applyToPoint20(transform, [maxX, maxY]);
|
|
1888
2022
|
const width = Math.abs(x2 - x1);
|
|
1889
2023
|
const height = Math.abs(y2 - y1);
|
|
1890
2024
|
const x = Math.min(x1, x2);
|
|
@@ -1912,14 +2046,14 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
1912
2046
|
import { stringify as stringify2 } from "svgson";
|
|
1913
2047
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
1914
2048
|
import {
|
|
1915
|
-
applyToPoint as
|
|
1916
|
-
compose as
|
|
2049
|
+
applyToPoint as applyToPoint27,
|
|
2050
|
+
compose as compose6,
|
|
1917
2051
|
scale as scale3,
|
|
1918
|
-
translate as
|
|
2052
|
+
translate as translate6
|
|
1919
2053
|
} from "transformation-matrix";
|
|
1920
2054
|
|
|
1921
2055
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
1922
|
-
import { applyToPoint as
|
|
2056
|
+
import { applyToPoint as applyToPoint21 } from "transformation-matrix";
|
|
1923
2057
|
var DEFAULT_BOARD_STYLE = {
|
|
1924
2058
|
fill: "none",
|
|
1925
2059
|
stroke: "rgb(0,0,0)",
|
|
@@ -1931,25 +2065,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
1931
2065
|
let path;
|
|
1932
2066
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
1933
2067
|
path = outline.map((point, index) => {
|
|
1934
|
-
const [x, y] =
|
|
2068
|
+
const [x, y] = applyToPoint21(transform, [point.x, point.y]);
|
|
1935
2069
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
1936
2070
|
}).join(" ");
|
|
1937
2071
|
} else {
|
|
1938
2072
|
const halfWidth = width / 2;
|
|
1939
2073
|
const halfHeight = height / 2;
|
|
1940
|
-
const topLeft =
|
|
2074
|
+
const topLeft = applyToPoint21(transform, [
|
|
1941
2075
|
center.x - halfWidth,
|
|
1942
2076
|
center.y - halfHeight
|
|
1943
2077
|
]);
|
|
1944
|
-
const topRight =
|
|
2078
|
+
const topRight = applyToPoint21(transform, [
|
|
1945
2079
|
center.x + halfWidth,
|
|
1946
2080
|
center.y - halfHeight
|
|
1947
2081
|
]);
|
|
1948
|
-
const bottomRight =
|
|
2082
|
+
const bottomRight = applyToPoint21(transform, [
|
|
1949
2083
|
center.x + halfWidth,
|
|
1950
2084
|
center.y + halfHeight
|
|
1951
2085
|
]);
|
|
1952
|
-
const bottomLeft =
|
|
2086
|
+
const bottomLeft = applyToPoint21(transform, [
|
|
1953
2087
|
center.x - halfWidth,
|
|
1954
2088
|
center.y + halfHeight
|
|
1955
2089
|
]);
|
|
@@ -1975,7 +2109,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
1975
2109
|
}
|
|
1976
2110
|
|
|
1977
2111
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
1978
|
-
import { applyToPoint as
|
|
2112
|
+
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
1979
2113
|
|
|
1980
2114
|
// lib/utils/get-sch-font-size.ts
|
|
1981
2115
|
import "transformation-matrix";
|
|
@@ -2001,8 +2135,8 @@ function createSvgObjectsFromAssemblyComponent(params, ctx) {
|
|
|
2001
2135
|
const { center, width, height, rotation = 0, layer = "top" } = elm;
|
|
2002
2136
|
if (!center || typeof width !== "number" || typeof height !== "number")
|
|
2003
2137
|
return null;
|
|
2004
|
-
const [x, y] =
|
|
2005
|
-
const [pinX, pinY] =
|
|
2138
|
+
const [x, y] = applyToPoint23(transform, [center.x, center.y]);
|
|
2139
|
+
const [pinX, pinY] = applyToPoint23(transform, [portPosition.x, portPosition.y]);
|
|
2006
2140
|
const scaledWidth = width * Math.abs(transform.a);
|
|
2007
2141
|
const scaledHeight = height * Math.abs(transform.d);
|
|
2008
2142
|
const isTopLayer = layer === "top";
|
|
@@ -2164,11 +2298,11 @@ function getRectPathData(w, h, rotation) {
|
|
|
2164
2298
|
}
|
|
2165
2299
|
|
|
2166
2300
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-hole.ts
|
|
2167
|
-
import { applyToPoint as
|
|
2301
|
+
import { applyToPoint as applyToPoint24 } from "transformation-matrix";
|
|
2168
2302
|
var HOLE_COLOR2 = "rgb(190, 190, 190)";
|
|
2169
2303
|
function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
2170
2304
|
const { transform } = ctx;
|
|
2171
|
-
const [x, y] =
|
|
2305
|
+
const [x, y] = applyToPoint24(transform, [hole.x, hole.y]);
|
|
2172
2306
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
2173
2307
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
2174
2308
|
const radius = scaledDiameter / 2;
|
|
@@ -2232,12 +2366,12 @@ function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
|
2232
2366
|
}
|
|
2233
2367
|
|
|
2234
2368
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-plated-hole.ts
|
|
2235
|
-
import { applyToPoint as
|
|
2369
|
+
import { applyToPoint as applyToPoint25 } from "transformation-matrix";
|
|
2236
2370
|
var PAD_COLOR = "rgb(210, 210, 210)";
|
|
2237
2371
|
var HOLE_COLOR3 = "rgb(190, 190, 190)";
|
|
2238
2372
|
function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
2239
2373
|
const { transform } = ctx;
|
|
2240
|
-
const [x, y] =
|
|
2374
|
+
const [x, y] = applyToPoint25(transform, [hole.x, hole.y]);
|
|
2241
2375
|
if (hole.shape === "pill") {
|
|
2242
2376
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
2243
2377
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -2472,14 +2606,14 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
2472
2606
|
}
|
|
2473
2607
|
|
|
2474
2608
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-smt-pad.ts
|
|
2475
|
-
import { applyToPoint as
|
|
2609
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
2476
2610
|
var PAD_COLOR2 = "rgb(210, 210, 210)";
|
|
2477
2611
|
function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
2478
2612
|
const { transform } = ctx;
|
|
2479
2613
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
2480
2614
|
const width = pad.width * Math.abs(transform.a);
|
|
2481
2615
|
const height = pad.height * Math.abs(transform.d);
|
|
2482
|
-
const [x, y] =
|
|
2616
|
+
const [x, y] = applyToPoint26(transform, [pad.x, pad.y]);
|
|
2483
2617
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
2484
2618
|
return [
|
|
2485
2619
|
{
|
|
@@ -2522,7 +2656,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
2522
2656
|
const width = pad.width * Math.abs(transform.a);
|
|
2523
2657
|
const height = pad.height * Math.abs(transform.d);
|
|
2524
2658
|
const radius = pad.radius * Math.abs(transform.a);
|
|
2525
|
-
const [x, y] =
|
|
2659
|
+
const [x, y] = applyToPoint26(transform, [pad.x, pad.y]);
|
|
2526
2660
|
return [
|
|
2527
2661
|
{
|
|
2528
2662
|
name: "rect",
|
|
@@ -2545,7 +2679,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
2545
2679
|
}
|
|
2546
2680
|
if (pad.shape === "circle") {
|
|
2547
2681
|
const radius = pad.radius * Math.abs(transform.a);
|
|
2548
|
-
const [x, y] =
|
|
2682
|
+
const [x, y] = applyToPoint26(transform, [pad.x, pad.y]);
|
|
2549
2683
|
return [
|
|
2550
2684
|
{
|
|
2551
2685
|
name: "circle",
|
|
@@ -2565,7 +2699,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
2565
2699
|
}
|
|
2566
2700
|
if (pad.shape === "polygon") {
|
|
2567
2701
|
const points = (pad.points ?? []).map(
|
|
2568
|
-
(point) =>
|
|
2702
|
+
(point) => applyToPoint26(transform, [point.x, point.y])
|
|
2569
2703
|
);
|
|
2570
2704
|
return [
|
|
2571
2705
|
{
|
|
@@ -2619,8 +2753,8 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
2619
2753
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
2620
2754
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
2621
2755
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
2622
|
-
const transform =
|
|
2623
|
-
|
|
2756
|
+
const transform = compose6(
|
|
2757
|
+
translate6(
|
|
2624
2758
|
offsetX - minX * scaleFactor + padding * scaleFactor,
|
|
2625
2759
|
svgHeight - offsetY + minY * scaleFactor - padding * scaleFactor
|
|
2626
2760
|
),
|
|
@@ -2742,8 +2876,8 @@ function createSvgObjects2(elm, ctx, soup) {
|
|
|
2742
2876
|
}
|
|
2743
2877
|
}
|
|
2744
2878
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
2745
|
-
const [x1, y1] =
|
|
2746
|
-
const [x2, y2] =
|
|
2879
|
+
const [x1, y1] = applyToPoint27(transform, [minX, minY]);
|
|
2880
|
+
const [x2, y2] = applyToPoint27(transform, [maxX, maxY]);
|
|
2747
2881
|
const width = Math.abs(x2 - x1);
|
|
2748
2882
|
const height = Math.abs(y2 - y1);
|
|
2749
2883
|
const x = Math.min(x1, x2);
|
|
@@ -3010,14 +3144,14 @@ import {
|
|
|
3010
3144
|
} from "transformation-matrix";
|
|
3011
3145
|
|
|
3012
3146
|
// lib/sch/draw-schematic-grid.ts
|
|
3013
|
-
import { applyToPoint as
|
|
3147
|
+
import { applyToPoint as applyToPoint28 } from "transformation-matrix";
|
|
3014
3148
|
function drawSchematicGrid(params) {
|
|
3015
3149
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
3016
3150
|
const cellSize = params.cellSize ?? 1;
|
|
3017
3151
|
const labelCells = params.labelCells ?? false;
|
|
3018
3152
|
const gridLines = [];
|
|
3019
3153
|
const transformPoint = (x, y) => {
|
|
3020
|
-
const [transformedX, transformedY] =
|
|
3154
|
+
const [transformedX, transformedY] = applyToPoint28(params.transform, [x, y]);
|
|
3021
3155
|
return { x: transformedX, y: transformedY };
|
|
3022
3156
|
};
|
|
3023
3157
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -3098,15 +3232,15 @@ function drawSchematicGrid(params) {
|
|
|
3098
3232
|
}
|
|
3099
3233
|
|
|
3100
3234
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
3101
|
-
import { applyToPoint as
|
|
3235
|
+
import { applyToPoint as applyToPoint29 } from "transformation-matrix";
|
|
3102
3236
|
function drawSchematicLabeledPoints(params) {
|
|
3103
3237
|
const { points, transform } = params;
|
|
3104
3238
|
const labeledPointsGroup = [];
|
|
3105
3239
|
for (const point of points) {
|
|
3106
|
-
const [x1, y1] =
|
|
3107
|
-
const [x2, y2] =
|
|
3108
|
-
const [x3, y3] =
|
|
3109
|
-
const [x4, y4] =
|
|
3240
|
+
const [x1, y1] = applyToPoint29(transform, [point.x - 0.1, point.y - 0.1]);
|
|
3241
|
+
const [x2, y2] = applyToPoint29(transform, [point.x + 0.1, point.y + 0.1]);
|
|
3242
|
+
const [x3, y3] = applyToPoint29(transform, [point.x - 0.1, point.y + 0.1]);
|
|
3243
|
+
const [x4, y4] = applyToPoint29(transform, [point.x + 0.1, point.y - 0.1]);
|
|
3110
3244
|
labeledPointsGroup.push({
|
|
3111
3245
|
name: "path",
|
|
3112
3246
|
type: "element",
|
|
@@ -3117,7 +3251,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
3117
3251
|
"stroke-opacity": "0.7"
|
|
3118
3252
|
}
|
|
3119
3253
|
});
|
|
3120
|
-
const [labelX, labelY] =
|
|
3254
|
+
const [labelX, labelY] = applyToPoint29(transform, [
|
|
3121
3255
|
point.x + 0.15,
|
|
3122
3256
|
point.y - 0.15
|
|
3123
3257
|
]);
|
|
@@ -4190,8 +4324,8 @@ import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
|
4190
4324
|
import { symbols } from "schematic-symbols";
|
|
4191
4325
|
import "svgson";
|
|
4192
4326
|
import {
|
|
4193
|
-
applyToPoint as
|
|
4194
|
-
compose as
|
|
4327
|
+
applyToPoint as applyToPoint31,
|
|
4328
|
+
compose as compose8
|
|
4195
4329
|
} from "transformation-matrix";
|
|
4196
4330
|
|
|
4197
4331
|
// lib/utils/get-sch-stroke-size.ts
|
|
@@ -4261,26 +4395,26 @@ var matchSchPortsToSymbolPorts = ({
|
|
|
4261
4395
|
};
|
|
4262
4396
|
|
|
4263
4397
|
// lib/utils/point-pairs-to-matrix.ts
|
|
4264
|
-
import { compose as
|
|
4398
|
+
import { compose as compose7, scale as scale4, translate as translate7 } from "transformation-matrix";
|
|
4265
4399
|
function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
4266
4400
|
const tx = a2.x - a1.x;
|
|
4267
4401
|
const ty = a2.y - a1.y;
|
|
4268
4402
|
const originalDistance = Math.sqrt((b1.x - a1.x) ** 2 + (b1.y - a1.y) ** 2);
|
|
4269
4403
|
const transformedDistance = Math.sqrt((b2.x - a2.x) ** 2 + (b2.y - a2.y) ** 2);
|
|
4270
4404
|
const a = transformedDistance / originalDistance;
|
|
4271
|
-
const translateMatrix =
|
|
4405
|
+
const translateMatrix = translate7(tx, ty);
|
|
4272
4406
|
const scaleMatrix = scale4(a, a);
|
|
4273
|
-
return
|
|
4407
|
+
return compose7(translateMatrix, scaleMatrix);
|
|
4274
4408
|
}
|
|
4275
4409
|
|
|
4276
4410
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
4277
|
-
import { applyToPoint as
|
|
4411
|
+
import { applyToPoint as applyToPoint30 } from "transformation-matrix";
|
|
4278
4412
|
var createSvgSchErrorText = ({
|
|
4279
4413
|
text,
|
|
4280
4414
|
realCenter,
|
|
4281
4415
|
realToScreenTransform
|
|
4282
4416
|
}) => {
|
|
4283
|
-
const screenCenter =
|
|
4417
|
+
const screenCenter = applyToPoint30(realToScreenTransform, realCenter);
|
|
4284
4418
|
return {
|
|
4285
4419
|
type: "element",
|
|
4286
4420
|
name: "text",
|
|
@@ -4389,12 +4523,12 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
4389
4523
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
4390
4524
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
4391
4525
|
};
|
|
4392
|
-
const [screenMinX, screenMinY] =
|
|
4393
|
-
|
|
4526
|
+
const [screenMinX, screenMinY] = applyToPoint31(
|
|
4527
|
+
compose8(realToScreenTransform, transformFromSymbolToReal),
|
|
4394
4528
|
[bounds.minX, bounds.minY]
|
|
4395
4529
|
);
|
|
4396
|
-
const [screenMaxX, screenMaxY] =
|
|
4397
|
-
|
|
4530
|
+
const [screenMaxX, screenMaxY] = applyToPoint31(
|
|
4531
|
+
compose8(realToScreenTransform, transformFromSymbolToReal),
|
|
4398
4532
|
[bounds.maxX, bounds.maxY]
|
|
4399
4533
|
);
|
|
4400
4534
|
const rectHeight = Math.abs(screenMaxY - screenMinY);
|
|
@@ -4422,8 +4556,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
4422
4556
|
name: "path",
|
|
4423
4557
|
attributes: {
|
|
4424
4558
|
d: points.map((p, i) => {
|
|
4425
|
-
const [x, y] =
|
|
4426
|
-
|
|
4559
|
+
const [x, y] = applyToPoint31(
|
|
4560
|
+
compose8(realToScreenTransform, transformFromSymbolToReal),
|
|
4427
4561
|
[p.x, p.y]
|
|
4428
4562
|
);
|
|
4429
4563
|
return `${i === 0 ? "M" : "L"} ${x} ${y}`;
|
|
@@ -4438,8 +4572,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
4438
4572
|
});
|
|
4439
4573
|
}
|
|
4440
4574
|
for (const text of texts) {
|
|
4441
|
-
const screenTextPos =
|
|
4442
|
-
|
|
4575
|
+
const screenTextPos = applyToPoint31(
|
|
4576
|
+
compose8(realToScreenTransform, transformFromSymbolToReal),
|
|
4443
4577
|
text
|
|
4444
4578
|
);
|
|
4445
4579
|
let textValue = "";
|
|
@@ -4490,11 +4624,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
4490
4624
|
});
|
|
4491
4625
|
}
|
|
4492
4626
|
for (const box of boxes) {
|
|
4493
|
-
const screenBoxPos =
|
|
4494
|
-
|
|
4627
|
+
const screenBoxPos = applyToPoint31(
|
|
4628
|
+
compose8(realToScreenTransform, transformFromSymbolToReal),
|
|
4495
4629
|
box
|
|
4496
4630
|
);
|
|
4497
|
-
const symbolToScreenScale =
|
|
4631
|
+
const symbolToScreenScale = compose8(
|
|
4498
4632
|
realToScreenTransform,
|
|
4499
4633
|
transformFromSymbolToReal
|
|
4500
4634
|
).a;
|
|
@@ -4514,8 +4648,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
4514
4648
|
}
|
|
4515
4649
|
for (const port of symbol.ports) {
|
|
4516
4650
|
if (connectedSymbolPorts.has(port)) continue;
|
|
4517
|
-
const screenPortPos =
|
|
4518
|
-
|
|
4651
|
+
const screenPortPos = applyToPoint31(
|
|
4652
|
+
compose8(realToScreenTransform, transformFromSymbolToReal),
|
|
4519
4653
|
port
|
|
4520
4654
|
);
|
|
4521
4655
|
svgObjects.push({
|
|
@@ -4534,8 +4668,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
4534
4668
|
});
|
|
4535
4669
|
}
|
|
4536
4670
|
for (const circle of circles) {
|
|
4537
|
-
const screenCirclePos =
|
|
4538
|
-
|
|
4671
|
+
const screenCirclePos = applyToPoint31(
|
|
4672
|
+
compose8(realToScreenTransform, transformFromSymbolToReal),
|
|
4539
4673
|
circle
|
|
4540
4674
|
);
|
|
4541
4675
|
const screenRadius = Math.abs(circle.radius * realToScreenTransform.a);
|
|
@@ -4561,14 +4695,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
4561
4695
|
import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
4562
4696
|
import "schematic-symbols";
|
|
4563
4697
|
import "svgson";
|
|
4564
|
-
import { applyToPoint as
|
|
4698
|
+
import { applyToPoint as applyToPoint37 } from "transformation-matrix";
|
|
4565
4699
|
|
|
4566
4700
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
4567
4701
|
import "transformation-matrix";
|
|
4568
4702
|
import "@tscircuit/circuit-json-util";
|
|
4569
4703
|
|
|
4570
4704
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
4571
|
-
import { applyToPoint as
|
|
4705
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
4572
4706
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
4573
4707
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
4574
4708
|
var createArrow = (tip, angle, size, color, strokeWidth) => {
|
|
@@ -4621,8 +4755,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
4621
4755
|
realEdgePos.y += realPinLineLength;
|
|
4622
4756
|
break;
|
|
4623
4757
|
}
|
|
4624
|
-
const screenSchPortPos =
|
|
4625
|
-
const screenRealEdgePos =
|
|
4758
|
+
const screenSchPortPos = applyToPoint32(transform, schPort.center);
|
|
4759
|
+
const screenRealEdgePos = applyToPoint32(transform, realEdgePos);
|
|
4626
4760
|
const realLineEnd = { ...schPort.center };
|
|
4627
4761
|
switch (schPort.side_of_component) {
|
|
4628
4762
|
case "left":
|
|
@@ -4638,7 +4772,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
4638
4772
|
realLineEnd.y += PIN_CIRCLE_RADIUS_MM;
|
|
4639
4773
|
break;
|
|
4640
4774
|
}
|
|
4641
|
-
const screenLineEnd =
|
|
4775
|
+
const screenLineEnd = applyToPoint32(transform, realLineEnd);
|
|
4642
4776
|
svgObjects.push({
|
|
4643
4777
|
name: "line",
|
|
4644
4778
|
type: "element",
|
|
@@ -4760,7 +4894,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
4760
4894
|
};
|
|
4761
4895
|
|
|
4762
4896
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
4763
|
-
import { applyToPoint as
|
|
4897
|
+
import { applyToPoint as applyToPoint33 } from "transformation-matrix";
|
|
4764
4898
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
4765
4899
|
const svgObjects = [];
|
|
4766
4900
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -4778,7 +4912,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
4778
4912
|
} else {
|
|
4779
4913
|
realPinNumberPos.y += 0.02;
|
|
4780
4914
|
}
|
|
4781
|
-
const screenPinNumberTextPos =
|
|
4915
|
+
const screenPinNumberTextPos = applyToPoint33(transform, realPinNumberPos);
|
|
4782
4916
|
svgObjects.push({
|
|
4783
4917
|
name: "text",
|
|
4784
4918
|
type: "element",
|
|
@@ -4808,7 +4942,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
4808
4942
|
};
|
|
4809
4943
|
|
|
4810
4944
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
4811
|
-
import { applyToPoint as
|
|
4945
|
+
import { applyToPoint as applyToPoint34 } from "transformation-matrix";
|
|
4812
4946
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
4813
4947
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
4814
4948
|
const svgObjects = [];
|
|
@@ -4822,7 +4956,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
4822
4956
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
4823
4957
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
4824
4958
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
4825
|
-
const screenPinNumberTextPos =
|
|
4959
|
+
const screenPinNumberTextPos = applyToPoint34(transform, realPinNumberPos);
|
|
4826
4960
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
4827
4961
|
if (!label) return [];
|
|
4828
4962
|
const isNegated = label.startsWith("N_");
|
|
@@ -4870,13 +5004,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
4870
5004
|
};
|
|
4871
5005
|
|
|
4872
5006
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
4873
|
-
import { applyToPoint as
|
|
5007
|
+
import { applyToPoint as applyToPoint36 } from "transformation-matrix";
|
|
4874
5008
|
var createSvgSchText = ({
|
|
4875
5009
|
elm,
|
|
4876
5010
|
transform,
|
|
4877
5011
|
colorMap: colorMap2
|
|
4878
5012
|
}) => {
|
|
4879
|
-
const center =
|
|
5013
|
+
const center = applyToPoint36(transform, elm.position);
|
|
4880
5014
|
const textAnchorMap = {
|
|
4881
5015
|
center: "middle",
|
|
4882
5016
|
center_right: "end",
|
|
@@ -4960,11 +5094,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
4960
5094
|
colorMap: colorMap2
|
|
4961
5095
|
}) => {
|
|
4962
5096
|
const svgObjects = [];
|
|
4963
|
-
const componentScreenTopLeft =
|
|
5097
|
+
const componentScreenTopLeft = applyToPoint37(transform, {
|
|
4964
5098
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
4965
5099
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
4966
5100
|
});
|
|
4967
|
-
const componentScreenBottomRight =
|
|
5101
|
+
const componentScreenBottomRight = applyToPoint37(transform, {
|
|
4968
5102
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
4969
5103
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
4970
5104
|
});
|
|
@@ -5047,13 +5181,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
5047
5181
|
}
|
|
5048
5182
|
|
|
5049
5183
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
5050
|
-
import { applyToPoint as
|
|
5184
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
5051
5185
|
function createSvgObjectsFromSchVoltageProbe({
|
|
5052
5186
|
probe,
|
|
5053
5187
|
transform,
|
|
5054
5188
|
colorMap: colorMap2
|
|
5055
5189
|
}) {
|
|
5056
|
-
const [screenX, screenY] =
|
|
5190
|
+
const [screenX, screenY] = applyToPoint38(transform, [
|
|
5057
5191
|
probe.position.x,
|
|
5058
5192
|
probe.position.y
|
|
5059
5193
|
]);
|
|
@@ -5113,17 +5247,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
5113
5247
|
}
|
|
5114
5248
|
|
|
5115
5249
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
5116
|
-
import { applyToPoint as
|
|
5250
|
+
import { applyToPoint as applyToPoint39 } from "transformation-matrix";
|
|
5117
5251
|
function createSvgObjectsFromSchDebugObject({
|
|
5118
5252
|
debugObject,
|
|
5119
5253
|
transform
|
|
5120
5254
|
}) {
|
|
5121
5255
|
if (debugObject.shape === "rect") {
|
|
5122
|
-
let [screenLeft, screenTop] =
|
|
5256
|
+
let [screenLeft, screenTop] = applyToPoint39(transform, [
|
|
5123
5257
|
debugObject.center.x - debugObject.size.width / 2,
|
|
5124
5258
|
debugObject.center.y - debugObject.size.height / 2
|
|
5125
5259
|
]);
|
|
5126
|
-
let [screenRight, screenBottom] =
|
|
5260
|
+
let [screenRight, screenBottom] = applyToPoint39(transform, [
|
|
5127
5261
|
debugObject.center.x + debugObject.size.width / 2,
|
|
5128
5262
|
debugObject.center.y + debugObject.size.height / 2
|
|
5129
5263
|
]);
|
|
@@ -5133,7 +5267,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
5133
5267
|
];
|
|
5134
5268
|
const width = Math.abs(screenRight - screenLeft);
|
|
5135
5269
|
const height = Math.abs(screenBottom - screenTop);
|
|
5136
|
-
const [screenCenterX, screenCenterY] =
|
|
5270
|
+
const [screenCenterX, screenCenterY] = applyToPoint39(transform, [
|
|
5137
5271
|
debugObject.center.x,
|
|
5138
5272
|
debugObject.center.y
|
|
5139
5273
|
]);
|
|
@@ -5179,11 +5313,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
5179
5313
|
];
|
|
5180
5314
|
}
|
|
5181
5315
|
if (debugObject.shape === "line") {
|
|
5182
|
-
const [screenStartX, screenStartY] =
|
|
5316
|
+
const [screenStartX, screenStartY] = applyToPoint39(transform, [
|
|
5183
5317
|
debugObject.start.x,
|
|
5184
5318
|
debugObject.start.y
|
|
5185
5319
|
]);
|
|
5186
|
-
const [screenEndX, screenEndY] =
|
|
5320
|
+
const [screenEndX, screenEndY] = applyToPoint39(transform, [
|
|
5187
5321
|
debugObject.end.x,
|
|
5188
5322
|
debugObject.end.y
|
|
5189
5323
|
]);
|
|
@@ -5233,7 +5367,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
5233
5367
|
}
|
|
5234
5368
|
|
|
5235
5369
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
5236
|
-
import { applyToPoint as
|
|
5370
|
+
import { applyToPoint as applyToPoint40 } from "transformation-matrix";
|
|
5237
5371
|
function createSchematicTrace({
|
|
5238
5372
|
trace,
|
|
5239
5373
|
transform,
|
|
@@ -5247,11 +5381,11 @@ function createSchematicTrace({
|
|
|
5247
5381
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
5248
5382
|
const edge = edges[edgeIndex];
|
|
5249
5383
|
if (edge.is_crossing) continue;
|
|
5250
|
-
const [screenFromX, screenFromY] =
|
|
5384
|
+
const [screenFromX, screenFromY] = applyToPoint40(transform, [
|
|
5251
5385
|
edge.from.x,
|
|
5252
5386
|
edge.from.y
|
|
5253
5387
|
]);
|
|
5254
|
-
const [screenToX, screenToY] =
|
|
5388
|
+
const [screenToX, screenToY] = applyToPoint40(transform, [
|
|
5255
5389
|
edge.to.x,
|
|
5256
5390
|
edge.to.y
|
|
5257
5391
|
]);
|
|
@@ -5295,11 +5429,11 @@ function createSchematicTrace({
|
|
|
5295
5429
|
}
|
|
5296
5430
|
for (const edge of edges) {
|
|
5297
5431
|
if (!edge.is_crossing) continue;
|
|
5298
|
-
const [screenFromX, screenFromY] =
|
|
5432
|
+
const [screenFromX, screenFromY] = applyToPoint40(transform, [
|
|
5299
5433
|
edge.from.x,
|
|
5300
5434
|
edge.from.y
|
|
5301
5435
|
]);
|
|
5302
|
-
const [screenToX, screenToY] =
|
|
5436
|
+
const [screenToX, screenToY] = applyToPoint40(transform, [
|
|
5303
5437
|
edge.to.x,
|
|
5304
5438
|
edge.to.y
|
|
5305
5439
|
]);
|
|
@@ -5343,7 +5477,7 @@ function createSchematicTrace({
|
|
|
5343
5477
|
}
|
|
5344
5478
|
if (trace.junctions) {
|
|
5345
5479
|
for (const junction of trace.junctions) {
|
|
5346
|
-
const [screenX, screenY] =
|
|
5480
|
+
const [screenX, screenY] = applyToPoint40(transform, [
|
|
5347
5481
|
junction.x,
|
|
5348
5482
|
junction.y
|
|
5349
5483
|
]);
|
|
@@ -5398,20 +5532,20 @@ function createSchematicTrace({
|
|
|
5398
5532
|
|
|
5399
5533
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
5400
5534
|
import {
|
|
5401
|
-
applyToPoint as
|
|
5402
|
-
compose as
|
|
5403
|
-
rotate as
|
|
5535
|
+
applyToPoint as applyToPoint42,
|
|
5536
|
+
compose as compose10,
|
|
5537
|
+
rotate as rotate6,
|
|
5404
5538
|
scale as scale6,
|
|
5405
|
-
translate as
|
|
5539
|
+
translate as translate10
|
|
5406
5540
|
} from "transformation-matrix";
|
|
5407
5541
|
|
|
5408
5542
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
5409
5543
|
import {
|
|
5410
|
-
applyToPoint as
|
|
5411
|
-
compose as
|
|
5412
|
-
rotate as
|
|
5544
|
+
applyToPoint as applyToPoint41,
|
|
5545
|
+
compose as compose9,
|
|
5546
|
+
rotate as rotate5,
|
|
5413
5547
|
scale as scale5,
|
|
5414
|
-
translate as
|
|
5548
|
+
translate as translate9
|
|
5415
5549
|
} from "transformation-matrix";
|
|
5416
5550
|
import { symbols as symbols3 } from "schematic-symbols";
|
|
5417
5551
|
var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
@@ -5455,7 +5589,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
5455
5589
|
y: schNetLabel.center.y - realTextGrowthVec.y * fullWidthFsr * fontSizeMm / 2
|
|
5456
5590
|
};
|
|
5457
5591
|
const pathRotation = 0;
|
|
5458
|
-
const rotationMatrix =
|
|
5592
|
+
const rotationMatrix = rotate5(pathRotation / 180 * Math.PI);
|
|
5459
5593
|
const symbolBounds = {
|
|
5460
5594
|
minX: Math.min(
|
|
5461
5595
|
...symbol.primitives.flatMap(
|
|
@@ -5482,9 +5616,9 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
5482
5616
|
x: symbolBounds.minX,
|
|
5483
5617
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
5484
5618
|
};
|
|
5485
|
-
const rotatedSymbolEnd =
|
|
5486
|
-
const symbolToRealTransform =
|
|
5487
|
-
|
|
5619
|
+
const rotatedSymbolEnd = applyToPoint41(rotationMatrix, symbolEndPoint);
|
|
5620
|
+
const symbolToRealTransform = compose9(
|
|
5621
|
+
translate9(
|
|
5488
5622
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
5489
5623
|
realAnchorPosition.y - rotatedSymbolEnd.y
|
|
5490
5624
|
),
|
|
@@ -5492,12 +5626,12 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
5492
5626
|
scale5(1)
|
|
5493
5627
|
// Use full symbol size
|
|
5494
5628
|
);
|
|
5495
|
-
const [screenMinX, screenMinY] =
|
|
5496
|
-
|
|
5629
|
+
const [screenMinX, screenMinY] = applyToPoint41(
|
|
5630
|
+
compose9(realToScreenTransform, symbolToRealTransform),
|
|
5497
5631
|
[bounds.minX, bounds.minY]
|
|
5498
5632
|
);
|
|
5499
|
-
const [screenMaxX, screenMaxY] =
|
|
5500
|
-
|
|
5633
|
+
const [screenMaxX, screenMaxY] = applyToPoint41(
|
|
5634
|
+
compose9(realToScreenTransform, symbolToRealTransform),
|
|
5501
5635
|
[bounds.maxX, bounds.maxY]
|
|
5502
5636
|
);
|
|
5503
5637
|
const rectHeight = Math.abs(screenMaxY - screenMinY);
|
|
@@ -5520,8 +5654,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
5520
5654
|
});
|
|
5521
5655
|
for (const path of symbolPaths) {
|
|
5522
5656
|
const symbolPath = path.points.map((p, i) => {
|
|
5523
|
-
const [x, y] =
|
|
5524
|
-
|
|
5657
|
+
const [x, y] = applyToPoint41(
|
|
5658
|
+
compose9(realToScreenTransform, symbolToRealTransform),
|
|
5525
5659
|
[p.x, p.y]
|
|
5526
5660
|
);
|
|
5527
5661
|
return `${i === 0 ? "M" : "L"} ${x} ${y}`;
|
|
@@ -5541,8 +5675,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
5541
5675
|
});
|
|
5542
5676
|
}
|
|
5543
5677
|
for (const text of symbolTexts) {
|
|
5544
|
-
const screenTextPos =
|
|
5545
|
-
|
|
5678
|
+
const screenTextPos = applyToPoint41(
|
|
5679
|
+
compose9(realToScreenTransform, symbolToRealTransform),
|
|
5546
5680
|
text
|
|
5547
5681
|
);
|
|
5548
5682
|
let textValue = text.text;
|
|
@@ -5583,11 +5717,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
5583
5717
|
});
|
|
5584
5718
|
}
|
|
5585
5719
|
for (const box of symbolBoxes) {
|
|
5586
|
-
const screenBoxPos =
|
|
5587
|
-
|
|
5720
|
+
const screenBoxPos = applyToPoint41(
|
|
5721
|
+
compose9(realToScreenTransform, symbolToRealTransform),
|
|
5588
5722
|
box
|
|
5589
5723
|
);
|
|
5590
|
-
const symbolToScreenScale =
|
|
5724
|
+
const symbolToScreenScale = compose9(
|
|
5591
5725
|
realToScreenTransform,
|
|
5592
5726
|
symbolToRealTransform
|
|
5593
5727
|
).a;
|
|
@@ -5606,11 +5740,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
5606
5740
|
});
|
|
5607
5741
|
}
|
|
5608
5742
|
for (const circle of symbolCircles) {
|
|
5609
|
-
const screenCirclePos =
|
|
5610
|
-
|
|
5743
|
+
const screenCirclePos = applyToPoint41(
|
|
5744
|
+
compose9(realToScreenTransform, symbolToRealTransform),
|
|
5611
5745
|
circle
|
|
5612
5746
|
);
|
|
5613
|
-
const symbolToScreenScale =
|
|
5747
|
+
const symbolToScreenScale = compose9(
|
|
5614
5748
|
realToScreenTransform,
|
|
5615
5749
|
symbolToRealTransform
|
|
5616
5750
|
).a;
|
|
@@ -5651,14 +5785,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
5651
5785
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
5652
5786
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
5653
5787
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
5654
|
-
const screenCenter =
|
|
5788
|
+
const screenCenter = applyToPoint42(realToScreenTransform, schNetLabel.center);
|
|
5655
5789
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
5656
5790
|
schNetLabel.anchor_side
|
|
5657
5791
|
);
|
|
5658
5792
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
5659
5793
|
screenTextGrowthVec.y *= -1;
|
|
5660
5794
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
5661
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
5795
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint42(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
5662
5796
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
5663
5797
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
5664
5798
|
};
|
|
@@ -5699,12 +5833,12 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
5699
5833
|
y: -0.6
|
|
5700
5834
|
}
|
|
5701
5835
|
].map(
|
|
5702
|
-
(fontRelativePoint) =>
|
|
5703
|
-
|
|
5836
|
+
(fontRelativePoint) => applyToPoint42(
|
|
5837
|
+
compose10(
|
|
5704
5838
|
realToScreenTransform,
|
|
5705
|
-
|
|
5839
|
+
translate10(realAnchorPosition.x, realAnchorPosition.y),
|
|
5706
5840
|
scale6(fontSizeMm),
|
|
5707
|
-
|
|
5841
|
+
rotate6(pathRotation / 180 * Math.PI)
|
|
5708
5842
|
),
|
|
5709
5843
|
fontRelativePoint
|
|
5710
5844
|
)
|
|
@@ -5776,17 +5910,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
5776
5910
|
};
|
|
5777
5911
|
|
|
5778
5912
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
5779
|
-
import { applyToPoint as
|
|
5913
|
+
import { applyToPoint as applyToPoint43 } from "transformation-matrix";
|
|
5780
5914
|
var createSvgObjectsFromSchematicBox = ({
|
|
5781
5915
|
schematicBox,
|
|
5782
5916
|
transform,
|
|
5783
5917
|
colorMap: colorMap2
|
|
5784
5918
|
}) => {
|
|
5785
|
-
const topLeft =
|
|
5919
|
+
const topLeft = applyToPoint43(transform, {
|
|
5786
5920
|
x: schematicBox.x,
|
|
5787
5921
|
y: schematicBox.y
|
|
5788
5922
|
});
|
|
5789
|
-
const bottomRight =
|
|
5923
|
+
const bottomRight = applyToPoint43(transform, {
|
|
5790
5924
|
x: schematicBox.x + schematicBox.width,
|
|
5791
5925
|
y: schematicBox.y + schematicBox.height
|
|
5792
5926
|
});
|
|
@@ -5822,7 +5956,7 @@ var createSvgObjectsFromSchematicBox = ({
|
|
|
5822
5956
|
};
|
|
5823
5957
|
|
|
5824
5958
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-table.ts
|
|
5825
|
-
import { applyToPoint as
|
|
5959
|
+
import { applyToPoint as applyToPoint44 } from "transformation-matrix";
|
|
5826
5960
|
var createSvgObjectsFromSchematicTable = ({
|
|
5827
5961
|
schematicTable,
|
|
5828
5962
|
transform,
|
|
@@ -5855,11 +5989,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
5855
5989
|
const svgObjects = [];
|
|
5856
5990
|
const borderStrokeWidth = border_width * Math.abs(transform.a);
|
|
5857
5991
|
const gridStrokeWidth = getSchStrokeSize(transform);
|
|
5858
|
-
const [screenTopLeftX, screenTopLeftY] =
|
|
5992
|
+
const [screenTopLeftX, screenTopLeftY] = applyToPoint44(transform, [
|
|
5859
5993
|
topLeftX,
|
|
5860
5994
|
topLeftY
|
|
5861
5995
|
]);
|
|
5862
|
-
const [screenBottomRightX, screenBottomRightY] =
|
|
5996
|
+
const [screenBottomRightX, screenBottomRightY] = applyToPoint44(transform, [
|
|
5863
5997
|
topLeftX + totalWidth,
|
|
5864
5998
|
topLeftY - totalHeight
|
|
5865
5999
|
]);
|
|
@@ -5891,8 +6025,8 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
5891
6025
|
(cell) => cell.start_column_index <= i && cell.end_column_index > i && cell.start_row_index <= j && cell.end_row_index >= j
|
|
5892
6026
|
);
|
|
5893
6027
|
if (!isMerged) {
|
|
5894
|
-
const start =
|
|
5895
|
-
const end =
|
|
6028
|
+
const start = applyToPoint44(transform, { x: currentX, y: segmentStartY });
|
|
6029
|
+
const end = applyToPoint44(transform, { x: currentX, y: segmentEndY });
|
|
5896
6030
|
svgObjects.push({
|
|
5897
6031
|
name: "line",
|
|
5898
6032
|
type: "element",
|
|
@@ -5921,11 +6055,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
5921
6055
|
(cell) => cell.start_row_index <= i && cell.end_row_index > i && cell.start_column_index <= j && cell.end_column_index >= j
|
|
5922
6056
|
);
|
|
5923
6057
|
if (!isMerged) {
|
|
5924
|
-
const start =
|
|
6058
|
+
const start = applyToPoint44(transform, {
|
|
5925
6059
|
x: segmentStartX,
|
|
5926
6060
|
y: currentY
|
|
5927
6061
|
});
|
|
5928
|
-
const end =
|
|
6062
|
+
const end = applyToPoint44(transform, { x: segmentEndX, y: currentY });
|
|
5929
6063
|
svgObjects.push({
|
|
5930
6064
|
name: "line",
|
|
5931
6065
|
type: "element",
|
|
@@ -5967,7 +6101,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
5967
6101
|
} else if (vertical_align === "bottom") {
|
|
5968
6102
|
realTextAnchorPos.y = cellTopLeftY - cellHeight + cell_padding;
|
|
5969
6103
|
}
|
|
5970
|
-
const screenTextAnchorPos =
|
|
6104
|
+
const screenTextAnchorPos = applyToPoint44(transform, realTextAnchorPos);
|
|
5971
6105
|
const fontSize = getSchScreenFontSize(
|
|
5972
6106
|
transform,
|
|
5973
6107
|
"reference_designator",
|
|
@@ -6023,13 +6157,13 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
6023
6157
|
|
|
6024
6158
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
|
|
6025
6159
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
6026
|
-
import { applyToPoint as
|
|
6160
|
+
import { applyToPoint as applyToPoint45 } from "transformation-matrix";
|
|
6027
6161
|
var PIN_CIRCLE_RADIUS_MM2 = 0.02;
|
|
6028
6162
|
var createSvgObjectsForSchPortHover = ({
|
|
6029
6163
|
schPort,
|
|
6030
6164
|
transform
|
|
6031
6165
|
}) => {
|
|
6032
|
-
const screenSchPortPos =
|
|
6166
|
+
const screenSchPortPos = applyToPoint45(transform, schPort.center);
|
|
6033
6167
|
const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
|
|
6034
6168
|
return [
|
|
6035
6169
|
{
|
|
@@ -6337,18 +6471,18 @@ var circuitJsonToSchematicSvg = convertCircuitJsonToSchematicSvg;
|
|
|
6337
6471
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
6338
6472
|
import { stringify as stringify4 } from "svgson";
|
|
6339
6473
|
import {
|
|
6340
|
-
applyToPoint as
|
|
6341
|
-
compose as
|
|
6474
|
+
applyToPoint as applyToPoint48,
|
|
6475
|
+
compose as compose12,
|
|
6342
6476
|
scale as scale8,
|
|
6343
|
-
translate as
|
|
6477
|
+
translate as translate12
|
|
6344
6478
|
} from "transformation-matrix";
|
|
6345
6479
|
|
|
6346
6480
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
6347
|
-
import { applyToPoint as
|
|
6481
|
+
import { applyToPoint as applyToPoint47 } from "transformation-matrix";
|
|
6348
6482
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
6349
6483
|
const { transform, layer: layerFilter } = ctx;
|
|
6350
6484
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
6351
|
-
const [x, y] =
|
|
6485
|
+
const [x, y] = applyToPoint47(transform, [solderPaste.x, solderPaste.y]);
|
|
6352
6486
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
6353
6487
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
6354
6488
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -6456,8 +6590,8 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
|
|
|
6456
6590
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
6457
6591
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
6458
6592
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
6459
|
-
const transform =
|
|
6460
|
-
|
|
6593
|
+
const transform = compose12(
|
|
6594
|
+
translate12(
|
|
6461
6595
|
offsetX - minX * scaleFactor + padding * scaleFactor,
|
|
6462
6596
|
svgHeight - offsetY + minY * scaleFactor - padding * scaleFactor
|
|
6463
6597
|
),
|
|
@@ -6551,8 +6685,8 @@ function createSvgObjects3({ elm, ctx }) {
|
|
|
6551
6685
|
}
|
|
6552
6686
|
}
|
|
6553
6687
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
6554
|
-
const [x1, y1] =
|
|
6555
|
-
const [x2, y2] =
|
|
6688
|
+
const [x1, y1] = applyToPoint48(transform, [minX, minY]);
|
|
6689
|
+
const [x2, y2] = applyToPoint48(transform, [maxX, maxY]);
|
|
6556
6690
|
const width = Math.abs(x2 - x1);
|
|
6557
6691
|
const height = Math.abs(y2 - y1);
|
|
6558
6692
|
const x = Math.min(x1, x2);
|