circuit-to-svg 0.0.232 → 0.0.233
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 +296 -202
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// lib/pcb/convert-circuit-json-to-pcb-svg.ts
|
|
2
2
|
import { stringify } from "svgson";
|
|
3
3
|
import {
|
|
4
|
-
applyToPoint as
|
|
4
|
+
applyToPoint as applyToPoint27,
|
|
5
5
|
compose as compose5,
|
|
6
6
|
scale as scale2,
|
|
7
7
|
translate as translate5
|
|
@@ -520,8 +520,93 @@ function createSvgObjectsFromPcbFabricationNoteText(pcbFabNoteText, ctx) {
|
|
|
520
520
|
return [svgObject];
|
|
521
521
|
}
|
|
522
522
|
|
|
523
|
-
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-
|
|
523
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-fabrication-note-rect.ts
|
|
524
524
|
import { applyToPoint as applyToPoint5 } from "transformation-matrix";
|
|
525
|
+
var DEFAULT_OVERLAY_STROKE_COLOR = "rgba(255,255,255,0.5)";
|
|
526
|
+
var DEFAULT_OVERLAY_FILL_COLOR = "rgba(255,255,255,0.2)";
|
|
527
|
+
function createSvgObjectsFromPcbFabricationNoteRect(fabricationNoteRect, ctx) {
|
|
528
|
+
const { transform, layer: layerFilter } = ctx;
|
|
529
|
+
const {
|
|
530
|
+
center,
|
|
531
|
+
width,
|
|
532
|
+
height,
|
|
533
|
+
stroke_width,
|
|
534
|
+
is_filled,
|
|
535
|
+
has_stroke,
|
|
536
|
+
is_stroke_dashed,
|
|
537
|
+
color,
|
|
538
|
+
layer = "top",
|
|
539
|
+
pcb_component_id,
|
|
540
|
+
pcb_fabrication_note_rect_id
|
|
541
|
+
} = fabricationNoteRect;
|
|
542
|
+
if (layerFilter && layer !== layerFilter) return [];
|
|
543
|
+
if (!center || typeof center.x !== "number" || typeof center.y !== "number" || typeof width !== "number" || typeof height !== "number") {
|
|
544
|
+
console.error("Invalid pcb_fabrication_note_rect data", {
|
|
545
|
+
center,
|
|
546
|
+
width,
|
|
547
|
+
height
|
|
548
|
+
});
|
|
549
|
+
return [];
|
|
550
|
+
}
|
|
551
|
+
const halfWidth = width / 2;
|
|
552
|
+
const halfHeight = height / 2;
|
|
553
|
+
const [topLeftX, topLeftY] = applyToPoint5(transform, [
|
|
554
|
+
center.x - halfWidth,
|
|
555
|
+
center.y + halfHeight
|
|
556
|
+
]);
|
|
557
|
+
const [bottomRightX, bottomRightY] = applyToPoint5(transform, [
|
|
558
|
+
center.x + halfWidth,
|
|
559
|
+
center.y - halfHeight
|
|
560
|
+
]);
|
|
561
|
+
const rectX = Math.min(topLeftX, bottomRightX);
|
|
562
|
+
const rectY = Math.min(topLeftY, bottomRightY);
|
|
563
|
+
const rectWidth = Math.abs(bottomRightX - topLeftX);
|
|
564
|
+
const rectHeight = Math.abs(bottomRightY - topLeftY);
|
|
565
|
+
const baseStrokeWidth = typeof stroke_width === "number" ? stroke_width : 0;
|
|
566
|
+
const transformedStrokeWidth = baseStrokeWidth * Math.abs(transform.a);
|
|
567
|
+
const overlayStrokeColor = color ?? DEFAULT_OVERLAY_STROKE_COLOR;
|
|
568
|
+
const attributes = {
|
|
569
|
+
x: rectX.toString(),
|
|
570
|
+
y: rectY.toString(),
|
|
571
|
+
width: rectWidth.toString(),
|
|
572
|
+
height: rectHeight.toString(),
|
|
573
|
+
class: "pcb-fabrication-note-rect",
|
|
574
|
+
"data-type": "pcb_fabrication_note_rect",
|
|
575
|
+
"data-pcb-fabrication-note-rect-id": pcb_fabrication_note_rect_id,
|
|
576
|
+
"data-pcb-layer": "overlay"
|
|
577
|
+
};
|
|
578
|
+
if (pcb_component_id !== void 0) {
|
|
579
|
+
attributes["data-pcb-component-id"] = pcb_component_id;
|
|
580
|
+
}
|
|
581
|
+
if (is_filled) {
|
|
582
|
+
attributes.fill = color ?? DEFAULT_OVERLAY_FILL_COLOR;
|
|
583
|
+
} else {
|
|
584
|
+
attributes.fill = "none";
|
|
585
|
+
}
|
|
586
|
+
const shouldDrawStroke = has_stroke ?? transformedStrokeWidth > 0;
|
|
587
|
+
if (shouldDrawStroke) {
|
|
588
|
+
attributes.stroke = overlayStrokeColor;
|
|
589
|
+
attributes["stroke-width"] = transformedStrokeWidth.toString();
|
|
590
|
+
if (is_stroke_dashed) {
|
|
591
|
+
const dash = 0.2 * Math.abs(transform.a);
|
|
592
|
+
const gap = 0.1 * Math.abs(transform.a);
|
|
593
|
+
attributes["stroke-dasharray"] = `${dash} ${gap}`;
|
|
594
|
+
}
|
|
595
|
+
} else {
|
|
596
|
+
attributes.stroke = "none";
|
|
597
|
+
}
|
|
598
|
+
const svgObject = {
|
|
599
|
+
name: "rect",
|
|
600
|
+
type: "element",
|
|
601
|
+
value: "",
|
|
602
|
+
attributes,
|
|
603
|
+
children: []
|
|
604
|
+
};
|
|
605
|
+
return [svgObject];
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-dimension.ts
|
|
609
|
+
import { applyToPoint as applyToPoint6 } from "transformation-matrix";
|
|
525
610
|
function normalize(vector) {
|
|
526
611
|
const length = Math.hypot(vector.x, vector.y) || 1;
|
|
527
612
|
return { x: vector.x / length, y: vector.y / length };
|
|
@@ -578,11 +663,11 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
|
|
|
578
663
|
y: toBase.y - perpendicular.y * arrowHalfWidth
|
|
579
664
|
})
|
|
580
665
|
];
|
|
581
|
-
const [lineStartX, lineStartY] =
|
|
666
|
+
const [lineStartX, lineStartY] = applyToPoint6(transform, [
|
|
582
667
|
fromBase.x,
|
|
583
668
|
fromBase.y
|
|
584
669
|
]);
|
|
585
|
-
const [lineEndX, lineEndY] =
|
|
670
|
+
const [lineEndX, lineEndY] = applyToPoint6(transform, [toBase.x, toBase.y]);
|
|
586
671
|
const strokeWidth = arrow_size / 5 * Math.abs(transform.a);
|
|
587
672
|
const lineColor = color || "rgba(255,255,255,0.5)";
|
|
588
673
|
const midPoint = {
|
|
@@ -594,7 +679,7 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
|
|
|
594
679
|
x: midPoint.x + perpendicular.x * textOffset,
|
|
595
680
|
y: midPoint.y + perpendicular.y * textOffset
|
|
596
681
|
};
|
|
597
|
-
const [textX, textY] =
|
|
682
|
+
const [textX, textY] = applyToPoint6(transform, [textPoint.x, textPoint.y]);
|
|
598
683
|
const transformedFontSize = font_size * Math.abs(transform.a);
|
|
599
684
|
const children = [
|
|
600
685
|
{
|
|
@@ -675,13 +760,13 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
|
|
|
675
760
|
}
|
|
676
761
|
];
|
|
677
762
|
function toScreen(point) {
|
|
678
|
-
const [x, y] =
|
|
763
|
+
const [x, y] = applyToPoint6(transform, [point.x, point.y]);
|
|
679
764
|
return { x, y };
|
|
680
765
|
}
|
|
681
766
|
}
|
|
682
767
|
|
|
683
768
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-text.ts
|
|
684
|
-
import { applyToPoint as
|
|
769
|
+
import { applyToPoint as applyToPoint7 } from "transformation-matrix";
|
|
685
770
|
var DEFAULT_OVERLAY_COLOR = "rgba(255,255,255,0.5)";
|
|
686
771
|
function createSvgObjectsFromPcbNoteText(note, ctx) {
|
|
687
772
|
const { transform } = ctx;
|
|
@@ -700,7 +785,7 @@ function createSvgObjectsFromPcbNoteText(note, ctx) {
|
|
|
700
785
|
console.error("Invalid pcb_note_text text", text);
|
|
701
786
|
return [];
|
|
702
787
|
}
|
|
703
|
-
const [x, y] =
|
|
788
|
+
const [x, y] = applyToPoint7(transform, [anchor_position.x, anchor_position.y]);
|
|
704
789
|
const transformedFontSize = font_size * Math.abs(transform.a);
|
|
705
790
|
let textAnchor = "middle";
|
|
706
791
|
let dominantBaseline = "central";
|
|
@@ -758,7 +843,7 @@ function createSvgObjectsFromPcbNoteText(note, ctx) {
|
|
|
758
843
|
}
|
|
759
844
|
|
|
760
845
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-rect.ts
|
|
761
|
-
import { applyToPoint as
|
|
846
|
+
import { applyToPoint as applyToPoint8 } from "transformation-matrix";
|
|
762
847
|
var DEFAULT_OVERLAY_COLOR2 = "rgba(255,255,255,0.5)";
|
|
763
848
|
var DEFAULT_FILL_COLOR = "rgba(255,255,255,0.2)";
|
|
764
849
|
function createSvgObjectsFromPcbNoteRect(noteRect, ctx) {
|
|
@@ -779,11 +864,11 @@ function createSvgObjectsFromPcbNoteRect(noteRect, ctx) {
|
|
|
779
864
|
}
|
|
780
865
|
const halfWidth = width / 2;
|
|
781
866
|
const halfHeight = height / 2;
|
|
782
|
-
const [topLeftX, topLeftY] =
|
|
867
|
+
const [topLeftX, topLeftY] = applyToPoint8(transform, [
|
|
783
868
|
center.x - halfWidth,
|
|
784
869
|
center.y + halfHeight
|
|
785
870
|
]);
|
|
786
|
-
const [bottomRightX, bottomRightY] =
|
|
871
|
+
const [bottomRightX, bottomRightY] = applyToPoint8(transform, [
|
|
787
872
|
center.x + halfWidth,
|
|
788
873
|
center.y - halfHeight
|
|
789
874
|
]);
|
|
@@ -832,7 +917,7 @@ function createSvgObjectsFromPcbNoteRect(noteRect, ctx) {
|
|
|
832
917
|
}
|
|
833
918
|
|
|
834
919
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-path.ts
|
|
835
|
-
import { applyToPoint as
|
|
920
|
+
import { applyToPoint as applyToPoint9 } from "transformation-matrix";
|
|
836
921
|
var DEFAULT_OVERLAY_COLOR3 = "rgba(255,255,255,0.5)";
|
|
837
922
|
function createSvgObjectsFromPcbNotePath(notePath, ctx) {
|
|
838
923
|
const { transform } = ctx;
|
|
@@ -847,7 +932,7 @@ function createSvgObjectsFromPcbNotePath(notePath, ctx) {
|
|
|
847
932
|
}
|
|
848
933
|
}
|
|
849
934
|
const pathD = notePath.route.map((point, index) => {
|
|
850
|
-
const [x, y] =
|
|
935
|
+
const [x, y] = applyToPoint9(transform, [point.x, point.y]);
|
|
851
936
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
852
937
|
}).join(" ");
|
|
853
938
|
const strokeWidth = notePath.stroke_width * Math.abs(transform.a);
|
|
@@ -871,7 +956,7 @@ function createSvgObjectsFromPcbNotePath(notePath, ctx) {
|
|
|
871
956
|
}
|
|
872
957
|
|
|
873
958
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-line.ts
|
|
874
|
-
import { applyToPoint as
|
|
959
|
+
import { applyToPoint as applyToPoint10 } from "transformation-matrix";
|
|
875
960
|
var DEFAULT_OVERLAY_COLOR4 = "rgba(255,255,255,0.5)";
|
|
876
961
|
function createSvgObjectsFromPcbNoteLine(noteLine, ctx) {
|
|
877
962
|
const { transform } = ctx;
|
|
@@ -885,8 +970,8 @@ function createSvgObjectsFromPcbNoteLine(noteLine, ctx) {
|
|
|
885
970
|
});
|
|
886
971
|
return [];
|
|
887
972
|
}
|
|
888
|
-
const [startX, startY] =
|
|
889
|
-
const [endX, endY] =
|
|
973
|
+
const [startX, startY] = applyToPoint10(transform, [x1, y1]);
|
|
974
|
+
const [endX, endY] = applyToPoint10(transform, [x2, y2]);
|
|
890
975
|
const baseStrokeWidth = typeof stroke_width === "number" ? stroke_width : 0;
|
|
891
976
|
const transformedStrokeWidth = baseStrokeWidth * Math.abs(transform.a);
|
|
892
977
|
const attributes = {
|
|
@@ -918,10 +1003,10 @@ function createSvgObjectsFromPcbNoteLine(noteLine, ctx) {
|
|
|
918
1003
|
}
|
|
919
1004
|
|
|
920
1005
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-plated-hole.ts
|
|
921
|
-
import { applyToPoint as
|
|
1006
|
+
import { applyToPoint as applyToPoint11 } from "transformation-matrix";
|
|
922
1007
|
function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
923
1008
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
924
|
-
const [x, y] =
|
|
1009
|
+
const [x, y] = applyToPoint11(transform, [hole.x, hole.y]);
|
|
925
1010
|
const copperLayer = Array.isArray(hole.layers) && hole.layers[0] || hole.layer || "top";
|
|
926
1011
|
if (hole.shape === "pill") {
|
|
927
1012
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
@@ -1038,7 +1123,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
1038
1123
|
const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
|
|
1039
1124
|
const scaledRectBorderRadius = (hole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
1040
1125
|
const holeRadius = scaledHoleDiameter / 2;
|
|
1041
|
-
const [holeCx, holeCy] =
|
|
1126
|
+
const [holeCx, holeCy] = applyToPoint11(transform, [
|
|
1042
1127
|
h.x + (h.hole_offset_x ?? 0),
|
|
1043
1128
|
h.y + (h.hole_offset_y ?? 0)
|
|
1044
1129
|
]);
|
|
@@ -1103,7 +1188,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
1103
1188
|
const pillHoleWithOffsets = pillHole;
|
|
1104
1189
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
1105
1190
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
1106
|
-
const [holeCenterX, holeCenterY] =
|
|
1191
|
+
const [holeCenterX, holeCenterY] = applyToPoint11(transform, [
|
|
1107
1192
|
pillHole.x + holeOffsetX,
|
|
1108
1193
|
pillHole.y + holeOffsetY
|
|
1109
1194
|
]);
|
|
@@ -1172,7 +1257,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
1172
1257
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
1173
1258
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
1174
1259
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
1175
|
-
const [holeCenterX, holeCenterY] =
|
|
1260
|
+
const [holeCenterX, holeCenterY] = applyToPoint11(transform, [
|
|
1176
1261
|
rotatedHole.x + holeOffsetX,
|
|
1177
1262
|
rotatedHole.y + holeOffsetY
|
|
1178
1263
|
]);
|
|
@@ -1235,12 +1320,12 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
1235
1320
|
}
|
|
1236
1321
|
|
|
1237
1322
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-path.ts
|
|
1238
|
-
import { applyToPoint as
|
|
1323
|
+
import { applyToPoint as applyToPoint12 } from "transformation-matrix";
|
|
1239
1324
|
function createSvgObjectsFromPcbSilkscreenPath(silkscreenPath, ctx) {
|
|
1240
1325
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1241
1326
|
if (!silkscreenPath.route || !Array.isArray(silkscreenPath.route)) return [];
|
|
1242
1327
|
let path = silkscreenPath.route.map((point, index) => {
|
|
1243
|
-
const [x, y] =
|
|
1328
|
+
const [x, y] = applyToPoint12(transform, [point.x, point.y]);
|
|
1244
1329
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
1245
1330
|
}).join(" ");
|
|
1246
1331
|
const firstPoint = silkscreenPath.route[0];
|
|
@@ -1276,7 +1361,7 @@ function createSvgObjectsFromPcbSilkscreenPath(silkscreenPath, ctx) {
|
|
|
1276
1361
|
|
|
1277
1362
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-text.ts
|
|
1278
1363
|
import {
|
|
1279
|
-
applyToPoint as
|
|
1364
|
+
applyToPoint as applyToPoint13,
|
|
1280
1365
|
compose as compose2,
|
|
1281
1366
|
rotate as rotate2,
|
|
1282
1367
|
translate as translate2,
|
|
@@ -1298,7 +1383,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
1298
1383
|
console.error("Invalid anchor_position:", anchor_position);
|
|
1299
1384
|
return [];
|
|
1300
1385
|
}
|
|
1301
|
-
const [transformedX, transformedY] =
|
|
1386
|
+
const [transformedX, transformedY] = applyToPoint13(transform, [
|
|
1302
1387
|
anchor_position.x,
|
|
1303
1388
|
anchor_position.y
|
|
1304
1389
|
]);
|
|
@@ -1406,7 +1491,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
1406
1491
|
}
|
|
1407
1492
|
|
|
1408
1493
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-rect.ts
|
|
1409
|
-
import { applyToPoint as
|
|
1494
|
+
import { applyToPoint as applyToPoint14 } from "transformation-matrix";
|
|
1410
1495
|
function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
|
|
1411
1496
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1412
1497
|
const {
|
|
@@ -1425,7 +1510,7 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
|
|
|
1425
1510
|
console.error("Invalid rectangle data:", { center, width, height });
|
|
1426
1511
|
return [];
|
|
1427
1512
|
}
|
|
1428
|
-
const [transformedX, transformedY] =
|
|
1513
|
+
const [transformedX, transformedY] = applyToPoint14(transform, [
|
|
1429
1514
|
center.x,
|
|
1430
1515
|
center.y
|
|
1431
1516
|
]);
|
|
@@ -1472,7 +1557,7 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
|
|
|
1472
1557
|
}
|
|
1473
1558
|
|
|
1474
1559
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-circle.ts
|
|
1475
|
-
import { applyToPoint as
|
|
1560
|
+
import { applyToPoint as applyToPoint15 } from "transformation-matrix";
|
|
1476
1561
|
function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
1477
1562
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1478
1563
|
const {
|
|
@@ -1487,7 +1572,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
|
1487
1572
|
console.error("Invalid PCB Silkscreen Circle data:", { center, radius });
|
|
1488
1573
|
return [];
|
|
1489
1574
|
}
|
|
1490
|
-
const [transformedX, transformedY] =
|
|
1575
|
+
const [transformedX, transformedY] = applyToPoint15(transform, [
|
|
1491
1576
|
center.x,
|
|
1492
1577
|
center.y
|
|
1493
1578
|
]);
|
|
@@ -1515,7 +1600,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
|
1515
1600
|
}
|
|
1516
1601
|
|
|
1517
1602
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-line.ts
|
|
1518
|
-
import { applyToPoint as
|
|
1603
|
+
import { applyToPoint as applyToPoint16 } from "transformation-matrix";
|
|
1519
1604
|
function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
|
|
1520
1605
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1521
1606
|
const {
|
|
@@ -1532,8 +1617,8 @@ function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
|
|
|
1532
1617
|
console.error("Invalid coordinates:", { x1, y1, x2, y2 });
|
|
1533
1618
|
return [];
|
|
1534
1619
|
}
|
|
1535
|
-
const [transformedX1, transformedY1] =
|
|
1536
|
-
const [transformedX2, transformedY2] =
|
|
1620
|
+
const [transformedX1, transformedY1] = applyToPoint16(transform, [x1, y1]);
|
|
1621
|
+
const [transformedX2, transformedY2] = applyToPoint16(transform, [x2, y2]);
|
|
1537
1622
|
const transformedStrokeWidth = stroke_width * Math.abs(transform.a);
|
|
1538
1623
|
const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
|
|
1539
1624
|
return [
|
|
@@ -1568,7 +1653,7 @@ function pairs(arr) {
|
|
|
1568
1653
|
}
|
|
1569
1654
|
|
|
1570
1655
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace.ts
|
|
1571
|
-
import { applyToPoint as
|
|
1656
|
+
import { applyToPoint as applyToPoint17 } from "transformation-matrix";
|
|
1572
1657
|
|
|
1573
1658
|
// lib/pcb/colors.ts
|
|
1574
1659
|
var DEFAULT_PCB_COLOR_MAP = {
|
|
@@ -1624,8 +1709,8 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
|
1624
1709
|
const segments = pairs(trace.route);
|
|
1625
1710
|
const svgObjects = [];
|
|
1626
1711
|
for (const [start, end] of segments) {
|
|
1627
|
-
const startPoint =
|
|
1628
|
-
const endPoint =
|
|
1712
|
+
const startPoint = applyToPoint17(transform, [start.x, start.y]);
|
|
1713
|
+
const endPoint = applyToPoint17(transform, [end.x, end.y]);
|
|
1629
1714
|
const layer = "layer" in start ? start.layer : "layer" in end ? end.layer : null;
|
|
1630
1715
|
if (!layer) continue;
|
|
1631
1716
|
if (layerFilter && layer !== layerFilter) continue;
|
|
@@ -1697,7 +1782,7 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
|
1697
1782
|
}
|
|
1698
1783
|
|
|
1699
1784
|
// lib/pcb/svg-object-fns/create-svg-objects-from-smt-pads.ts
|
|
1700
|
-
import { applyToPoint as
|
|
1785
|
+
import { applyToPoint as applyToPoint18 } from "transformation-matrix";
|
|
1701
1786
|
function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
1702
1787
|
const { transform, layer: layerFilter, colorMap: colorMap2, renderSolderMask } = ctx;
|
|
1703
1788
|
if (layerFilter && pad.layer !== layerFilter) return [];
|
|
@@ -1707,7 +1792,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1707
1792
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
1708
1793
|
const width = pad.width * Math.abs(transform.a);
|
|
1709
1794
|
const height = pad.height * Math.abs(transform.d);
|
|
1710
|
-
const [x, y] =
|
|
1795
|
+
const [x, y] = applyToPoint18(transform, [pad.x, pad.y]);
|
|
1711
1796
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
1712
1797
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
1713
1798
|
const padElement2 = {
|
|
@@ -1789,7 +1874,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1789
1874
|
const width = pad.width * Math.abs(transform.a);
|
|
1790
1875
|
const height = pad.height * Math.abs(transform.d);
|
|
1791
1876
|
const radius = pad.radius * Math.abs(transform.a);
|
|
1792
|
-
const [x, y] =
|
|
1877
|
+
const [x, y] = applyToPoint18(transform, [pad.x, pad.y]);
|
|
1793
1878
|
const padElement = {
|
|
1794
1879
|
name: "rect",
|
|
1795
1880
|
type: "element",
|
|
@@ -1827,7 +1912,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1827
1912
|
}
|
|
1828
1913
|
if (pad.shape === "circle") {
|
|
1829
1914
|
const radius = pad.radius * Math.abs(transform.a);
|
|
1830
|
-
const [x, y] =
|
|
1915
|
+
const [x, y] = applyToPoint18(transform, [pad.x, pad.y]);
|
|
1831
1916
|
const padElement = {
|
|
1832
1917
|
name: "circle",
|
|
1833
1918
|
type: "element",
|
|
@@ -1862,7 +1947,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1862
1947
|
}
|
|
1863
1948
|
if (pad.shape === "polygon") {
|
|
1864
1949
|
const points = (pad.points ?? []).map(
|
|
1865
|
-
(point) =>
|
|
1950
|
+
(point) => applyToPoint18(transform, [point.x, point.y])
|
|
1866
1951
|
);
|
|
1867
1952
|
const padElement = {
|
|
1868
1953
|
name: "polygon",
|
|
@@ -1898,32 +1983,32 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1898
1983
|
}
|
|
1899
1984
|
|
|
1900
1985
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-board.ts
|
|
1901
|
-
import { applyToPoint as
|
|
1986
|
+
import { applyToPoint as applyToPoint19 } from "transformation-matrix";
|
|
1902
1987
|
function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
1903
1988
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
1904
1989
|
const { width, height, center, outline } = pcbBoard;
|
|
1905
1990
|
let path;
|
|
1906
1991
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
1907
1992
|
path = outline.map((point, index) => {
|
|
1908
|
-
const [x, y] =
|
|
1993
|
+
const [x, y] = applyToPoint19(transform, [point.x, point.y]);
|
|
1909
1994
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
1910
1995
|
}).join(" ");
|
|
1911
1996
|
} else {
|
|
1912
1997
|
const halfWidth = width / 2;
|
|
1913
1998
|
const halfHeight = height / 2;
|
|
1914
|
-
const topLeft =
|
|
1999
|
+
const topLeft = applyToPoint19(transform, [
|
|
1915
2000
|
center.x - halfWidth,
|
|
1916
2001
|
center.y - halfHeight
|
|
1917
2002
|
]);
|
|
1918
|
-
const topRight =
|
|
2003
|
+
const topRight = applyToPoint19(transform, [
|
|
1919
2004
|
center.x + halfWidth,
|
|
1920
2005
|
center.y - halfHeight
|
|
1921
2006
|
]);
|
|
1922
|
-
const bottomRight =
|
|
2007
|
+
const bottomRight = applyToPoint19(transform, [
|
|
1923
2008
|
center.x + halfWidth,
|
|
1924
2009
|
center.y + halfHeight
|
|
1925
2010
|
]);
|
|
1926
|
-
const bottomLeft =
|
|
2011
|
+
const bottomLeft = applyToPoint19(transform, [
|
|
1927
2012
|
center.x - halfWidth,
|
|
1928
2013
|
center.y + halfHeight
|
|
1929
2014
|
]);
|
|
@@ -1950,10 +2035,10 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
|
1950
2035
|
}
|
|
1951
2036
|
|
|
1952
2037
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-via.ts
|
|
1953
|
-
import { applyToPoint as
|
|
2038
|
+
import { applyToPoint as applyToPoint20 } from "transformation-matrix";
|
|
1954
2039
|
function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
1955
2040
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
1956
|
-
const [x, y] =
|
|
2041
|
+
const [x, y] = applyToPoint20(transform, [hole.x, hole.y]);
|
|
1957
2042
|
const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a);
|
|
1958
2043
|
const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a);
|
|
1959
2044
|
const scaledHoleWidth = hole.hole_diameter * Math.abs(transform.a);
|
|
@@ -1999,10 +2084,10 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
|
1999
2084
|
}
|
|
2000
2085
|
|
|
2001
2086
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-hole.ts
|
|
2002
|
-
import { applyToPoint as
|
|
2087
|
+
import { applyToPoint as applyToPoint21 } from "transformation-matrix";
|
|
2003
2088
|
function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
2004
2089
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
2005
|
-
const [x, y] =
|
|
2090
|
+
const [x, y] = applyToPoint21(transform, [hole.x, hole.y]);
|
|
2006
2091
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
2007
2092
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
2008
2093
|
const radius = scaledDiameter / 2;
|
|
@@ -2076,7 +2161,7 @@ import {
|
|
|
2076
2161
|
getFullConnectivityMapFromCircuitJson
|
|
2077
2162
|
} from "circuit-json-to-connectivity-map";
|
|
2078
2163
|
import "svgson";
|
|
2079
|
-
import { applyToPoint as
|
|
2164
|
+
import { applyToPoint as applyToPoint22 } from "transformation-matrix";
|
|
2080
2165
|
|
|
2081
2166
|
// lib/pcb/create-svg-objects-from-pcb-rats-nest/get-element-position.ts
|
|
2082
2167
|
import { su } from "@tscircuit/circuit-json-util";
|
|
@@ -2156,11 +2241,11 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
2156
2241
|
});
|
|
2157
2242
|
const svgObjects = [];
|
|
2158
2243
|
for (const line of ratsNestLines) {
|
|
2159
|
-
const transformedStart =
|
|
2244
|
+
const transformedStart = applyToPoint22(transform, [
|
|
2160
2245
|
line.startPoint.x,
|
|
2161
2246
|
line.startPoint.y
|
|
2162
2247
|
]);
|
|
2163
|
-
const transformedEnd =
|
|
2248
|
+
const transformedEnd = applyToPoint22(transform, [
|
|
2164
2249
|
line.endPoint.x,
|
|
2165
2250
|
line.endPoint.y
|
|
2166
2251
|
]);
|
|
@@ -2188,7 +2273,7 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
2188
2273
|
|
|
2189
2274
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-cutout.ts
|
|
2190
2275
|
import {
|
|
2191
|
-
applyToPoint as
|
|
2276
|
+
applyToPoint as applyToPoint23,
|
|
2192
2277
|
compose as compose3,
|
|
2193
2278
|
rotate as rotate3,
|
|
2194
2279
|
translate as translate3,
|
|
@@ -2198,7 +2283,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2198
2283
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
2199
2284
|
if (cutout.shape === "rect") {
|
|
2200
2285
|
const rectCutout = cutout;
|
|
2201
|
-
const [cx, cy] =
|
|
2286
|
+
const [cx, cy] = applyToPoint23(transform, [
|
|
2202
2287
|
rectCutout.center.x,
|
|
2203
2288
|
rectCutout.center.y
|
|
2204
2289
|
]);
|
|
@@ -2229,7 +2314,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2229
2314
|
}
|
|
2230
2315
|
if (cutout.shape === "circle") {
|
|
2231
2316
|
const circleCutout = cutout;
|
|
2232
|
-
const [cx, cy] =
|
|
2317
|
+
const [cx, cy] = applyToPoint23(transform, [
|
|
2233
2318
|
circleCutout.center.x,
|
|
2234
2319
|
circleCutout.center.y
|
|
2235
2320
|
]);
|
|
@@ -2256,7 +2341,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2256
2341
|
const polygonCutout = cutout;
|
|
2257
2342
|
if (!polygonCutout.points || polygonCutout.points.length === 0) return [];
|
|
2258
2343
|
const transformedPoints = polygonCutout.points.map(
|
|
2259
|
-
(p) =>
|
|
2344
|
+
(p) => applyToPoint23(transform, [p.x, p.y])
|
|
2260
2345
|
);
|
|
2261
2346
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
2262
2347
|
return [
|
|
@@ -2280,7 +2365,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2280
2365
|
|
|
2281
2366
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-copper-pour.ts
|
|
2282
2367
|
import {
|
|
2283
|
-
applyToPoint as
|
|
2368
|
+
applyToPoint as applyToPoint25,
|
|
2284
2369
|
compose as compose4,
|
|
2285
2370
|
rotate as rotate4,
|
|
2286
2371
|
toString as matrixToString7,
|
|
@@ -2288,11 +2373,11 @@ import {
|
|
|
2288
2373
|
} from "transformation-matrix";
|
|
2289
2374
|
|
|
2290
2375
|
// lib/utils/ring-to-path-d.ts
|
|
2291
|
-
import { applyToPoint as
|
|
2376
|
+
import { applyToPoint as applyToPoint24 } from "transformation-matrix";
|
|
2292
2377
|
function ringToPathD(vertices, transform) {
|
|
2293
2378
|
if (vertices.length === 0) return "";
|
|
2294
2379
|
const transformedVertices = vertices.map((v) => {
|
|
2295
|
-
const [x, y] =
|
|
2380
|
+
const [x, y] = applyToPoint24(transform, [v.x, v.y]);
|
|
2296
2381
|
return { ...v, x, y };
|
|
2297
2382
|
});
|
|
2298
2383
|
let d = `M ${transformedVertices[0].x} ${transformedVertices[0].y}`;
|
|
@@ -2325,7 +2410,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
2325
2410
|
const color = layerNameToColor(layer, colorMap2);
|
|
2326
2411
|
const opacity = "0.5";
|
|
2327
2412
|
if (pour.shape === "rect") {
|
|
2328
|
-
const [cx, cy] =
|
|
2413
|
+
const [cx, cy] = applyToPoint25(transform, [pour.center.x, pour.center.y]);
|
|
2329
2414
|
const scaledWidth = pour.width * Math.abs(transform.a);
|
|
2330
2415
|
const scaledHeight = pour.height * Math.abs(transform.d);
|
|
2331
2416
|
const svgRotation = -(pour.rotation ?? 0);
|
|
@@ -2355,7 +2440,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
2355
2440
|
if (pour.shape === "polygon") {
|
|
2356
2441
|
if (!pour.points || pour.points.length === 0) return [];
|
|
2357
2442
|
const transformedPoints = pour.points.map(
|
|
2358
|
-
(p) =>
|
|
2443
|
+
(p) => applyToPoint25(transform, [p.x, p.y])
|
|
2359
2444
|
);
|
|
2360
2445
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
2361
2446
|
return [
|
|
@@ -2540,11 +2625,11 @@ function createMajorGridPatternChildren(cellSize, majorCellSize, lineColor, majo
|
|
|
2540
2625
|
}
|
|
2541
2626
|
|
|
2542
2627
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-component.ts
|
|
2543
|
-
import { applyToPoint as
|
|
2628
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
2544
2629
|
function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
2545
2630
|
const { transform } = ctx;
|
|
2546
2631
|
const { center, width, height, rotation = 0 } = component;
|
|
2547
|
-
const [x, y] =
|
|
2632
|
+
const [x, y] = applyToPoint26(transform, [center.x, center.y]);
|
|
2548
2633
|
const scaledWidth = width * Math.abs(transform.a);
|
|
2549
2634
|
const scaledHeight = height * Math.abs(transform.d);
|
|
2550
2635
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
@@ -2594,7 +2679,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
2594
2679
|
var package_default = {
|
|
2595
2680
|
name: "circuit-to-svg",
|
|
2596
2681
|
type: "module",
|
|
2597
|
-
version: "0.0.
|
|
2682
|
+
version: "0.0.232",
|
|
2598
2683
|
description: "Convert Circuit JSON to SVG",
|
|
2599
2684
|
main: "dist/index.js",
|
|
2600
2685
|
files: [
|
|
@@ -2663,6 +2748,7 @@ var TYPE_PRIORITY = {
|
|
|
2663
2748
|
pcb_component: 60,
|
|
2664
2749
|
pcb_fabrication_note_text: 70,
|
|
2665
2750
|
pcb_fabrication_note_path: 70,
|
|
2751
|
+
pcb_fabrication_note_rect: 70,
|
|
2666
2752
|
pcb_note_dimension: 70,
|
|
2667
2753
|
pcb_note_text: 70,
|
|
2668
2754
|
pcb_note_rect: 70,
|
|
@@ -2784,6 +2870,12 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
2784
2870
|
}
|
|
2785
2871
|
} else if ("route" in circuitJsonElm) {
|
|
2786
2872
|
updateTraceBounds(circuitJsonElm.route);
|
|
2873
|
+
} else if (circuitJsonElm.type === "pcb_note_rect" || circuitJsonElm.type === "pcb_fabrication_note_rect") {
|
|
2874
|
+
updateBounds(
|
|
2875
|
+
circuitJsonElm.center,
|
|
2876
|
+
circuitJsonElm.width,
|
|
2877
|
+
circuitJsonElm.height
|
|
2878
|
+
);
|
|
2787
2879
|
} else if (circuitJsonElm.type === "pcb_silkscreen_text" || circuitJsonElm.type === "pcb_silkscreen_rect" || circuitJsonElm.type === "pcb_silkscreen_circle" || circuitJsonElm.type === "pcb_silkscreen_line") {
|
|
2788
2880
|
updateSilkscreenBounds(circuitJsonElm);
|
|
2789
2881
|
} else if (circuitJsonElm.type === "pcb_copper_pour") {
|
|
@@ -3042,6 +3134,8 @@ function createSvgObjects({
|
|
|
3042
3134
|
return createSvgObjectsFromPcbFabricationNotePath(elm, ctx);
|
|
3043
3135
|
case "pcb_fabrication_note_text":
|
|
3044
3136
|
return createSvgObjectsFromPcbFabricationNoteText(elm, ctx);
|
|
3137
|
+
case "pcb_fabrication_note_rect":
|
|
3138
|
+
return createSvgObjectsFromPcbFabricationNoteRect(elm, ctx);
|
|
3045
3139
|
case "pcb_note_dimension":
|
|
3046
3140
|
return createSvgObjectsFromPcbNoteDimension(elm, ctx);
|
|
3047
3141
|
case "pcb_note_text":
|
|
@@ -3065,8 +3159,8 @@ function createSvgObjects({
|
|
|
3065
3159
|
}
|
|
3066
3160
|
}
|
|
3067
3161
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
3068
|
-
const [x1, y1] =
|
|
3069
|
-
const [x2, y2] =
|
|
3162
|
+
const [x1, y1] = applyToPoint27(transform, [minX, minY]);
|
|
3163
|
+
const [x2, y2] = applyToPoint27(transform, [maxX, maxY]);
|
|
3070
3164
|
const width = Math.abs(x2 - x1);
|
|
3071
3165
|
const height = Math.abs(y2 - y1);
|
|
3072
3166
|
const x = Math.min(x1, x2);
|
|
@@ -3096,14 +3190,14 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
3096
3190
|
import { stringify as stringify2 } from "svgson";
|
|
3097
3191
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
3098
3192
|
import {
|
|
3099
|
-
applyToPoint as
|
|
3193
|
+
applyToPoint as applyToPoint34,
|
|
3100
3194
|
compose as compose6,
|
|
3101
3195
|
scale as scale3,
|
|
3102
3196
|
translate as translate6
|
|
3103
3197
|
} from "transformation-matrix";
|
|
3104
3198
|
|
|
3105
3199
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
3106
|
-
import { applyToPoint as
|
|
3200
|
+
import { applyToPoint as applyToPoint28 } from "transformation-matrix";
|
|
3107
3201
|
var DEFAULT_BOARD_STYLE = {
|
|
3108
3202
|
fill: "none",
|
|
3109
3203
|
stroke: "rgb(0,0,0)",
|
|
@@ -3115,25 +3209,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
3115
3209
|
let path;
|
|
3116
3210
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
3117
3211
|
path = outline.map((point, index) => {
|
|
3118
|
-
const [x, y] =
|
|
3212
|
+
const [x, y] = applyToPoint28(transform, [point.x, point.y]);
|
|
3119
3213
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
3120
3214
|
}).join(" ");
|
|
3121
3215
|
} else {
|
|
3122
3216
|
const halfWidth = width / 2;
|
|
3123
3217
|
const halfHeight = height / 2;
|
|
3124
|
-
const topLeft =
|
|
3218
|
+
const topLeft = applyToPoint28(transform, [
|
|
3125
3219
|
center.x - halfWidth,
|
|
3126
3220
|
center.y - halfHeight
|
|
3127
3221
|
]);
|
|
3128
|
-
const topRight =
|
|
3222
|
+
const topRight = applyToPoint28(transform, [
|
|
3129
3223
|
center.x + halfWidth,
|
|
3130
3224
|
center.y - halfHeight
|
|
3131
3225
|
]);
|
|
3132
|
-
const bottomRight =
|
|
3226
|
+
const bottomRight = applyToPoint28(transform, [
|
|
3133
3227
|
center.x + halfWidth,
|
|
3134
3228
|
center.y + halfHeight
|
|
3135
3229
|
]);
|
|
3136
|
-
const bottomLeft =
|
|
3230
|
+
const bottomLeft = applyToPoint28(transform, [
|
|
3137
3231
|
center.x - halfWidth,
|
|
3138
3232
|
center.y + halfHeight
|
|
3139
3233
|
]);
|
|
@@ -3159,7 +3253,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
3159
3253
|
}
|
|
3160
3254
|
|
|
3161
3255
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
3162
|
-
import { applyToPoint as
|
|
3256
|
+
import { applyToPoint as applyToPoint30 } from "transformation-matrix";
|
|
3163
3257
|
|
|
3164
3258
|
// lib/utils/get-sch-font-size.ts
|
|
3165
3259
|
import "transformation-matrix";
|
|
@@ -3185,8 +3279,8 @@ function createSvgObjectsFromAssemblyComponent(params, ctx) {
|
|
|
3185
3279
|
const { center, width, height, rotation = 0, layer = "top" } = elm;
|
|
3186
3280
|
if (!center || typeof width !== "number" || typeof height !== "number")
|
|
3187
3281
|
return null;
|
|
3188
|
-
const [x, y] =
|
|
3189
|
-
const [pinX, pinY] =
|
|
3282
|
+
const [x, y] = applyToPoint30(transform, [center.x, center.y]);
|
|
3283
|
+
const [pinX, pinY] = applyToPoint30(transform, [portPosition.x, portPosition.y]);
|
|
3190
3284
|
const scaledWidth = width * Math.abs(transform.a);
|
|
3191
3285
|
const scaledHeight = height * Math.abs(transform.d);
|
|
3192
3286
|
const isTopLayer = layer === "top";
|
|
@@ -3348,11 +3442,11 @@ function getRectPathData(w, h, rotation) {
|
|
|
3348
3442
|
}
|
|
3349
3443
|
|
|
3350
3444
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-hole.ts
|
|
3351
|
-
import { applyToPoint as
|
|
3445
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
3352
3446
|
var HOLE_COLOR2 = "rgb(190, 190, 190)";
|
|
3353
3447
|
function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
3354
3448
|
const { transform } = ctx;
|
|
3355
|
-
const [x, y] =
|
|
3449
|
+
const [x, y] = applyToPoint31(transform, [hole.x, hole.y]);
|
|
3356
3450
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
3357
3451
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
3358
3452
|
const radius = scaledDiameter / 2;
|
|
@@ -3416,12 +3510,12 @@ function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
|
3416
3510
|
}
|
|
3417
3511
|
|
|
3418
3512
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-plated-hole.ts
|
|
3419
|
-
import { applyToPoint as
|
|
3513
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
3420
3514
|
var PAD_COLOR = "rgb(210, 210, 210)";
|
|
3421
3515
|
var HOLE_COLOR3 = "rgb(190, 190, 190)";
|
|
3422
3516
|
function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
3423
3517
|
const { transform } = ctx;
|
|
3424
|
-
const [x, y] =
|
|
3518
|
+
const [x, y] = applyToPoint32(transform, [hole.x, hole.y]);
|
|
3425
3519
|
if (hole.shape === "pill") {
|
|
3426
3520
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
3427
3521
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -3516,7 +3610,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3516
3610
|
const scaledRectPadHeight = circularHole.rect_pad_height * Math.abs(transform.a);
|
|
3517
3611
|
const scaledRectBorderRadius = (circularHole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
3518
3612
|
const holeRadius = scaledHoleDiameter / 2;
|
|
3519
|
-
const [holeCx, holeCy] =
|
|
3613
|
+
const [holeCx, holeCy] = applyToPoint32(transform, [
|
|
3520
3614
|
circularHole.x + circularHole.hole_offset_x,
|
|
3521
3615
|
circularHole.y + circularHole.hole_offset_y
|
|
3522
3616
|
]);
|
|
@@ -3574,7 +3668,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3574
3668
|
const pillHoleWithOffsets = pillHole;
|
|
3575
3669
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
3576
3670
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
3577
|
-
const [holeCenterX, holeCenterY] =
|
|
3671
|
+
const [holeCenterX, holeCenterY] = applyToPoint32(transform, [
|
|
3578
3672
|
pillHole.x + holeOffsetX,
|
|
3579
3673
|
pillHole.y + holeOffsetY
|
|
3580
3674
|
]);
|
|
@@ -3636,7 +3730,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3636
3730
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
3637
3731
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
3638
3732
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
3639
|
-
const [holeCenterX, holeCenterY] =
|
|
3733
|
+
const [holeCenterX, holeCenterY] = applyToPoint32(transform, [
|
|
3640
3734
|
rotatedHole.x + holeOffsetX,
|
|
3641
3735
|
rotatedHole.y + holeOffsetY
|
|
3642
3736
|
]);
|
|
@@ -3692,14 +3786,14 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3692
3786
|
}
|
|
3693
3787
|
|
|
3694
3788
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-smt-pad.ts
|
|
3695
|
-
import { applyToPoint as
|
|
3789
|
+
import { applyToPoint as applyToPoint33 } from "transformation-matrix";
|
|
3696
3790
|
var PAD_COLOR2 = "rgb(210, 210, 210)";
|
|
3697
3791
|
function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
3698
3792
|
const { transform } = ctx;
|
|
3699
3793
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
3700
3794
|
const width = pad.width * Math.abs(transform.a);
|
|
3701
3795
|
const height = pad.height * Math.abs(transform.d);
|
|
3702
|
-
const [x, y] =
|
|
3796
|
+
const [x, y] = applyToPoint33(transform, [pad.x, pad.y]);
|
|
3703
3797
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
3704
3798
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
3705
3799
|
return [
|
|
@@ -3751,7 +3845,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3751
3845
|
const width = pad.width * Math.abs(transform.a);
|
|
3752
3846
|
const height = pad.height * Math.abs(transform.d);
|
|
3753
3847
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3754
|
-
const [x, y] =
|
|
3848
|
+
const [x, y] = applyToPoint33(transform, [pad.x, pad.y]);
|
|
3755
3849
|
return [
|
|
3756
3850
|
{
|
|
3757
3851
|
name: "rect",
|
|
@@ -3774,7 +3868,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3774
3868
|
}
|
|
3775
3869
|
if (pad.shape === "circle") {
|
|
3776
3870
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3777
|
-
const [x, y] =
|
|
3871
|
+
const [x, y] = applyToPoint33(transform, [pad.x, pad.y]);
|
|
3778
3872
|
return [
|
|
3779
3873
|
{
|
|
3780
3874
|
name: "circle",
|
|
@@ -3794,7 +3888,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3794
3888
|
}
|
|
3795
3889
|
if (pad.shape === "polygon") {
|
|
3796
3890
|
const points = (pad.points ?? []).map(
|
|
3797
|
-
(point) =>
|
|
3891
|
+
(point) => applyToPoint33(transform, [point.x, point.y])
|
|
3798
3892
|
);
|
|
3799
3893
|
return [
|
|
3800
3894
|
{
|
|
@@ -3971,8 +4065,8 @@ function createSvgObjects2(elm, ctx, soup) {
|
|
|
3971
4065
|
}
|
|
3972
4066
|
}
|
|
3973
4067
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
3974
|
-
const [x1, y1] =
|
|
3975
|
-
const [x2, y2] =
|
|
4068
|
+
const [x1, y1] = applyToPoint34(transform, [minX, minY]);
|
|
4069
|
+
const [x2, y2] = applyToPoint34(transform, [maxX, maxY]);
|
|
3976
4070
|
const width = Math.abs(x2 - x1);
|
|
3977
4071
|
const height = Math.abs(y2 - y1);
|
|
3978
4072
|
const x = Math.min(x1, x2);
|
|
@@ -4001,7 +4095,7 @@ import {
|
|
|
4001
4095
|
} from "transformation-matrix";
|
|
4002
4096
|
|
|
4003
4097
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-board.ts
|
|
4004
|
-
import { applyToPoint as
|
|
4098
|
+
import { applyToPoint as applyToPoint35 } from "transformation-matrix";
|
|
4005
4099
|
import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
4006
4100
|
var BOARD_FILL_COLOR = "rgb(26, 115, 143)";
|
|
4007
4101
|
var BOARD_STROKE_COLOR = "rgba(0,0,0,0.9)";
|
|
@@ -4011,25 +4105,25 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4011
4105
|
let path;
|
|
4012
4106
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
4013
4107
|
path = outline.map((point, index) => {
|
|
4014
|
-
const [x, y] =
|
|
4108
|
+
const [x, y] = applyToPoint35(transform, [point.x, point.y]);
|
|
4015
4109
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
4016
4110
|
}).join(" ");
|
|
4017
4111
|
} else {
|
|
4018
4112
|
const halfWidth = width / 2;
|
|
4019
4113
|
const halfHeight = height / 2;
|
|
4020
|
-
const topLeft =
|
|
4114
|
+
const topLeft = applyToPoint35(transform, [
|
|
4021
4115
|
center.x - halfWidth,
|
|
4022
4116
|
center.y - halfHeight
|
|
4023
4117
|
]);
|
|
4024
|
-
const topRight =
|
|
4118
|
+
const topRight = applyToPoint35(transform, [
|
|
4025
4119
|
center.x + halfWidth,
|
|
4026
4120
|
center.y - halfHeight
|
|
4027
4121
|
]);
|
|
4028
|
-
const bottomRight =
|
|
4122
|
+
const bottomRight = applyToPoint35(transform, [
|
|
4029
4123
|
center.x + halfWidth,
|
|
4030
4124
|
center.y + halfHeight
|
|
4031
4125
|
]);
|
|
4032
|
-
const bottomLeft =
|
|
4126
|
+
const bottomLeft = applyToPoint35(transform, [
|
|
4033
4127
|
center.x - halfWidth,
|
|
4034
4128
|
center.y + halfHeight
|
|
4035
4129
|
]);
|
|
@@ -4047,10 +4141,10 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4047
4141
|
const halfWidth = width2 / 2;
|
|
4048
4142
|
const halfHeight = height2 / 2;
|
|
4049
4143
|
const [tl, tr, br, bl] = [
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4144
|
+
applyToPoint35(transform, [x - halfWidth, y - halfHeight]),
|
|
4145
|
+
applyToPoint35(transform, [x + halfWidth, y - halfHeight]),
|
|
4146
|
+
applyToPoint35(transform, [x + halfWidth, y + halfHeight]),
|
|
4147
|
+
applyToPoint35(transform, [x - halfWidth, y + halfHeight])
|
|
4054
4148
|
];
|
|
4055
4149
|
path += ` M ${tl[0]} ${tl[1]} L ${tr[0]} ${tr[1]} L ${br[0]} ${br[1]} L ${bl[0]} ${bl[1]} Z`;
|
|
4056
4150
|
} else if (cutout.shape === "circle") {
|
|
@@ -4077,7 +4171,7 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4077
4171
|
|
|
4078
4172
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-component.ts
|
|
4079
4173
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
4080
|
-
import { applyToPoint as
|
|
4174
|
+
import { applyToPoint as applyToPoint36 } from "transformation-matrix";
|
|
4081
4175
|
var COMPONENT_FILL_COLOR = "rgba(120, 120, 120, 0.6)";
|
|
4082
4176
|
var COMPONENT_LABEL_COLOR = "rgba(255, 255, 255, 0.9)";
|
|
4083
4177
|
function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
@@ -4087,7 +4181,7 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
4087
4181
|
if (!center || typeof width !== "number" || typeof height !== "number" || width === 0 || height === 0) {
|
|
4088
4182
|
return [];
|
|
4089
4183
|
}
|
|
4090
|
-
const [x, y] =
|
|
4184
|
+
const [x, y] = applyToPoint36(transform, [center.x, center.y]);
|
|
4091
4185
|
const scaledWidth = width * Math.abs(transform.a);
|
|
4092
4186
|
const scaledHeight = height * Math.abs(transform.d);
|
|
4093
4187
|
const transformStr = `translate(${x}, ${y})`;
|
|
@@ -4148,11 +4242,11 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
4148
4242
|
}
|
|
4149
4243
|
|
|
4150
4244
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-hole.ts
|
|
4151
|
-
import { applyToPoint as
|
|
4245
|
+
import { applyToPoint as applyToPoint37 } from "transformation-matrix";
|
|
4152
4246
|
var HOLE_COLOR4 = "rgb(50, 50, 50)";
|
|
4153
4247
|
function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
4154
4248
|
const { transform } = ctx;
|
|
4155
|
-
const [x, y] =
|
|
4249
|
+
const [x, y] = applyToPoint37(transform, [hole.x, hole.y]);
|
|
4156
4250
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
4157
4251
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
4158
4252
|
const radius = scaledDiameter / 2;
|
|
@@ -4216,12 +4310,12 @@ function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
|
4216
4310
|
}
|
|
4217
4311
|
|
|
4218
4312
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-plated-hole.ts
|
|
4219
|
-
import { applyToPoint as
|
|
4313
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
4220
4314
|
var PAD_COLOR3 = "rgb(218, 165, 32)";
|
|
4221
4315
|
var HOLE_COLOR5 = "rgb(40, 40, 40)";
|
|
4222
4316
|
function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
4223
4317
|
const { transform } = ctx;
|
|
4224
|
-
const [x, y] =
|
|
4318
|
+
const [x, y] = applyToPoint38(transform, [hole.x, hole.y]);
|
|
4225
4319
|
if (hole.shape === "pill") {
|
|
4226
4320
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
4227
4321
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -4456,14 +4550,14 @@ function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
|
4456
4550
|
}
|
|
4457
4551
|
|
|
4458
4552
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-smt-pad.ts
|
|
4459
|
-
import { applyToPoint as
|
|
4553
|
+
import { applyToPoint as applyToPoint39 } from "transformation-matrix";
|
|
4460
4554
|
var PAD_COLOR4 = "rgb(218, 165, 32)";
|
|
4461
4555
|
function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
4462
4556
|
const { transform } = ctx;
|
|
4463
4557
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
4464
4558
|
const width = pad.width * Math.abs(transform.a);
|
|
4465
4559
|
const height = pad.height * Math.abs(transform.d);
|
|
4466
|
-
const [x, y] =
|
|
4560
|
+
const [x, y] = applyToPoint39(transform, [pad.x, pad.y]);
|
|
4467
4561
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
4468
4562
|
return [
|
|
4469
4563
|
{
|
|
@@ -4506,7 +4600,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4506
4600
|
const width = pad.width * Math.abs(transform.a);
|
|
4507
4601
|
const height = pad.height * Math.abs(transform.d);
|
|
4508
4602
|
const radius = pad.radius * Math.abs(transform.a);
|
|
4509
|
-
const [x, y] =
|
|
4603
|
+
const [x, y] = applyToPoint39(transform, [pad.x, pad.y]);
|
|
4510
4604
|
return [
|
|
4511
4605
|
{
|
|
4512
4606
|
name: "rect",
|
|
@@ -4529,7 +4623,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4529
4623
|
}
|
|
4530
4624
|
if (pad.shape === "circle") {
|
|
4531
4625
|
const radius = pad.radius * Math.abs(transform.a);
|
|
4532
|
-
const [x, y] =
|
|
4626
|
+
const [x, y] = applyToPoint39(transform, [pad.x, pad.y]);
|
|
4533
4627
|
return [
|
|
4534
4628
|
{
|
|
4535
4629
|
name: "circle",
|
|
@@ -4549,7 +4643,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4549
4643
|
}
|
|
4550
4644
|
if (pad.shape === "polygon") {
|
|
4551
4645
|
const points = (pad.points ?? []).map(
|
|
4552
|
-
(point) =>
|
|
4646
|
+
(point) => applyToPoint39(transform, [point.x, point.y])
|
|
4553
4647
|
);
|
|
4554
4648
|
return [
|
|
4555
4649
|
{
|
|
@@ -4570,7 +4664,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4570
4664
|
}
|
|
4571
4665
|
|
|
4572
4666
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-port.ts
|
|
4573
|
-
import { applyToPoint as
|
|
4667
|
+
import { applyToPoint as applyToPoint40 } from "transformation-matrix";
|
|
4574
4668
|
import { calculateElbow } from "calculate-elbow";
|
|
4575
4669
|
|
|
4576
4670
|
// lib/pinout/svg-object-fns/pinout-label-box.ts
|
|
@@ -4647,7 +4741,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
4647
4741
|
const label_info = ctx.label_positions.get(pcb_port.pcb_port_id);
|
|
4648
4742
|
if (!label_info) return [];
|
|
4649
4743
|
const { text: label, aliases, elbow_end, label_pos, edge } = label_info;
|
|
4650
|
-
const [port_x, port_y] =
|
|
4744
|
+
const [port_x, port_y] = applyToPoint40(ctx.transform, [pcb_port.x, pcb_port.y]);
|
|
4651
4745
|
const start_facing_direction = edge === "left" ? "x-" : edge === "right" ? "x+" : edge === "top" ? "y-" : "y+";
|
|
4652
4746
|
const end_facing_direction = edge === "left" ? "x+" : edge === "right" ? "x-" : edge === "top" ? "y+" : "y-";
|
|
4653
4747
|
const elbow_path = calculateElbow(
|
|
@@ -4788,7 +4882,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
4788
4882
|
}
|
|
4789
4883
|
|
|
4790
4884
|
// lib/pinout/calculate-label-positions.ts
|
|
4791
|
-
import { applyToPoint as
|
|
4885
|
+
import { applyToPoint as applyToPoint41 } from "transformation-matrix";
|
|
4792
4886
|
|
|
4793
4887
|
// lib/pinout/constants.ts
|
|
4794
4888
|
var LABEL_RECT_HEIGHT_BASE_MM = 1.6;
|
|
@@ -4826,7 +4920,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4826
4920
|
);
|
|
4827
4921
|
const mapToEdgePort = (pinout_label) => ({
|
|
4828
4922
|
pcb_port: pinout_label.pcb_port,
|
|
4829
|
-
y:
|
|
4923
|
+
y: applyToPoint41(transform, [
|
|
4830
4924
|
pinout_label.pcb_port.x,
|
|
4831
4925
|
pinout_label.pcb_port.y
|
|
4832
4926
|
])[1],
|
|
@@ -4841,7 +4935,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4841
4935
|
} else {
|
|
4842
4936
|
edge_ports = pinout_labels.map((pinout_label) => ({
|
|
4843
4937
|
pcb_port: pinout_label.pcb_port,
|
|
4844
|
-
y:
|
|
4938
|
+
y: applyToPoint41(transform, [
|
|
4845
4939
|
pinout_label.pcb_port.x,
|
|
4846
4940
|
pinout_label.pcb_port.y
|
|
4847
4941
|
])[1],
|
|
@@ -4849,7 +4943,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4849
4943
|
})).sort((a, b) => a.y - b.y);
|
|
4850
4944
|
}
|
|
4851
4945
|
if (edge_ports.length === 0) return;
|
|
4852
|
-
const board_edge_x =
|
|
4946
|
+
const board_edge_x = applyToPoint41(transform, [
|
|
4853
4947
|
edge === "left" ? board_bounds.minX : board_bounds.maxX,
|
|
4854
4948
|
0
|
|
4855
4949
|
])[0];
|
|
@@ -5498,14 +5592,14 @@ import {
|
|
|
5498
5592
|
} from "transformation-matrix";
|
|
5499
5593
|
|
|
5500
5594
|
// lib/sch/draw-schematic-grid.ts
|
|
5501
|
-
import { applyToPoint as
|
|
5595
|
+
import { applyToPoint as applyToPoint42 } from "transformation-matrix";
|
|
5502
5596
|
function drawSchematicGrid(params) {
|
|
5503
5597
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
5504
5598
|
const cellSize = params.cellSize ?? 1;
|
|
5505
5599
|
const labelCells = params.labelCells ?? false;
|
|
5506
5600
|
const gridLines = [];
|
|
5507
5601
|
const transformPoint = (x, y) => {
|
|
5508
|
-
const [transformedX, transformedY] =
|
|
5602
|
+
const [transformedX, transformedY] = applyToPoint42(params.transform, [x, y]);
|
|
5509
5603
|
return { x: transformedX, y: transformedY };
|
|
5510
5604
|
};
|
|
5511
5605
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -5586,15 +5680,15 @@ function drawSchematicGrid(params) {
|
|
|
5586
5680
|
}
|
|
5587
5681
|
|
|
5588
5682
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
5589
|
-
import { applyToPoint as
|
|
5683
|
+
import { applyToPoint as applyToPoint43 } from "transformation-matrix";
|
|
5590
5684
|
function drawSchematicLabeledPoints(params) {
|
|
5591
5685
|
const { points, transform } = params;
|
|
5592
5686
|
const labeledPointsGroup = [];
|
|
5593
5687
|
for (const point of points) {
|
|
5594
|
-
const [x1, y1] =
|
|
5595
|
-
const [x2, y2] =
|
|
5596
|
-
const [x3, y3] =
|
|
5597
|
-
const [x4, y4] =
|
|
5688
|
+
const [x1, y1] = applyToPoint43(transform, [point.x - 0.1, point.y - 0.1]);
|
|
5689
|
+
const [x2, y2] = applyToPoint43(transform, [point.x + 0.1, point.y + 0.1]);
|
|
5690
|
+
const [x3, y3] = applyToPoint43(transform, [point.x - 0.1, point.y + 0.1]);
|
|
5691
|
+
const [x4, y4] = applyToPoint43(transform, [point.x + 0.1, point.y - 0.1]);
|
|
5598
5692
|
labeledPointsGroup.push({
|
|
5599
5693
|
name: "path",
|
|
5600
5694
|
type: "element",
|
|
@@ -5605,7 +5699,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
5605
5699
|
"stroke-opacity": "0.7"
|
|
5606
5700
|
}
|
|
5607
5701
|
});
|
|
5608
|
-
const [labelX, labelY] =
|
|
5702
|
+
const [labelX, labelY] = applyToPoint43(transform, [
|
|
5609
5703
|
point.x + 0.15,
|
|
5610
5704
|
point.y - 0.15
|
|
5611
5705
|
]);
|
|
@@ -6699,7 +6793,7 @@ import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
|
6699
6793
|
import { symbols } from "schematic-symbols";
|
|
6700
6794
|
import "svgson";
|
|
6701
6795
|
import {
|
|
6702
|
-
applyToPoint as
|
|
6796
|
+
applyToPoint as applyToPoint45,
|
|
6703
6797
|
compose as compose9
|
|
6704
6798
|
} from "transformation-matrix";
|
|
6705
6799
|
|
|
@@ -6783,13 +6877,13 @@ function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
|
6783
6877
|
}
|
|
6784
6878
|
|
|
6785
6879
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
6786
|
-
import { applyToPoint as
|
|
6880
|
+
import { applyToPoint as applyToPoint44 } from "transformation-matrix";
|
|
6787
6881
|
var createSvgSchErrorText = ({
|
|
6788
6882
|
text,
|
|
6789
6883
|
realCenter,
|
|
6790
6884
|
realToScreenTransform
|
|
6791
6885
|
}) => {
|
|
6792
|
-
const screenCenter =
|
|
6886
|
+
const screenCenter = applyToPoint44(realToScreenTransform, realCenter);
|
|
6793
6887
|
return {
|
|
6794
6888
|
type: "element",
|
|
6795
6889
|
name: "text",
|
|
@@ -6898,11 +6992,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6898
6992
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
6899
6993
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
6900
6994
|
};
|
|
6901
|
-
const [screenMinX, screenMinY] =
|
|
6995
|
+
const [screenMinX, screenMinY] = applyToPoint45(
|
|
6902
6996
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6903
6997
|
[bounds.minX, bounds.minY]
|
|
6904
6998
|
);
|
|
6905
|
-
const [screenMaxX, screenMaxY] =
|
|
6999
|
+
const [screenMaxX, screenMaxY] = applyToPoint45(
|
|
6906
7000
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6907
7001
|
[bounds.maxX, bounds.maxY]
|
|
6908
7002
|
);
|
|
@@ -6931,7 +7025,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6931
7025
|
name: "path",
|
|
6932
7026
|
attributes: {
|
|
6933
7027
|
d: points.map((p, i) => {
|
|
6934
|
-
const [x, y] =
|
|
7028
|
+
const [x, y] = applyToPoint45(
|
|
6935
7029
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6936
7030
|
[p.x, p.y]
|
|
6937
7031
|
);
|
|
@@ -6947,7 +7041,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6947
7041
|
});
|
|
6948
7042
|
}
|
|
6949
7043
|
for (const text of texts) {
|
|
6950
|
-
const screenTextPos =
|
|
7044
|
+
const screenTextPos = applyToPoint45(
|
|
6951
7045
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6952
7046
|
text
|
|
6953
7047
|
);
|
|
@@ -6999,7 +7093,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6999
7093
|
});
|
|
7000
7094
|
}
|
|
7001
7095
|
for (const box of boxes) {
|
|
7002
|
-
const screenBoxPos =
|
|
7096
|
+
const screenBoxPos = applyToPoint45(
|
|
7003
7097
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7004
7098
|
box
|
|
7005
7099
|
);
|
|
@@ -7023,7 +7117,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7023
7117
|
}
|
|
7024
7118
|
for (const port of symbol.ports) {
|
|
7025
7119
|
if (connectedSymbolPorts.has(port)) continue;
|
|
7026
|
-
const screenPortPos =
|
|
7120
|
+
const screenPortPos = applyToPoint45(
|
|
7027
7121
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7028
7122
|
port
|
|
7029
7123
|
);
|
|
@@ -7043,7 +7137,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7043
7137
|
});
|
|
7044
7138
|
}
|
|
7045
7139
|
for (const circle of circles) {
|
|
7046
|
-
const screenCirclePos =
|
|
7140
|
+
const screenCirclePos = applyToPoint45(
|
|
7047
7141
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7048
7142
|
circle
|
|
7049
7143
|
);
|
|
@@ -7070,14 +7164,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7070
7164
|
import { su as su10 } from "@tscircuit/circuit-json-util";
|
|
7071
7165
|
import "schematic-symbols";
|
|
7072
7166
|
import "svgson";
|
|
7073
|
-
import { applyToPoint as
|
|
7167
|
+
import { applyToPoint as applyToPoint51 } from "transformation-matrix";
|
|
7074
7168
|
|
|
7075
7169
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
7076
7170
|
import "transformation-matrix";
|
|
7077
7171
|
import "@tscircuit/circuit-json-util";
|
|
7078
7172
|
|
|
7079
7173
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
7080
|
-
import { applyToPoint as
|
|
7174
|
+
import { applyToPoint as applyToPoint46 } from "transformation-matrix";
|
|
7081
7175
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
7082
7176
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
7083
7177
|
var createArrow = (tip, angle, size, color, strokeWidth) => {
|
|
@@ -7130,8 +7224,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7130
7224
|
realEdgePos.y += realPinLineLength;
|
|
7131
7225
|
break;
|
|
7132
7226
|
}
|
|
7133
|
-
const screenSchPortPos =
|
|
7134
|
-
const screenRealEdgePos =
|
|
7227
|
+
const screenSchPortPos = applyToPoint46(transform, schPort.center);
|
|
7228
|
+
const screenRealEdgePos = applyToPoint46(transform, realEdgePos);
|
|
7135
7229
|
const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
|
|
7136
7230
|
const realLineEnd = { ...schPort.center };
|
|
7137
7231
|
if (!isConnected) {
|
|
@@ -7150,7 +7244,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7150
7244
|
break;
|
|
7151
7245
|
}
|
|
7152
7246
|
}
|
|
7153
|
-
const screenLineEnd =
|
|
7247
|
+
const screenLineEnd = applyToPoint46(transform, realLineEnd);
|
|
7154
7248
|
svgObjects.push({
|
|
7155
7249
|
name: "line",
|
|
7156
7250
|
type: "element",
|
|
@@ -7271,7 +7365,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7271
7365
|
};
|
|
7272
7366
|
|
|
7273
7367
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
7274
|
-
import { applyToPoint as
|
|
7368
|
+
import { applyToPoint as applyToPoint47 } from "transformation-matrix";
|
|
7275
7369
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
7276
7370
|
const svgObjects = [];
|
|
7277
7371
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -7289,7 +7383,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
7289
7383
|
} else {
|
|
7290
7384
|
realPinNumberPos.y += 0.02;
|
|
7291
7385
|
}
|
|
7292
|
-
const screenPinNumberTextPos =
|
|
7386
|
+
const screenPinNumberTextPos = applyToPoint47(transform, realPinNumberPos);
|
|
7293
7387
|
svgObjects.push({
|
|
7294
7388
|
name: "text",
|
|
7295
7389
|
type: "element",
|
|
@@ -7319,7 +7413,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
7319
7413
|
};
|
|
7320
7414
|
|
|
7321
7415
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
7322
|
-
import { applyToPoint as
|
|
7416
|
+
import { applyToPoint as applyToPoint48 } from "transformation-matrix";
|
|
7323
7417
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
7324
7418
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
7325
7419
|
const svgObjects = [];
|
|
@@ -7333,7 +7427,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
7333
7427
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
7334
7428
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
7335
7429
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
7336
|
-
const screenPinNumberTextPos =
|
|
7430
|
+
const screenPinNumberTextPos = applyToPoint48(transform, realPinNumberPos);
|
|
7337
7431
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
7338
7432
|
if (!label) return [];
|
|
7339
7433
|
const isNegated = label.startsWith("N_");
|
|
@@ -7381,13 +7475,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
7381
7475
|
};
|
|
7382
7476
|
|
|
7383
7477
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
7384
|
-
import { applyToPoint as
|
|
7478
|
+
import { applyToPoint as applyToPoint50 } from "transformation-matrix";
|
|
7385
7479
|
var createSvgSchText = ({
|
|
7386
7480
|
elm,
|
|
7387
7481
|
transform,
|
|
7388
7482
|
colorMap: colorMap2
|
|
7389
7483
|
}) => {
|
|
7390
|
-
const center =
|
|
7484
|
+
const center = applyToPoint50(transform, elm.position);
|
|
7391
7485
|
const textAnchorMap = {
|
|
7392
7486
|
center: "middle",
|
|
7393
7487
|
center_right: "end",
|
|
@@ -7471,11 +7565,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
7471
7565
|
colorMap: colorMap2
|
|
7472
7566
|
}) => {
|
|
7473
7567
|
const svgObjects = [];
|
|
7474
|
-
const componentScreenTopLeft =
|
|
7568
|
+
const componentScreenTopLeft = applyToPoint51(transform, {
|
|
7475
7569
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
7476
7570
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
7477
7571
|
});
|
|
7478
|
-
const componentScreenBottomRight =
|
|
7572
|
+
const componentScreenBottomRight = applyToPoint51(transform, {
|
|
7479
7573
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
7480
7574
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
7481
7575
|
});
|
|
@@ -7561,13 +7655,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
7561
7655
|
}
|
|
7562
7656
|
|
|
7563
7657
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
7564
|
-
import { applyToPoint as
|
|
7658
|
+
import { applyToPoint as applyToPoint52 } from "transformation-matrix";
|
|
7565
7659
|
function createSvgObjectsFromSchVoltageProbe({
|
|
7566
7660
|
probe,
|
|
7567
7661
|
transform,
|
|
7568
7662
|
colorMap: colorMap2
|
|
7569
7663
|
}) {
|
|
7570
|
-
const [screenX, screenY] =
|
|
7664
|
+
const [screenX, screenY] = applyToPoint52(transform, [
|
|
7571
7665
|
probe.position.x,
|
|
7572
7666
|
probe.position.y
|
|
7573
7667
|
]);
|
|
@@ -7627,17 +7721,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
7627
7721
|
}
|
|
7628
7722
|
|
|
7629
7723
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
7630
|
-
import { applyToPoint as
|
|
7724
|
+
import { applyToPoint as applyToPoint53 } from "transformation-matrix";
|
|
7631
7725
|
function createSvgObjectsFromSchDebugObject({
|
|
7632
7726
|
debugObject,
|
|
7633
7727
|
transform
|
|
7634
7728
|
}) {
|
|
7635
7729
|
if (debugObject.shape === "rect") {
|
|
7636
|
-
let [screenLeft, screenTop] =
|
|
7730
|
+
let [screenLeft, screenTop] = applyToPoint53(transform, [
|
|
7637
7731
|
debugObject.center.x - debugObject.size.width / 2,
|
|
7638
7732
|
debugObject.center.y - debugObject.size.height / 2
|
|
7639
7733
|
]);
|
|
7640
|
-
let [screenRight, screenBottom] =
|
|
7734
|
+
let [screenRight, screenBottom] = applyToPoint53(transform, [
|
|
7641
7735
|
debugObject.center.x + debugObject.size.width / 2,
|
|
7642
7736
|
debugObject.center.y + debugObject.size.height / 2
|
|
7643
7737
|
]);
|
|
@@ -7647,7 +7741,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
7647
7741
|
];
|
|
7648
7742
|
const width = Math.abs(screenRight - screenLeft);
|
|
7649
7743
|
const height = Math.abs(screenBottom - screenTop);
|
|
7650
|
-
const [screenCenterX, screenCenterY] =
|
|
7744
|
+
const [screenCenterX, screenCenterY] = applyToPoint53(transform, [
|
|
7651
7745
|
debugObject.center.x,
|
|
7652
7746
|
debugObject.center.y
|
|
7653
7747
|
]);
|
|
@@ -7693,11 +7787,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
7693
7787
|
];
|
|
7694
7788
|
}
|
|
7695
7789
|
if (debugObject.shape === "line") {
|
|
7696
|
-
const [screenStartX, screenStartY] =
|
|
7790
|
+
const [screenStartX, screenStartY] = applyToPoint53(transform, [
|
|
7697
7791
|
debugObject.start.x,
|
|
7698
7792
|
debugObject.start.y
|
|
7699
7793
|
]);
|
|
7700
|
-
const [screenEndX, screenEndY] =
|
|
7794
|
+
const [screenEndX, screenEndY] = applyToPoint53(transform, [
|
|
7701
7795
|
debugObject.end.x,
|
|
7702
7796
|
debugObject.end.y
|
|
7703
7797
|
]);
|
|
@@ -7747,7 +7841,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
7747
7841
|
}
|
|
7748
7842
|
|
|
7749
7843
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
7750
|
-
import { applyToPoint as
|
|
7844
|
+
import { applyToPoint as applyToPoint54 } from "transformation-matrix";
|
|
7751
7845
|
function createSchematicTrace({
|
|
7752
7846
|
trace,
|
|
7753
7847
|
transform,
|
|
@@ -7761,11 +7855,11 @@ function createSchematicTrace({
|
|
|
7761
7855
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
7762
7856
|
const edge = edges[edgeIndex];
|
|
7763
7857
|
if (edge.is_crossing) continue;
|
|
7764
|
-
const [screenFromX, screenFromY] =
|
|
7858
|
+
const [screenFromX, screenFromY] = applyToPoint54(transform, [
|
|
7765
7859
|
edge.from.x,
|
|
7766
7860
|
edge.from.y
|
|
7767
7861
|
]);
|
|
7768
|
-
const [screenToX, screenToY] =
|
|
7862
|
+
const [screenToX, screenToY] = applyToPoint54(transform, [
|
|
7769
7863
|
edge.to.x,
|
|
7770
7864
|
edge.to.y
|
|
7771
7865
|
]);
|
|
@@ -7809,11 +7903,11 @@ function createSchematicTrace({
|
|
|
7809
7903
|
}
|
|
7810
7904
|
for (const edge of edges) {
|
|
7811
7905
|
if (!edge.is_crossing) continue;
|
|
7812
|
-
const [screenFromX, screenFromY] =
|
|
7906
|
+
const [screenFromX, screenFromY] = applyToPoint54(transform, [
|
|
7813
7907
|
edge.from.x,
|
|
7814
7908
|
edge.from.y
|
|
7815
7909
|
]);
|
|
7816
|
-
const [screenToX, screenToY] =
|
|
7910
|
+
const [screenToX, screenToY] = applyToPoint54(transform, [
|
|
7817
7911
|
edge.to.x,
|
|
7818
7912
|
edge.to.y
|
|
7819
7913
|
]);
|
|
@@ -7857,7 +7951,7 @@ function createSchematicTrace({
|
|
|
7857
7951
|
}
|
|
7858
7952
|
if (trace.junctions) {
|
|
7859
7953
|
for (const junction of trace.junctions) {
|
|
7860
|
-
const [screenX, screenY] =
|
|
7954
|
+
const [screenX, screenY] = applyToPoint54(transform, [
|
|
7861
7955
|
junction.x,
|
|
7862
7956
|
junction.y
|
|
7863
7957
|
]);
|
|
@@ -7912,7 +8006,7 @@ function createSchematicTrace({
|
|
|
7912
8006
|
|
|
7913
8007
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
7914
8008
|
import {
|
|
7915
|
-
applyToPoint as
|
|
8009
|
+
applyToPoint as applyToPoint56,
|
|
7916
8010
|
compose as compose11,
|
|
7917
8011
|
rotate as rotate6,
|
|
7918
8012
|
scale as scale6,
|
|
@@ -7921,7 +8015,7 @@ import {
|
|
|
7921
8015
|
|
|
7922
8016
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
7923
8017
|
import {
|
|
7924
|
-
applyToPoint as
|
|
8018
|
+
applyToPoint as applyToPoint55,
|
|
7925
8019
|
compose as compose10,
|
|
7926
8020
|
rotate as rotate5,
|
|
7927
8021
|
scale as scale5,
|
|
@@ -7996,7 +8090,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7996
8090
|
x: symbolBounds.minX,
|
|
7997
8091
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
7998
8092
|
};
|
|
7999
|
-
const rotatedSymbolEnd =
|
|
8093
|
+
const rotatedSymbolEnd = applyToPoint55(rotationMatrix, symbolEndPoint);
|
|
8000
8094
|
const symbolToRealTransform = compose10(
|
|
8001
8095
|
translate10(
|
|
8002
8096
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
@@ -8006,11 +8100,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8006
8100
|
scale5(1)
|
|
8007
8101
|
// Use full symbol size
|
|
8008
8102
|
);
|
|
8009
|
-
const [screenMinX, screenMinY] =
|
|
8103
|
+
const [screenMinX, screenMinY] = applyToPoint55(
|
|
8010
8104
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8011
8105
|
[bounds.minX, bounds.minY]
|
|
8012
8106
|
);
|
|
8013
|
-
const [screenMaxX, screenMaxY] =
|
|
8107
|
+
const [screenMaxX, screenMaxY] = applyToPoint55(
|
|
8014
8108
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8015
8109
|
[bounds.maxX, bounds.maxY]
|
|
8016
8110
|
);
|
|
@@ -8034,7 +8128,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8034
8128
|
});
|
|
8035
8129
|
for (const path of symbolPaths) {
|
|
8036
8130
|
const symbolPath = path.points.map((p, i) => {
|
|
8037
|
-
const [x, y] =
|
|
8131
|
+
const [x, y] = applyToPoint55(
|
|
8038
8132
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8039
8133
|
[p.x, p.y]
|
|
8040
8134
|
);
|
|
@@ -8055,7 +8149,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8055
8149
|
});
|
|
8056
8150
|
}
|
|
8057
8151
|
for (const text of symbolTexts) {
|
|
8058
|
-
const screenTextPos =
|
|
8152
|
+
const screenTextPos = applyToPoint55(
|
|
8059
8153
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8060
8154
|
text
|
|
8061
8155
|
);
|
|
@@ -8097,7 +8191,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8097
8191
|
});
|
|
8098
8192
|
}
|
|
8099
8193
|
for (const box of symbolBoxes) {
|
|
8100
|
-
const screenBoxPos =
|
|
8194
|
+
const screenBoxPos = applyToPoint55(
|
|
8101
8195
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8102
8196
|
box
|
|
8103
8197
|
);
|
|
@@ -8120,7 +8214,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8120
8214
|
});
|
|
8121
8215
|
}
|
|
8122
8216
|
for (const circle of symbolCircles) {
|
|
8123
|
-
const screenCirclePos =
|
|
8217
|
+
const screenCirclePos = applyToPoint55(
|
|
8124
8218
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8125
8219
|
circle
|
|
8126
8220
|
);
|
|
@@ -8165,14 +8259,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
8165
8259
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
8166
8260
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
8167
8261
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
8168
|
-
const screenCenter =
|
|
8262
|
+
const screenCenter = applyToPoint56(realToScreenTransform, schNetLabel.center);
|
|
8169
8263
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
8170
8264
|
schNetLabel.anchor_side
|
|
8171
8265
|
);
|
|
8172
8266
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
8173
8267
|
screenTextGrowthVec.y *= -1;
|
|
8174
8268
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
8175
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
8269
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint56(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
8176
8270
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
8177
8271
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
8178
8272
|
};
|
|
@@ -8213,7 +8307,7 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
8213
8307
|
y: -0.6
|
|
8214
8308
|
}
|
|
8215
8309
|
].map(
|
|
8216
|
-
(fontRelativePoint) =>
|
|
8310
|
+
(fontRelativePoint) => applyToPoint56(
|
|
8217
8311
|
compose11(
|
|
8218
8312
|
realToScreenTransform,
|
|
8219
8313
|
translate11(realAnchorPosition.x, realAnchorPosition.y),
|
|
@@ -8290,17 +8384,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
8290
8384
|
};
|
|
8291
8385
|
|
|
8292
8386
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
8293
|
-
import { applyToPoint as
|
|
8387
|
+
import { applyToPoint as applyToPoint57 } from "transformation-matrix";
|
|
8294
8388
|
var createSvgObjectsFromSchematicBox = ({
|
|
8295
8389
|
schematicBox,
|
|
8296
8390
|
transform,
|
|
8297
8391
|
colorMap: colorMap2
|
|
8298
8392
|
}) => {
|
|
8299
|
-
const topLeft =
|
|
8393
|
+
const topLeft = applyToPoint57(transform, {
|
|
8300
8394
|
x: schematicBox.x,
|
|
8301
8395
|
y: schematicBox.y
|
|
8302
8396
|
});
|
|
8303
|
-
const bottomRight =
|
|
8397
|
+
const bottomRight = applyToPoint57(transform, {
|
|
8304
8398
|
x: schematicBox.x + schematicBox.width,
|
|
8305
8399
|
y: schematicBox.y + schematicBox.height
|
|
8306
8400
|
});
|
|
@@ -8336,7 +8430,7 @@ var createSvgObjectsFromSchematicBox = ({
|
|
|
8336
8430
|
};
|
|
8337
8431
|
|
|
8338
8432
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-table.ts
|
|
8339
|
-
import { applyToPoint as
|
|
8433
|
+
import { applyToPoint as applyToPoint58 } from "transformation-matrix";
|
|
8340
8434
|
var createSvgObjectsFromSchematicTable = ({
|
|
8341
8435
|
schematicTable,
|
|
8342
8436
|
transform,
|
|
@@ -8369,11 +8463,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8369
8463
|
const svgObjects = [];
|
|
8370
8464
|
const borderStrokeWidth = border_width * Math.abs(transform.a);
|
|
8371
8465
|
const gridStrokeWidth = getSchStrokeSize(transform);
|
|
8372
|
-
const [screenTopLeftX, screenTopLeftY] =
|
|
8466
|
+
const [screenTopLeftX, screenTopLeftY] = applyToPoint58(transform, [
|
|
8373
8467
|
topLeftX,
|
|
8374
8468
|
topLeftY
|
|
8375
8469
|
]);
|
|
8376
|
-
const [screenBottomRightX, screenBottomRightY] =
|
|
8470
|
+
const [screenBottomRightX, screenBottomRightY] = applyToPoint58(transform, [
|
|
8377
8471
|
topLeftX + totalWidth,
|
|
8378
8472
|
topLeftY - totalHeight
|
|
8379
8473
|
]);
|
|
@@ -8405,8 +8499,8 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8405
8499
|
(cell) => cell.start_column_index <= i && cell.end_column_index > i && cell.start_row_index <= j && cell.end_row_index >= j
|
|
8406
8500
|
);
|
|
8407
8501
|
if (!isMerged) {
|
|
8408
|
-
const start =
|
|
8409
|
-
const end =
|
|
8502
|
+
const start = applyToPoint58(transform, { x: currentX, y: segmentStartY });
|
|
8503
|
+
const end = applyToPoint58(transform, { x: currentX, y: segmentEndY });
|
|
8410
8504
|
svgObjects.push({
|
|
8411
8505
|
name: "line",
|
|
8412
8506
|
type: "element",
|
|
@@ -8435,11 +8529,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8435
8529
|
(cell) => cell.start_row_index <= i && cell.end_row_index > i && cell.start_column_index <= j && cell.end_column_index >= j
|
|
8436
8530
|
);
|
|
8437
8531
|
if (!isMerged) {
|
|
8438
|
-
const start =
|
|
8532
|
+
const start = applyToPoint58(transform, {
|
|
8439
8533
|
x: segmentStartX,
|
|
8440
8534
|
y: currentY
|
|
8441
8535
|
});
|
|
8442
|
-
const end =
|
|
8536
|
+
const end = applyToPoint58(transform, { x: segmentEndX, y: currentY });
|
|
8443
8537
|
svgObjects.push({
|
|
8444
8538
|
name: "line",
|
|
8445
8539
|
type: "element",
|
|
@@ -8481,7 +8575,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8481
8575
|
} else if (vertical_align === "bottom") {
|
|
8482
8576
|
realTextAnchorPos.y = cellTopLeftY - cellHeight + cell_padding;
|
|
8483
8577
|
}
|
|
8484
|
-
const screenTextAnchorPos =
|
|
8578
|
+
const screenTextAnchorPos = applyToPoint58(transform, realTextAnchorPos);
|
|
8485
8579
|
const fontSize = getSchScreenFontSize(
|
|
8486
8580
|
transform,
|
|
8487
8581
|
"reference_designator",
|
|
@@ -8537,13 +8631,13 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8537
8631
|
|
|
8538
8632
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
|
|
8539
8633
|
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
8540
|
-
import { applyToPoint as
|
|
8634
|
+
import { applyToPoint as applyToPoint59 } from "transformation-matrix";
|
|
8541
8635
|
var PIN_CIRCLE_RADIUS_MM2 = 0.02;
|
|
8542
8636
|
var createSvgObjectsForSchPortHover = ({
|
|
8543
8637
|
schPort,
|
|
8544
8638
|
transform
|
|
8545
8639
|
}) => {
|
|
8546
|
-
const screenSchPortPos =
|
|
8640
|
+
const screenSchPortPos = applyToPoint59(transform, schPort.center);
|
|
8547
8641
|
const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
|
|
8548
8642
|
return [
|
|
8549
8643
|
{
|
|
@@ -8588,14 +8682,14 @@ var createSvgObjectsForSchComponentPortHovers = ({
|
|
|
8588
8682
|
};
|
|
8589
8683
|
|
|
8590
8684
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-line.ts
|
|
8591
|
-
import { applyToPoint as
|
|
8685
|
+
import { applyToPoint as applyToPoint60 } from "transformation-matrix";
|
|
8592
8686
|
function createSvgObjectsFromSchematicLine({
|
|
8593
8687
|
schLine,
|
|
8594
8688
|
transform,
|
|
8595
8689
|
colorMap: colorMap2
|
|
8596
8690
|
}) {
|
|
8597
|
-
const p1 =
|
|
8598
|
-
const p2 =
|
|
8691
|
+
const p1 = applyToPoint60(transform, { x: schLine.x1, y: schLine.y1 });
|
|
8692
|
+
const p2 = applyToPoint60(transform, { x: schLine.x2, y: schLine.y2 });
|
|
8599
8693
|
const strokeWidth = schLine.stroke_width ?? 0.02;
|
|
8600
8694
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
8601
8695
|
return [
|
|
@@ -8624,13 +8718,13 @@ function createSvgObjectsFromSchematicLine({
|
|
|
8624
8718
|
}
|
|
8625
8719
|
|
|
8626
8720
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-circle.ts
|
|
8627
|
-
import { applyToPoint as
|
|
8721
|
+
import { applyToPoint as applyToPoint61 } from "transformation-matrix";
|
|
8628
8722
|
function createSvgObjectsFromSchematicCircle({
|
|
8629
8723
|
schCircle,
|
|
8630
8724
|
transform,
|
|
8631
8725
|
colorMap: colorMap2
|
|
8632
8726
|
}) {
|
|
8633
|
-
const center =
|
|
8727
|
+
const center = applyToPoint61(transform, schCircle.center);
|
|
8634
8728
|
const transformedRadius = Math.abs(transform.a) * schCircle.radius;
|
|
8635
8729
|
const strokeWidth = schCircle.stroke_width ?? 0.02;
|
|
8636
8730
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -8660,13 +8754,13 @@ function createSvgObjectsFromSchematicCircle({
|
|
|
8660
8754
|
}
|
|
8661
8755
|
|
|
8662
8756
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-rect.ts
|
|
8663
|
-
import { applyToPoint as
|
|
8757
|
+
import { applyToPoint as applyToPoint62 } from "transformation-matrix";
|
|
8664
8758
|
function createSvgObjectsFromSchematicRect({
|
|
8665
8759
|
schRect,
|
|
8666
8760
|
transform,
|
|
8667
8761
|
colorMap: colorMap2
|
|
8668
8762
|
}) {
|
|
8669
|
-
const center =
|
|
8763
|
+
const center = applyToPoint62(transform, schRect.center);
|
|
8670
8764
|
const transformedWidth = Math.abs(transform.a) * schRect.width;
|
|
8671
8765
|
const transformedHeight = Math.abs(transform.d) * schRect.height;
|
|
8672
8766
|
const strokeWidth = schRect.stroke_width ?? 0.02;
|
|
@@ -8702,13 +8796,13 @@ function createSvgObjectsFromSchematicRect({
|
|
|
8702
8796
|
}
|
|
8703
8797
|
|
|
8704
8798
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-arc.ts
|
|
8705
|
-
import { applyToPoint as
|
|
8799
|
+
import { applyToPoint as applyToPoint63 } from "transformation-matrix";
|
|
8706
8800
|
function createSvgObjectsFromSchematicArc({
|
|
8707
8801
|
schArc,
|
|
8708
8802
|
transform,
|
|
8709
8803
|
colorMap: colorMap2
|
|
8710
8804
|
}) {
|
|
8711
|
-
const center =
|
|
8805
|
+
const center = applyToPoint63(transform, schArc.center);
|
|
8712
8806
|
const transformedRadius = Math.abs(transform.a) * schArc.radius;
|
|
8713
8807
|
const strokeWidth = schArc.stroke_width ?? 0.02;
|
|
8714
8808
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -9740,18 +9834,18 @@ function formatNumber2(value) {
|
|
|
9740
9834
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
9741
9835
|
import { stringify as stringify7 } from "svgson";
|
|
9742
9836
|
import {
|
|
9743
|
-
applyToPoint as
|
|
9837
|
+
applyToPoint as applyToPoint66,
|
|
9744
9838
|
compose as compose14,
|
|
9745
9839
|
scale as scale8,
|
|
9746
9840
|
translate as translate14
|
|
9747
9841
|
} from "transformation-matrix";
|
|
9748
9842
|
|
|
9749
9843
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
9750
|
-
import { applyToPoint as
|
|
9844
|
+
import { applyToPoint as applyToPoint65 } from "transformation-matrix";
|
|
9751
9845
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
9752
9846
|
const { transform, layer: layerFilter } = ctx;
|
|
9753
9847
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
9754
|
-
const [x, y] =
|
|
9848
|
+
const [x, y] = applyToPoint65(transform, [solderPaste.x, solderPaste.y]);
|
|
9755
9849
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
9756
9850
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
9757
9851
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -9962,8 +10056,8 @@ function createSvgObjects4({ elm, ctx }) {
|
|
|
9962
10056
|
}
|
|
9963
10057
|
}
|
|
9964
10058
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
9965
|
-
const [x1, y1] =
|
|
9966
|
-
const [x2, y2] =
|
|
10059
|
+
const [x1, y1] = applyToPoint66(transform, [minX, minY]);
|
|
10060
|
+
const [x2, y2] = applyToPoint66(transform, [maxX, maxY]);
|
|
9967
10061
|
const width = Math.abs(x2 - x1);
|
|
9968
10062
|
const height = Math.abs(y2 - y1);
|
|
9969
10063
|
const x = Math.min(x1, x2);
|