circuit-to-svg 0.0.232 → 0.0.234
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 +340 -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;
|
|
@@ -2068,6 +2153,50 @@ function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
|
2068
2153
|
}
|
|
2069
2154
|
];
|
|
2070
2155
|
}
|
|
2156
|
+
if (hole.hole_shape === "pill") {
|
|
2157
|
+
const scaledWidth = hole.hole_width * Math.abs(transform.a);
|
|
2158
|
+
const scaledHeight = hole.hole_height * Math.abs(transform.a);
|
|
2159
|
+
const radiusX = scaledWidth / 2;
|
|
2160
|
+
const straightLength = scaledHeight - scaledWidth;
|
|
2161
|
+
return [
|
|
2162
|
+
{
|
|
2163
|
+
name: "path",
|
|
2164
|
+
type: "element",
|
|
2165
|
+
attributes: {
|
|
2166
|
+
class: "pcb-hole",
|
|
2167
|
+
fill: colorMap2.drill,
|
|
2168
|
+
d: `M${x - radiusX},${y - straightLength / 2} v${straightLength} a${radiusX},${radiusX} 0 0 0 ${scaledWidth},0 v-${straightLength} a${radiusX},${radiusX} 0 0 0 -${scaledWidth},0 z`,
|
|
2169
|
+
"data-type": "pcb_hole",
|
|
2170
|
+
"data-pcb-layer": "drill"
|
|
2171
|
+
},
|
|
2172
|
+
children: [],
|
|
2173
|
+
value: ""
|
|
2174
|
+
}
|
|
2175
|
+
];
|
|
2176
|
+
}
|
|
2177
|
+
if (hole.hole_shape === "rotated_pill") {
|
|
2178
|
+
const scaledWidth = hole.hole_width * Math.abs(transform.a);
|
|
2179
|
+
const scaledHeight = hole.hole_height * Math.abs(transform.a);
|
|
2180
|
+
const radiusX = scaledWidth / 2;
|
|
2181
|
+
const straightLength = scaledHeight - scaledWidth;
|
|
2182
|
+
const rotation = hole.hole_ccw_rotation || 0;
|
|
2183
|
+
return [
|
|
2184
|
+
{
|
|
2185
|
+
name: "path",
|
|
2186
|
+
type: "element",
|
|
2187
|
+
attributes: {
|
|
2188
|
+
class: "pcb-hole",
|
|
2189
|
+
fill: colorMap2.drill,
|
|
2190
|
+
d: `M${-radiusX},${-straightLength / 2} v${straightLength} a${radiusX},${radiusX} 0 0 0 ${scaledWidth},0 v-${straightLength} a${radiusX},${radiusX} 0 0 0 -${scaledWidth},0 z`,
|
|
2191
|
+
transform: `translate(${x} ${y}) rotate(${-rotation})`,
|
|
2192
|
+
"data-type": "pcb_hole",
|
|
2193
|
+
"data-pcb-layer": "drill"
|
|
2194
|
+
},
|
|
2195
|
+
children: [],
|
|
2196
|
+
value: ""
|
|
2197
|
+
}
|
|
2198
|
+
];
|
|
2199
|
+
}
|
|
2071
2200
|
return [];
|
|
2072
2201
|
}
|
|
2073
2202
|
|
|
@@ -2076,7 +2205,7 @@ import {
|
|
|
2076
2205
|
getFullConnectivityMapFromCircuitJson
|
|
2077
2206
|
} from "circuit-json-to-connectivity-map";
|
|
2078
2207
|
import "svgson";
|
|
2079
|
-
import { applyToPoint as
|
|
2208
|
+
import { applyToPoint as applyToPoint22 } from "transformation-matrix";
|
|
2080
2209
|
|
|
2081
2210
|
// lib/pcb/create-svg-objects-from-pcb-rats-nest/get-element-position.ts
|
|
2082
2211
|
import { su } from "@tscircuit/circuit-json-util";
|
|
@@ -2156,11 +2285,11 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
2156
2285
|
});
|
|
2157
2286
|
const svgObjects = [];
|
|
2158
2287
|
for (const line of ratsNestLines) {
|
|
2159
|
-
const transformedStart =
|
|
2288
|
+
const transformedStart = applyToPoint22(transform, [
|
|
2160
2289
|
line.startPoint.x,
|
|
2161
2290
|
line.startPoint.y
|
|
2162
2291
|
]);
|
|
2163
|
-
const transformedEnd =
|
|
2292
|
+
const transformedEnd = applyToPoint22(transform, [
|
|
2164
2293
|
line.endPoint.x,
|
|
2165
2294
|
line.endPoint.y
|
|
2166
2295
|
]);
|
|
@@ -2188,7 +2317,7 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
2188
2317
|
|
|
2189
2318
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-cutout.ts
|
|
2190
2319
|
import {
|
|
2191
|
-
applyToPoint as
|
|
2320
|
+
applyToPoint as applyToPoint23,
|
|
2192
2321
|
compose as compose3,
|
|
2193
2322
|
rotate as rotate3,
|
|
2194
2323
|
translate as translate3,
|
|
@@ -2198,7 +2327,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2198
2327
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
2199
2328
|
if (cutout.shape === "rect") {
|
|
2200
2329
|
const rectCutout = cutout;
|
|
2201
|
-
const [cx, cy] =
|
|
2330
|
+
const [cx, cy] = applyToPoint23(transform, [
|
|
2202
2331
|
rectCutout.center.x,
|
|
2203
2332
|
rectCutout.center.y
|
|
2204
2333
|
]);
|
|
@@ -2229,7 +2358,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2229
2358
|
}
|
|
2230
2359
|
if (cutout.shape === "circle") {
|
|
2231
2360
|
const circleCutout = cutout;
|
|
2232
|
-
const [cx, cy] =
|
|
2361
|
+
const [cx, cy] = applyToPoint23(transform, [
|
|
2233
2362
|
circleCutout.center.x,
|
|
2234
2363
|
circleCutout.center.y
|
|
2235
2364
|
]);
|
|
@@ -2256,7 +2385,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2256
2385
|
const polygonCutout = cutout;
|
|
2257
2386
|
if (!polygonCutout.points || polygonCutout.points.length === 0) return [];
|
|
2258
2387
|
const transformedPoints = polygonCutout.points.map(
|
|
2259
|
-
(p) =>
|
|
2388
|
+
(p) => applyToPoint23(transform, [p.x, p.y])
|
|
2260
2389
|
);
|
|
2261
2390
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
2262
2391
|
return [
|
|
@@ -2280,7 +2409,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2280
2409
|
|
|
2281
2410
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-copper-pour.ts
|
|
2282
2411
|
import {
|
|
2283
|
-
applyToPoint as
|
|
2412
|
+
applyToPoint as applyToPoint25,
|
|
2284
2413
|
compose as compose4,
|
|
2285
2414
|
rotate as rotate4,
|
|
2286
2415
|
toString as matrixToString7,
|
|
@@ -2288,11 +2417,11 @@ import {
|
|
|
2288
2417
|
} from "transformation-matrix";
|
|
2289
2418
|
|
|
2290
2419
|
// lib/utils/ring-to-path-d.ts
|
|
2291
|
-
import { applyToPoint as
|
|
2420
|
+
import { applyToPoint as applyToPoint24 } from "transformation-matrix";
|
|
2292
2421
|
function ringToPathD(vertices, transform) {
|
|
2293
2422
|
if (vertices.length === 0) return "";
|
|
2294
2423
|
const transformedVertices = vertices.map((v) => {
|
|
2295
|
-
const [x, y] =
|
|
2424
|
+
const [x, y] = applyToPoint24(transform, [v.x, v.y]);
|
|
2296
2425
|
return { ...v, x, y };
|
|
2297
2426
|
});
|
|
2298
2427
|
let d = `M ${transformedVertices[0].x} ${transformedVertices[0].y}`;
|
|
@@ -2325,7 +2454,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
2325
2454
|
const color = layerNameToColor(layer, colorMap2);
|
|
2326
2455
|
const opacity = "0.5";
|
|
2327
2456
|
if (pour.shape === "rect") {
|
|
2328
|
-
const [cx, cy] =
|
|
2457
|
+
const [cx, cy] = applyToPoint25(transform, [pour.center.x, pour.center.y]);
|
|
2329
2458
|
const scaledWidth = pour.width * Math.abs(transform.a);
|
|
2330
2459
|
const scaledHeight = pour.height * Math.abs(transform.d);
|
|
2331
2460
|
const svgRotation = -(pour.rotation ?? 0);
|
|
@@ -2355,7 +2484,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
2355
2484
|
if (pour.shape === "polygon") {
|
|
2356
2485
|
if (!pour.points || pour.points.length === 0) return [];
|
|
2357
2486
|
const transformedPoints = pour.points.map(
|
|
2358
|
-
(p) =>
|
|
2487
|
+
(p) => applyToPoint25(transform, [p.x, p.y])
|
|
2359
2488
|
);
|
|
2360
2489
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
2361
2490
|
return [
|
|
@@ -2540,11 +2669,11 @@ function createMajorGridPatternChildren(cellSize, majorCellSize, lineColor, majo
|
|
|
2540
2669
|
}
|
|
2541
2670
|
|
|
2542
2671
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-component.ts
|
|
2543
|
-
import { applyToPoint as
|
|
2672
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
2544
2673
|
function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
2545
2674
|
const { transform } = ctx;
|
|
2546
2675
|
const { center, width, height, rotation = 0 } = component;
|
|
2547
|
-
const [x, y] =
|
|
2676
|
+
const [x, y] = applyToPoint26(transform, [center.x, center.y]);
|
|
2548
2677
|
const scaledWidth = width * Math.abs(transform.a);
|
|
2549
2678
|
const scaledHeight = height * Math.abs(transform.d);
|
|
2550
2679
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
@@ -2594,7 +2723,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
2594
2723
|
var package_default = {
|
|
2595
2724
|
name: "circuit-to-svg",
|
|
2596
2725
|
type: "module",
|
|
2597
|
-
version: "0.0.
|
|
2726
|
+
version: "0.0.233",
|
|
2598
2727
|
description: "Convert Circuit JSON to SVG",
|
|
2599
2728
|
main: "dist/index.js",
|
|
2600
2729
|
files: [
|
|
@@ -2663,6 +2792,7 @@ var TYPE_PRIORITY = {
|
|
|
2663
2792
|
pcb_component: 60,
|
|
2664
2793
|
pcb_fabrication_note_text: 70,
|
|
2665
2794
|
pcb_fabrication_note_path: 70,
|
|
2795
|
+
pcb_fabrication_note_rect: 70,
|
|
2666
2796
|
pcb_note_dimension: 70,
|
|
2667
2797
|
pcb_note_text: 70,
|
|
2668
2798
|
pcb_note_rect: 70,
|
|
@@ -2784,6 +2914,12 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
2784
2914
|
}
|
|
2785
2915
|
} else if ("route" in circuitJsonElm) {
|
|
2786
2916
|
updateTraceBounds(circuitJsonElm.route);
|
|
2917
|
+
} else if (circuitJsonElm.type === "pcb_note_rect" || circuitJsonElm.type === "pcb_fabrication_note_rect") {
|
|
2918
|
+
updateBounds(
|
|
2919
|
+
circuitJsonElm.center,
|
|
2920
|
+
circuitJsonElm.width,
|
|
2921
|
+
circuitJsonElm.height
|
|
2922
|
+
);
|
|
2787
2923
|
} else if (circuitJsonElm.type === "pcb_silkscreen_text" || circuitJsonElm.type === "pcb_silkscreen_rect" || circuitJsonElm.type === "pcb_silkscreen_circle" || circuitJsonElm.type === "pcb_silkscreen_line") {
|
|
2788
2924
|
updateSilkscreenBounds(circuitJsonElm);
|
|
2789
2925
|
} else if (circuitJsonElm.type === "pcb_copper_pour") {
|
|
@@ -3042,6 +3178,8 @@ function createSvgObjects({
|
|
|
3042
3178
|
return createSvgObjectsFromPcbFabricationNotePath(elm, ctx);
|
|
3043
3179
|
case "pcb_fabrication_note_text":
|
|
3044
3180
|
return createSvgObjectsFromPcbFabricationNoteText(elm, ctx);
|
|
3181
|
+
case "pcb_fabrication_note_rect":
|
|
3182
|
+
return createSvgObjectsFromPcbFabricationNoteRect(elm, ctx);
|
|
3045
3183
|
case "pcb_note_dimension":
|
|
3046
3184
|
return createSvgObjectsFromPcbNoteDimension(elm, ctx);
|
|
3047
3185
|
case "pcb_note_text":
|
|
@@ -3065,8 +3203,8 @@ function createSvgObjects({
|
|
|
3065
3203
|
}
|
|
3066
3204
|
}
|
|
3067
3205
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
3068
|
-
const [x1, y1] =
|
|
3069
|
-
const [x2, y2] =
|
|
3206
|
+
const [x1, y1] = applyToPoint27(transform, [minX, minY]);
|
|
3207
|
+
const [x2, y2] = applyToPoint27(transform, [maxX, maxY]);
|
|
3070
3208
|
const width = Math.abs(x2 - x1);
|
|
3071
3209
|
const height = Math.abs(y2 - y1);
|
|
3072
3210
|
const x = Math.min(x1, x2);
|
|
@@ -3096,14 +3234,14 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
3096
3234
|
import { stringify as stringify2 } from "svgson";
|
|
3097
3235
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
3098
3236
|
import {
|
|
3099
|
-
applyToPoint as
|
|
3237
|
+
applyToPoint as applyToPoint34,
|
|
3100
3238
|
compose as compose6,
|
|
3101
3239
|
scale as scale3,
|
|
3102
3240
|
translate as translate6
|
|
3103
3241
|
} from "transformation-matrix";
|
|
3104
3242
|
|
|
3105
3243
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
3106
|
-
import { applyToPoint as
|
|
3244
|
+
import { applyToPoint as applyToPoint28 } from "transformation-matrix";
|
|
3107
3245
|
var DEFAULT_BOARD_STYLE = {
|
|
3108
3246
|
fill: "none",
|
|
3109
3247
|
stroke: "rgb(0,0,0)",
|
|
@@ -3115,25 +3253,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
3115
3253
|
let path;
|
|
3116
3254
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
3117
3255
|
path = outline.map((point, index) => {
|
|
3118
|
-
const [x, y] =
|
|
3256
|
+
const [x, y] = applyToPoint28(transform, [point.x, point.y]);
|
|
3119
3257
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
3120
3258
|
}).join(" ");
|
|
3121
3259
|
} else {
|
|
3122
3260
|
const halfWidth = width / 2;
|
|
3123
3261
|
const halfHeight = height / 2;
|
|
3124
|
-
const topLeft =
|
|
3262
|
+
const topLeft = applyToPoint28(transform, [
|
|
3125
3263
|
center.x - halfWidth,
|
|
3126
3264
|
center.y - halfHeight
|
|
3127
3265
|
]);
|
|
3128
|
-
const topRight =
|
|
3266
|
+
const topRight = applyToPoint28(transform, [
|
|
3129
3267
|
center.x + halfWidth,
|
|
3130
3268
|
center.y - halfHeight
|
|
3131
3269
|
]);
|
|
3132
|
-
const bottomRight =
|
|
3270
|
+
const bottomRight = applyToPoint28(transform, [
|
|
3133
3271
|
center.x + halfWidth,
|
|
3134
3272
|
center.y + halfHeight
|
|
3135
3273
|
]);
|
|
3136
|
-
const bottomLeft =
|
|
3274
|
+
const bottomLeft = applyToPoint28(transform, [
|
|
3137
3275
|
center.x - halfWidth,
|
|
3138
3276
|
center.y + halfHeight
|
|
3139
3277
|
]);
|
|
@@ -3159,7 +3297,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
3159
3297
|
}
|
|
3160
3298
|
|
|
3161
3299
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
3162
|
-
import { applyToPoint as
|
|
3300
|
+
import { applyToPoint as applyToPoint30 } from "transformation-matrix";
|
|
3163
3301
|
|
|
3164
3302
|
// lib/utils/get-sch-font-size.ts
|
|
3165
3303
|
import "transformation-matrix";
|
|
@@ -3185,8 +3323,8 @@ function createSvgObjectsFromAssemblyComponent(params, ctx) {
|
|
|
3185
3323
|
const { center, width, height, rotation = 0, layer = "top" } = elm;
|
|
3186
3324
|
if (!center || typeof width !== "number" || typeof height !== "number")
|
|
3187
3325
|
return null;
|
|
3188
|
-
const [x, y] =
|
|
3189
|
-
const [pinX, pinY] =
|
|
3326
|
+
const [x, y] = applyToPoint30(transform, [center.x, center.y]);
|
|
3327
|
+
const [pinX, pinY] = applyToPoint30(transform, [portPosition.x, portPosition.y]);
|
|
3190
3328
|
const scaledWidth = width * Math.abs(transform.a);
|
|
3191
3329
|
const scaledHeight = height * Math.abs(transform.d);
|
|
3192
3330
|
const isTopLayer = layer === "top";
|
|
@@ -3348,11 +3486,11 @@ function getRectPathData(w, h, rotation) {
|
|
|
3348
3486
|
}
|
|
3349
3487
|
|
|
3350
3488
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-hole.ts
|
|
3351
|
-
import { applyToPoint as
|
|
3489
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
3352
3490
|
var HOLE_COLOR2 = "rgb(190, 190, 190)";
|
|
3353
3491
|
function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
3354
3492
|
const { transform } = ctx;
|
|
3355
|
-
const [x, y] =
|
|
3493
|
+
const [x, y] = applyToPoint31(transform, [hole.x, hole.y]);
|
|
3356
3494
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
3357
3495
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
3358
3496
|
const radius = scaledDiameter / 2;
|
|
@@ -3416,12 +3554,12 @@ function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
|
3416
3554
|
}
|
|
3417
3555
|
|
|
3418
3556
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-plated-hole.ts
|
|
3419
|
-
import { applyToPoint as
|
|
3557
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
3420
3558
|
var PAD_COLOR = "rgb(210, 210, 210)";
|
|
3421
3559
|
var HOLE_COLOR3 = "rgb(190, 190, 190)";
|
|
3422
3560
|
function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
3423
3561
|
const { transform } = ctx;
|
|
3424
|
-
const [x, y] =
|
|
3562
|
+
const [x, y] = applyToPoint32(transform, [hole.x, hole.y]);
|
|
3425
3563
|
if (hole.shape === "pill") {
|
|
3426
3564
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
3427
3565
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -3516,7 +3654,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3516
3654
|
const scaledRectPadHeight = circularHole.rect_pad_height * Math.abs(transform.a);
|
|
3517
3655
|
const scaledRectBorderRadius = (circularHole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
3518
3656
|
const holeRadius = scaledHoleDiameter / 2;
|
|
3519
|
-
const [holeCx, holeCy] =
|
|
3657
|
+
const [holeCx, holeCy] = applyToPoint32(transform, [
|
|
3520
3658
|
circularHole.x + circularHole.hole_offset_x,
|
|
3521
3659
|
circularHole.y + circularHole.hole_offset_y
|
|
3522
3660
|
]);
|
|
@@ -3574,7 +3712,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3574
3712
|
const pillHoleWithOffsets = pillHole;
|
|
3575
3713
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
3576
3714
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
3577
|
-
const [holeCenterX, holeCenterY] =
|
|
3715
|
+
const [holeCenterX, holeCenterY] = applyToPoint32(transform, [
|
|
3578
3716
|
pillHole.x + holeOffsetX,
|
|
3579
3717
|
pillHole.y + holeOffsetY
|
|
3580
3718
|
]);
|
|
@@ -3636,7 +3774,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3636
3774
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
3637
3775
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
3638
3776
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
3639
|
-
const [holeCenterX, holeCenterY] =
|
|
3777
|
+
const [holeCenterX, holeCenterY] = applyToPoint32(transform, [
|
|
3640
3778
|
rotatedHole.x + holeOffsetX,
|
|
3641
3779
|
rotatedHole.y + holeOffsetY
|
|
3642
3780
|
]);
|
|
@@ -3692,14 +3830,14 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3692
3830
|
}
|
|
3693
3831
|
|
|
3694
3832
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-smt-pad.ts
|
|
3695
|
-
import { applyToPoint as
|
|
3833
|
+
import { applyToPoint as applyToPoint33 } from "transformation-matrix";
|
|
3696
3834
|
var PAD_COLOR2 = "rgb(210, 210, 210)";
|
|
3697
3835
|
function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
3698
3836
|
const { transform } = ctx;
|
|
3699
3837
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
3700
3838
|
const width = pad.width * Math.abs(transform.a);
|
|
3701
3839
|
const height = pad.height * Math.abs(transform.d);
|
|
3702
|
-
const [x, y] =
|
|
3840
|
+
const [x, y] = applyToPoint33(transform, [pad.x, pad.y]);
|
|
3703
3841
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
3704
3842
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
3705
3843
|
return [
|
|
@@ -3751,7 +3889,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3751
3889
|
const width = pad.width * Math.abs(transform.a);
|
|
3752
3890
|
const height = pad.height * Math.abs(transform.d);
|
|
3753
3891
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3754
|
-
const [x, y] =
|
|
3892
|
+
const [x, y] = applyToPoint33(transform, [pad.x, pad.y]);
|
|
3755
3893
|
return [
|
|
3756
3894
|
{
|
|
3757
3895
|
name: "rect",
|
|
@@ -3774,7 +3912,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3774
3912
|
}
|
|
3775
3913
|
if (pad.shape === "circle") {
|
|
3776
3914
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3777
|
-
const [x, y] =
|
|
3915
|
+
const [x, y] = applyToPoint33(transform, [pad.x, pad.y]);
|
|
3778
3916
|
return [
|
|
3779
3917
|
{
|
|
3780
3918
|
name: "circle",
|
|
@@ -3794,7 +3932,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3794
3932
|
}
|
|
3795
3933
|
if (pad.shape === "polygon") {
|
|
3796
3934
|
const points = (pad.points ?? []).map(
|
|
3797
|
-
(point) =>
|
|
3935
|
+
(point) => applyToPoint33(transform, [point.x, point.y])
|
|
3798
3936
|
);
|
|
3799
3937
|
return [
|
|
3800
3938
|
{
|
|
@@ -3971,8 +4109,8 @@ function createSvgObjects2(elm, ctx, soup) {
|
|
|
3971
4109
|
}
|
|
3972
4110
|
}
|
|
3973
4111
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
3974
|
-
const [x1, y1] =
|
|
3975
|
-
const [x2, y2] =
|
|
4112
|
+
const [x1, y1] = applyToPoint34(transform, [minX, minY]);
|
|
4113
|
+
const [x2, y2] = applyToPoint34(transform, [maxX, maxY]);
|
|
3976
4114
|
const width = Math.abs(x2 - x1);
|
|
3977
4115
|
const height = Math.abs(y2 - y1);
|
|
3978
4116
|
const x = Math.min(x1, x2);
|
|
@@ -4001,7 +4139,7 @@ import {
|
|
|
4001
4139
|
} from "transformation-matrix";
|
|
4002
4140
|
|
|
4003
4141
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-board.ts
|
|
4004
|
-
import { applyToPoint as
|
|
4142
|
+
import { applyToPoint as applyToPoint35 } from "transformation-matrix";
|
|
4005
4143
|
import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
4006
4144
|
var BOARD_FILL_COLOR = "rgb(26, 115, 143)";
|
|
4007
4145
|
var BOARD_STROKE_COLOR = "rgba(0,0,0,0.9)";
|
|
@@ -4011,25 +4149,25 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4011
4149
|
let path;
|
|
4012
4150
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
4013
4151
|
path = outline.map((point, index) => {
|
|
4014
|
-
const [x, y] =
|
|
4152
|
+
const [x, y] = applyToPoint35(transform, [point.x, point.y]);
|
|
4015
4153
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
4016
4154
|
}).join(" ");
|
|
4017
4155
|
} else {
|
|
4018
4156
|
const halfWidth = width / 2;
|
|
4019
4157
|
const halfHeight = height / 2;
|
|
4020
|
-
const topLeft =
|
|
4158
|
+
const topLeft = applyToPoint35(transform, [
|
|
4021
4159
|
center.x - halfWidth,
|
|
4022
4160
|
center.y - halfHeight
|
|
4023
4161
|
]);
|
|
4024
|
-
const topRight =
|
|
4162
|
+
const topRight = applyToPoint35(transform, [
|
|
4025
4163
|
center.x + halfWidth,
|
|
4026
4164
|
center.y - halfHeight
|
|
4027
4165
|
]);
|
|
4028
|
-
const bottomRight =
|
|
4166
|
+
const bottomRight = applyToPoint35(transform, [
|
|
4029
4167
|
center.x + halfWidth,
|
|
4030
4168
|
center.y + halfHeight
|
|
4031
4169
|
]);
|
|
4032
|
-
const bottomLeft =
|
|
4170
|
+
const bottomLeft = applyToPoint35(transform, [
|
|
4033
4171
|
center.x - halfWidth,
|
|
4034
4172
|
center.y + halfHeight
|
|
4035
4173
|
]);
|
|
@@ -4047,10 +4185,10 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4047
4185
|
const halfWidth = width2 / 2;
|
|
4048
4186
|
const halfHeight = height2 / 2;
|
|
4049
4187
|
const [tl, tr, br, bl] = [
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4188
|
+
applyToPoint35(transform, [x - halfWidth, y - halfHeight]),
|
|
4189
|
+
applyToPoint35(transform, [x + halfWidth, y - halfHeight]),
|
|
4190
|
+
applyToPoint35(transform, [x + halfWidth, y + halfHeight]),
|
|
4191
|
+
applyToPoint35(transform, [x - halfWidth, y + halfHeight])
|
|
4054
4192
|
];
|
|
4055
4193
|
path += ` M ${tl[0]} ${tl[1]} L ${tr[0]} ${tr[1]} L ${br[0]} ${br[1]} L ${bl[0]} ${bl[1]} Z`;
|
|
4056
4194
|
} else if (cutout.shape === "circle") {
|
|
@@ -4077,7 +4215,7 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4077
4215
|
|
|
4078
4216
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-component.ts
|
|
4079
4217
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
4080
|
-
import { applyToPoint as
|
|
4218
|
+
import { applyToPoint as applyToPoint36 } from "transformation-matrix";
|
|
4081
4219
|
var COMPONENT_FILL_COLOR = "rgba(120, 120, 120, 0.6)";
|
|
4082
4220
|
var COMPONENT_LABEL_COLOR = "rgba(255, 255, 255, 0.9)";
|
|
4083
4221
|
function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
@@ -4087,7 +4225,7 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
4087
4225
|
if (!center || typeof width !== "number" || typeof height !== "number" || width === 0 || height === 0) {
|
|
4088
4226
|
return [];
|
|
4089
4227
|
}
|
|
4090
|
-
const [x, y] =
|
|
4228
|
+
const [x, y] = applyToPoint36(transform, [center.x, center.y]);
|
|
4091
4229
|
const scaledWidth = width * Math.abs(transform.a);
|
|
4092
4230
|
const scaledHeight = height * Math.abs(transform.d);
|
|
4093
4231
|
const transformStr = `translate(${x}, ${y})`;
|
|
@@ -4148,11 +4286,11 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
4148
4286
|
}
|
|
4149
4287
|
|
|
4150
4288
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-hole.ts
|
|
4151
|
-
import { applyToPoint as
|
|
4289
|
+
import { applyToPoint as applyToPoint37 } from "transformation-matrix";
|
|
4152
4290
|
var HOLE_COLOR4 = "rgb(50, 50, 50)";
|
|
4153
4291
|
function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
4154
4292
|
const { transform } = ctx;
|
|
4155
|
-
const [x, y] =
|
|
4293
|
+
const [x, y] = applyToPoint37(transform, [hole.x, hole.y]);
|
|
4156
4294
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
4157
4295
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
4158
4296
|
const radius = scaledDiameter / 2;
|
|
@@ -4216,12 +4354,12 @@ function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
|
4216
4354
|
}
|
|
4217
4355
|
|
|
4218
4356
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-plated-hole.ts
|
|
4219
|
-
import { applyToPoint as
|
|
4357
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
4220
4358
|
var PAD_COLOR3 = "rgb(218, 165, 32)";
|
|
4221
4359
|
var HOLE_COLOR5 = "rgb(40, 40, 40)";
|
|
4222
4360
|
function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
4223
4361
|
const { transform } = ctx;
|
|
4224
|
-
const [x, y] =
|
|
4362
|
+
const [x, y] = applyToPoint38(transform, [hole.x, hole.y]);
|
|
4225
4363
|
if (hole.shape === "pill") {
|
|
4226
4364
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
4227
4365
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -4456,14 +4594,14 @@ function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
|
4456
4594
|
}
|
|
4457
4595
|
|
|
4458
4596
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-smt-pad.ts
|
|
4459
|
-
import { applyToPoint as
|
|
4597
|
+
import { applyToPoint as applyToPoint39 } from "transformation-matrix";
|
|
4460
4598
|
var PAD_COLOR4 = "rgb(218, 165, 32)";
|
|
4461
4599
|
function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
4462
4600
|
const { transform } = ctx;
|
|
4463
4601
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
4464
4602
|
const width = pad.width * Math.abs(transform.a);
|
|
4465
4603
|
const height = pad.height * Math.abs(transform.d);
|
|
4466
|
-
const [x, y] =
|
|
4604
|
+
const [x, y] = applyToPoint39(transform, [pad.x, pad.y]);
|
|
4467
4605
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
4468
4606
|
return [
|
|
4469
4607
|
{
|
|
@@ -4506,7 +4644,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4506
4644
|
const width = pad.width * Math.abs(transform.a);
|
|
4507
4645
|
const height = pad.height * Math.abs(transform.d);
|
|
4508
4646
|
const radius = pad.radius * Math.abs(transform.a);
|
|
4509
|
-
const [x, y] =
|
|
4647
|
+
const [x, y] = applyToPoint39(transform, [pad.x, pad.y]);
|
|
4510
4648
|
return [
|
|
4511
4649
|
{
|
|
4512
4650
|
name: "rect",
|
|
@@ -4529,7 +4667,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4529
4667
|
}
|
|
4530
4668
|
if (pad.shape === "circle") {
|
|
4531
4669
|
const radius = pad.radius * Math.abs(transform.a);
|
|
4532
|
-
const [x, y] =
|
|
4670
|
+
const [x, y] = applyToPoint39(transform, [pad.x, pad.y]);
|
|
4533
4671
|
return [
|
|
4534
4672
|
{
|
|
4535
4673
|
name: "circle",
|
|
@@ -4549,7 +4687,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4549
4687
|
}
|
|
4550
4688
|
if (pad.shape === "polygon") {
|
|
4551
4689
|
const points = (pad.points ?? []).map(
|
|
4552
|
-
(point) =>
|
|
4690
|
+
(point) => applyToPoint39(transform, [point.x, point.y])
|
|
4553
4691
|
);
|
|
4554
4692
|
return [
|
|
4555
4693
|
{
|
|
@@ -4570,7 +4708,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4570
4708
|
}
|
|
4571
4709
|
|
|
4572
4710
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-port.ts
|
|
4573
|
-
import { applyToPoint as
|
|
4711
|
+
import { applyToPoint as applyToPoint40 } from "transformation-matrix";
|
|
4574
4712
|
import { calculateElbow } from "calculate-elbow";
|
|
4575
4713
|
|
|
4576
4714
|
// lib/pinout/svg-object-fns/pinout-label-box.ts
|
|
@@ -4647,7 +4785,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
4647
4785
|
const label_info = ctx.label_positions.get(pcb_port.pcb_port_id);
|
|
4648
4786
|
if (!label_info) return [];
|
|
4649
4787
|
const { text: label, aliases, elbow_end, label_pos, edge } = label_info;
|
|
4650
|
-
const [port_x, port_y] =
|
|
4788
|
+
const [port_x, port_y] = applyToPoint40(ctx.transform, [pcb_port.x, pcb_port.y]);
|
|
4651
4789
|
const start_facing_direction = edge === "left" ? "x-" : edge === "right" ? "x+" : edge === "top" ? "y-" : "y+";
|
|
4652
4790
|
const end_facing_direction = edge === "left" ? "x+" : edge === "right" ? "x-" : edge === "top" ? "y+" : "y-";
|
|
4653
4791
|
const elbow_path = calculateElbow(
|
|
@@ -4788,7 +4926,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
4788
4926
|
}
|
|
4789
4927
|
|
|
4790
4928
|
// lib/pinout/calculate-label-positions.ts
|
|
4791
|
-
import { applyToPoint as
|
|
4929
|
+
import { applyToPoint as applyToPoint41 } from "transformation-matrix";
|
|
4792
4930
|
|
|
4793
4931
|
// lib/pinout/constants.ts
|
|
4794
4932
|
var LABEL_RECT_HEIGHT_BASE_MM = 1.6;
|
|
@@ -4826,7 +4964,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4826
4964
|
);
|
|
4827
4965
|
const mapToEdgePort = (pinout_label) => ({
|
|
4828
4966
|
pcb_port: pinout_label.pcb_port,
|
|
4829
|
-
y:
|
|
4967
|
+
y: applyToPoint41(transform, [
|
|
4830
4968
|
pinout_label.pcb_port.x,
|
|
4831
4969
|
pinout_label.pcb_port.y
|
|
4832
4970
|
])[1],
|
|
@@ -4841,7 +4979,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4841
4979
|
} else {
|
|
4842
4980
|
edge_ports = pinout_labels.map((pinout_label) => ({
|
|
4843
4981
|
pcb_port: pinout_label.pcb_port,
|
|
4844
|
-
y:
|
|
4982
|
+
y: applyToPoint41(transform, [
|
|
4845
4983
|
pinout_label.pcb_port.x,
|
|
4846
4984
|
pinout_label.pcb_port.y
|
|
4847
4985
|
])[1],
|
|
@@ -4849,7 +4987,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4849
4987
|
})).sort((a, b) => a.y - b.y);
|
|
4850
4988
|
}
|
|
4851
4989
|
if (edge_ports.length === 0) return;
|
|
4852
|
-
const board_edge_x =
|
|
4990
|
+
const board_edge_x = applyToPoint41(transform, [
|
|
4853
4991
|
edge === "left" ? board_bounds.minX : board_bounds.maxX,
|
|
4854
4992
|
0
|
|
4855
4993
|
])[0];
|
|
@@ -5498,14 +5636,14 @@ import {
|
|
|
5498
5636
|
} from "transformation-matrix";
|
|
5499
5637
|
|
|
5500
5638
|
// lib/sch/draw-schematic-grid.ts
|
|
5501
|
-
import { applyToPoint as
|
|
5639
|
+
import { applyToPoint as applyToPoint42 } from "transformation-matrix";
|
|
5502
5640
|
function drawSchematicGrid(params) {
|
|
5503
5641
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
5504
5642
|
const cellSize = params.cellSize ?? 1;
|
|
5505
5643
|
const labelCells = params.labelCells ?? false;
|
|
5506
5644
|
const gridLines = [];
|
|
5507
5645
|
const transformPoint = (x, y) => {
|
|
5508
|
-
const [transformedX, transformedY] =
|
|
5646
|
+
const [transformedX, transformedY] = applyToPoint42(params.transform, [x, y]);
|
|
5509
5647
|
return { x: transformedX, y: transformedY };
|
|
5510
5648
|
};
|
|
5511
5649
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -5586,15 +5724,15 @@ function drawSchematicGrid(params) {
|
|
|
5586
5724
|
}
|
|
5587
5725
|
|
|
5588
5726
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
5589
|
-
import { applyToPoint as
|
|
5727
|
+
import { applyToPoint as applyToPoint43 } from "transformation-matrix";
|
|
5590
5728
|
function drawSchematicLabeledPoints(params) {
|
|
5591
5729
|
const { points, transform } = params;
|
|
5592
5730
|
const labeledPointsGroup = [];
|
|
5593
5731
|
for (const point of points) {
|
|
5594
|
-
const [x1, y1] =
|
|
5595
|
-
const [x2, y2] =
|
|
5596
|
-
const [x3, y3] =
|
|
5597
|
-
const [x4, y4] =
|
|
5732
|
+
const [x1, y1] = applyToPoint43(transform, [point.x - 0.1, point.y - 0.1]);
|
|
5733
|
+
const [x2, y2] = applyToPoint43(transform, [point.x + 0.1, point.y + 0.1]);
|
|
5734
|
+
const [x3, y3] = applyToPoint43(transform, [point.x - 0.1, point.y + 0.1]);
|
|
5735
|
+
const [x4, y4] = applyToPoint43(transform, [point.x + 0.1, point.y - 0.1]);
|
|
5598
5736
|
labeledPointsGroup.push({
|
|
5599
5737
|
name: "path",
|
|
5600
5738
|
type: "element",
|
|
@@ -5605,7 +5743,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
5605
5743
|
"stroke-opacity": "0.7"
|
|
5606
5744
|
}
|
|
5607
5745
|
});
|
|
5608
|
-
const [labelX, labelY] =
|
|
5746
|
+
const [labelX, labelY] = applyToPoint43(transform, [
|
|
5609
5747
|
point.x + 0.15,
|
|
5610
5748
|
point.y - 0.15
|
|
5611
5749
|
]);
|
|
@@ -6699,7 +6837,7 @@ import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
|
6699
6837
|
import { symbols } from "schematic-symbols";
|
|
6700
6838
|
import "svgson";
|
|
6701
6839
|
import {
|
|
6702
|
-
applyToPoint as
|
|
6840
|
+
applyToPoint as applyToPoint45,
|
|
6703
6841
|
compose as compose9
|
|
6704
6842
|
} from "transformation-matrix";
|
|
6705
6843
|
|
|
@@ -6783,13 +6921,13 @@ function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
|
6783
6921
|
}
|
|
6784
6922
|
|
|
6785
6923
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
6786
|
-
import { applyToPoint as
|
|
6924
|
+
import { applyToPoint as applyToPoint44 } from "transformation-matrix";
|
|
6787
6925
|
var createSvgSchErrorText = ({
|
|
6788
6926
|
text,
|
|
6789
6927
|
realCenter,
|
|
6790
6928
|
realToScreenTransform
|
|
6791
6929
|
}) => {
|
|
6792
|
-
const screenCenter =
|
|
6930
|
+
const screenCenter = applyToPoint44(realToScreenTransform, realCenter);
|
|
6793
6931
|
return {
|
|
6794
6932
|
type: "element",
|
|
6795
6933
|
name: "text",
|
|
@@ -6898,11 +7036,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6898
7036
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
6899
7037
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
6900
7038
|
};
|
|
6901
|
-
const [screenMinX, screenMinY] =
|
|
7039
|
+
const [screenMinX, screenMinY] = applyToPoint45(
|
|
6902
7040
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6903
7041
|
[bounds.minX, bounds.minY]
|
|
6904
7042
|
);
|
|
6905
|
-
const [screenMaxX, screenMaxY] =
|
|
7043
|
+
const [screenMaxX, screenMaxY] = applyToPoint45(
|
|
6906
7044
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6907
7045
|
[bounds.maxX, bounds.maxY]
|
|
6908
7046
|
);
|
|
@@ -6931,7 +7069,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6931
7069
|
name: "path",
|
|
6932
7070
|
attributes: {
|
|
6933
7071
|
d: points.map((p, i) => {
|
|
6934
|
-
const [x, y] =
|
|
7072
|
+
const [x, y] = applyToPoint45(
|
|
6935
7073
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6936
7074
|
[p.x, p.y]
|
|
6937
7075
|
);
|
|
@@ -6947,7 +7085,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6947
7085
|
});
|
|
6948
7086
|
}
|
|
6949
7087
|
for (const text of texts) {
|
|
6950
|
-
const screenTextPos =
|
|
7088
|
+
const screenTextPos = applyToPoint45(
|
|
6951
7089
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6952
7090
|
text
|
|
6953
7091
|
);
|
|
@@ -6999,7 +7137,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6999
7137
|
});
|
|
7000
7138
|
}
|
|
7001
7139
|
for (const box of boxes) {
|
|
7002
|
-
const screenBoxPos =
|
|
7140
|
+
const screenBoxPos = applyToPoint45(
|
|
7003
7141
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7004
7142
|
box
|
|
7005
7143
|
);
|
|
@@ -7023,7 +7161,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7023
7161
|
}
|
|
7024
7162
|
for (const port of symbol.ports) {
|
|
7025
7163
|
if (connectedSymbolPorts.has(port)) continue;
|
|
7026
|
-
const screenPortPos =
|
|
7164
|
+
const screenPortPos = applyToPoint45(
|
|
7027
7165
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7028
7166
|
port
|
|
7029
7167
|
);
|
|
@@ -7043,7 +7181,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7043
7181
|
});
|
|
7044
7182
|
}
|
|
7045
7183
|
for (const circle of circles) {
|
|
7046
|
-
const screenCirclePos =
|
|
7184
|
+
const screenCirclePos = applyToPoint45(
|
|
7047
7185
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7048
7186
|
circle
|
|
7049
7187
|
);
|
|
@@ -7070,14 +7208,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7070
7208
|
import { su as su10 } from "@tscircuit/circuit-json-util";
|
|
7071
7209
|
import "schematic-symbols";
|
|
7072
7210
|
import "svgson";
|
|
7073
|
-
import { applyToPoint as
|
|
7211
|
+
import { applyToPoint as applyToPoint51 } from "transformation-matrix";
|
|
7074
7212
|
|
|
7075
7213
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
7076
7214
|
import "transformation-matrix";
|
|
7077
7215
|
import "@tscircuit/circuit-json-util";
|
|
7078
7216
|
|
|
7079
7217
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
7080
|
-
import { applyToPoint as
|
|
7218
|
+
import { applyToPoint as applyToPoint46 } from "transformation-matrix";
|
|
7081
7219
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
7082
7220
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
7083
7221
|
var createArrow = (tip, angle, size, color, strokeWidth) => {
|
|
@@ -7130,8 +7268,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7130
7268
|
realEdgePos.y += realPinLineLength;
|
|
7131
7269
|
break;
|
|
7132
7270
|
}
|
|
7133
|
-
const screenSchPortPos =
|
|
7134
|
-
const screenRealEdgePos =
|
|
7271
|
+
const screenSchPortPos = applyToPoint46(transform, schPort.center);
|
|
7272
|
+
const screenRealEdgePos = applyToPoint46(transform, realEdgePos);
|
|
7135
7273
|
const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
|
|
7136
7274
|
const realLineEnd = { ...schPort.center };
|
|
7137
7275
|
if (!isConnected) {
|
|
@@ -7150,7 +7288,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7150
7288
|
break;
|
|
7151
7289
|
}
|
|
7152
7290
|
}
|
|
7153
|
-
const screenLineEnd =
|
|
7291
|
+
const screenLineEnd = applyToPoint46(transform, realLineEnd);
|
|
7154
7292
|
svgObjects.push({
|
|
7155
7293
|
name: "line",
|
|
7156
7294
|
type: "element",
|
|
@@ -7271,7 +7409,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7271
7409
|
};
|
|
7272
7410
|
|
|
7273
7411
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
7274
|
-
import { applyToPoint as
|
|
7412
|
+
import { applyToPoint as applyToPoint47 } from "transformation-matrix";
|
|
7275
7413
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
7276
7414
|
const svgObjects = [];
|
|
7277
7415
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -7289,7 +7427,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
7289
7427
|
} else {
|
|
7290
7428
|
realPinNumberPos.y += 0.02;
|
|
7291
7429
|
}
|
|
7292
|
-
const screenPinNumberTextPos =
|
|
7430
|
+
const screenPinNumberTextPos = applyToPoint47(transform, realPinNumberPos);
|
|
7293
7431
|
svgObjects.push({
|
|
7294
7432
|
name: "text",
|
|
7295
7433
|
type: "element",
|
|
@@ -7319,7 +7457,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
7319
7457
|
};
|
|
7320
7458
|
|
|
7321
7459
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
7322
|
-
import { applyToPoint as
|
|
7460
|
+
import { applyToPoint as applyToPoint48 } from "transformation-matrix";
|
|
7323
7461
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
7324
7462
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
7325
7463
|
const svgObjects = [];
|
|
@@ -7333,7 +7471,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
7333
7471
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
7334
7472
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
7335
7473
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
7336
|
-
const screenPinNumberTextPos =
|
|
7474
|
+
const screenPinNumberTextPos = applyToPoint48(transform, realPinNumberPos);
|
|
7337
7475
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
7338
7476
|
if (!label) return [];
|
|
7339
7477
|
const isNegated = label.startsWith("N_");
|
|
@@ -7381,13 +7519,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
7381
7519
|
};
|
|
7382
7520
|
|
|
7383
7521
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
7384
|
-
import { applyToPoint as
|
|
7522
|
+
import { applyToPoint as applyToPoint50 } from "transformation-matrix";
|
|
7385
7523
|
var createSvgSchText = ({
|
|
7386
7524
|
elm,
|
|
7387
7525
|
transform,
|
|
7388
7526
|
colorMap: colorMap2
|
|
7389
7527
|
}) => {
|
|
7390
|
-
const center =
|
|
7528
|
+
const center = applyToPoint50(transform, elm.position);
|
|
7391
7529
|
const textAnchorMap = {
|
|
7392
7530
|
center: "middle",
|
|
7393
7531
|
center_right: "end",
|
|
@@ -7471,11 +7609,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
7471
7609
|
colorMap: colorMap2
|
|
7472
7610
|
}) => {
|
|
7473
7611
|
const svgObjects = [];
|
|
7474
|
-
const componentScreenTopLeft =
|
|
7612
|
+
const componentScreenTopLeft = applyToPoint51(transform, {
|
|
7475
7613
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
7476
7614
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
7477
7615
|
});
|
|
7478
|
-
const componentScreenBottomRight =
|
|
7616
|
+
const componentScreenBottomRight = applyToPoint51(transform, {
|
|
7479
7617
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
7480
7618
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
7481
7619
|
});
|
|
@@ -7561,13 +7699,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
7561
7699
|
}
|
|
7562
7700
|
|
|
7563
7701
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
7564
|
-
import { applyToPoint as
|
|
7702
|
+
import { applyToPoint as applyToPoint52 } from "transformation-matrix";
|
|
7565
7703
|
function createSvgObjectsFromSchVoltageProbe({
|
|
7566
7704
|
probe,
|
|
7567
7705
|
transform,
|
|
7568
7706
|
colorMap: colorMap2
|
|
7569
7707
|
}) {
|
|
7570
|
-
const [screenX, screenY] =
|
|
7708
|
+
const [screenX, screenY] = applyToPoint52(transform, [
|
|
7571
7709
|
probe.position.x,
|
|
7572
7710
|
probe.position.y
|
|
7573
7711
|
]);
|
|
@@ -7627,17 +7765,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
7627
7765
|
}
|
|
7628
7766
|
|
|
7629
7767
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
7630
|
-
import { applyToPoint as
|
|
7768
|
+
import { applyToPoint as applyToPoint53 } from "transformation-matrix";
|
|
7631
7769
|
function createSvgObjectsFromSchDebugObject({
|
|
7632
7770
|
debugObject,
|
|
7633
7771
|
transform
|
|
7634
7772
|
}) {
|
|
7635
7773
|
if (debugObject.shape === "rect") {
|
|
7636
|
-
let [screenLeft, screenTop] =
|
|
7774
|
+
let [screenLeft, screenTop] = applyToPoint53(transform, [
|
|
7637
7775
|
debugObject.center.x - debugObject.size.width / 2,
|
|
7638
7776
|
debugObject.center.y - debugObject.size.height / 2
|
|
7639
7777
|
]);
|
|
7640
|
-
let [screenRight, screenBottom] =
|
|
7778
|
+
let [screenRight, screenBottom] = applyToPoint53(transform, [
|
|
7641
7779
|
debugObject.center.x + debugObject.size.width / 2,
|
|
7642
7780
|
debugObject.center.y + debugObject.size.height / 2
|
|
7643
7781
|
]);
|
|
@@ -7647,7 +7785,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
7647
7785
|
];
|
|
7648
7786
|
const width = Math.abs(screenRight - screenLeft);
|
|
7649
7787
|
const height = Math.abs(screenBottom - screenTop);
|
|
7650
|
-
const [screenCenterX, screenCenterY] =
|
|
7788
|
+
const [screenCenterX, screenCenterY] = applyToPoint53(transform, [
|
|
7651
7789
|
debugObject.center.x,
|
|
7652
7790
|
debugObject.center.y
|
|
7653
7791
|
]);
|
|
@@ -7693,11 +7831,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
7693
7831
|
];
|
|
7694
7832
|
}
|
|
7695
7833
|
if (debugObject.shape === "line") {
|
|
7696
|
-
const [screenStartX, screenStartY] =
|
|
7834
|
+
const [screenStartX, screenStartY] = applyToPoint53(transform, [
|
|
7697
7835
|
debugObject.start.x,
|
|
7698
7836
|
debugObject.start.y
|
|
7699
7837
|
]);
|
|
7700
|
-
const [screenEndX, screenEndY] =
|
|
7838
|
+
const [screenEndX, screenEndY] = applyToPoint53(transform, [
|
|
7701
7839
|
debugObject.end.x,
|
|
7702
7840
|
debugObject.end.y
|
|
7703
7841
|
]);
|
|
@@ -7747,7 +7885,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
7747
7885
|
}
|
|
7748
7886
|
|
|
7749
7887
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
7750
|
-
import { applyToPoint as
|
|
7888
|
+
import { applyToPoint as applyToPoint54 } from "transformation-matrix";
|
|
7751
7889
|
function createSchematicTrace({
|
|
7752
7890
|
trace,
|
|
7753
7891
|
transform,
|
|
@@ -7761,11 +7899,11 @@ function createSchematicTrace({
|
|
|
7761
7899
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
7762
7900
|
const edge = edges[edgeIndex];
|
|
7763
7901
|
if (edge.is_crossing) continue;
|
|
7764
|
-
const [screenFromX, screenFromY] =
|
|
7902
|
+
const [screenFromX, screenFromY] = applyToPoint54(transform, [
|
|
7765
7903
|
edge.from.x,
|
|
7766
7904
|
edge.from.y
|
|
7767
7905
|
]);
|
|
7768
|
-
const [screenToX, screenToY] =
|
|
7906
|
+
const [screenToX, screenToY] = applyToPoint54(transform, [
|
|
7769
7907
|
edge.to.x,
|
|
7770
7908
|
edge.to.y
|
|
7771
7909
|
]);
|
|
@@ -7809,11 +7947,11 @@ function createSchematicTrace({
|
|
|
7809
7947
|
}
|
|
7810
7948
|
for (const edge of edges) {
|
|
7811
7949
|
if (!edge.is_crossing) continue;
|
|
7812
|
-
const [screenFromX, screenFromY] =
|
|
7950
|
+
const [screenFromX, screenFromY] = applyToPoint54(transform, [
|
|
7813
7951
|
edge.from.x,
|
|
7814
7952
|
edge.from.y
|
|
7815
7953
|
]);
|
|
7816
|
-
const [screenToX, screenToY] =
|
|
7954
|
+
const [screenToX, screenToY] = applyToPoint54(transform, [
|
|
7817
7955
|
edge.to.x,
|
|
7818
7956
|
edge.to.y
|
|
7819
7957
|
]);
|
|
@@ -7857,7 +7995,7 @@ function createSchematicTrace({
|
|
|
7857
7995
|
}
|
|
7858
7996
|
if (trace.junctions) {
|
|
7859
7997
|
for (const junction of trace.junctions) {
|
|
7860
|
-
const [screenX, screenY] =
|
|
7998
|
+
const [screenX, screenY] = applyToPoint54(transform, [
|
|
7861
7999
|
junction.x,
|
|
7862
8000
|
junction.y
|
|
7863
8001
|
]);
|
|
@@ -7912,7 +8050,7 @@ function createSchematicTrace({
|
|
|
7912
8050
|
|
|
7913
8051
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
7914
8052
|
import {
|
|
7915
|
-
applyToPoint as
|
|
8053
|
+
applyToPoint as applyToPoint56,
|
|
7916
8054
|
compose as compose11,
|
|
7917
8055
|
rotate as rotate6,
|
|
7918
8056
|
scale as scale6,
|
|
@@ -7921,7 +8059,7 @@ import {
|
|
|
7921
8059
|
|
|
7922
8060
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
7923
8061
|
import {
|
|
7924
|
-
applyToPoint as
|
|
8062
|
+
applyToPoint as applyToPoint55,
|
|
7925
8063
|
compose as compose10,
|
|
7926
8064
|
rotate as rotate5,
|
|
7927
8065
|
scale as scale5,
|
|
@@ -7996,7 +8134,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7996
8134
|
x: symbolBounds.minX,
|
|
7997
8135
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
7998
8136
|
};
|
|
7999
|
-
const rotatedSymbolEnd =
|
|
8137
|
+
const rotatedSymbolEnd = applyToPoint55(rotationMatrix, symbolEndPoint);
|
|
8000
8138
|
const symbolToRealTransform = compose10(
|
|
8001
8139
|
translate10(
|
|
8002
8140
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
@@ -8006,11 +8144,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8006
8144
|
scale5(1)
|
|
8007
8145
|
// Use full symbol size
|
|
8008
8146
|
);
|
|
8009
|
-
const [screenMinX, screenMinY] =
|
|
8147
|
+
const [screenMinX, screenMinY] = applyToPoint55(
|
|
8010
8148
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8011
8149
|
[bounds.minX, bounds.minY]
|
|
8012
8150
|
);
|
|
8013
|
-
const [screenMaxX, screenMaxY] =
|
|
8151
|
+
const [screenMaxX, screenMaxY] = applyToPoint55(
|
|
8014
8152
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8015
8153
|
[bounds.maxX, bounds.maxY]
|
|
8016
8154
|
);
|
|
@@ -8034,7 +8172,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8034
8172
|
});
|
|
8035
8173
|
for (const path of symbolPaths) {
|
|
8036
8174
|
const symbolPath = path.points.map((p, i) => {
|
|
8037
|
-
const [x, y] =
|
|
8175
|
+
const [x, y] = applyToPoint55(
|
|
8038
8176
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8039
8177
|
[p.x, p.y]
|
|
8040
8178
|
);
|
|
@@ -8055,7 +8193,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8055
8193
|
});
|
|
8056
8194
|
}
|
|
8057
8195
|
for (const text of symbolTexts) {
|
|
8058
|
-
const screenTextPos =
|
|
8196
|
+
const screenTextPos = applyToPoint55(
|
|
8059
8197
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8060
8198
|
text
|
|
8061
8199
|
);
|
|
@@ -8097,7 +8235,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8097
8235
|
});
|
|
8098
8236
|
}
|
|
8099
8237
|
for (const box of symbolBoxes) {
|
|
8100
|
-
const screenBoxPos =
|
|
8238
|
+
const screenBoxPos = applyToPoint55(
|
|
8101
8239
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8102
8240
|
box
|
|
8103
8241
|
);
|
|
@@ -8120,7 +8258,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8120
8258
|
});
|
|
8121
8259
|
}
|
|
8122
8260
|
for (const circle of symbolCircles) {
|
|
8123
|
-
const screenCirclePos =
|
|
8261
|
+
const screenCirclePos = applyToPoint55(
|
|
8124
8262
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8125
8263
|
circle
|
|
8126
8264
|
);
|
|
@@ -8165,14 +8303,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
8165
8303
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
8166
8304
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
8167
8305
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
8168
|
-
const screenCenter =
|
|
8306
|
+
const screenCenter = applyToPoint56(realToScreenTransform, schNetLabel.center);
|
|
8169
8307
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
8170
8308
|
schNetLabel.anchor_side
|
|
8171
8309
|
);
|
|
8172
8310
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
8173
8311
|
screenTextGrowthVec.y *= -1;
|
|
8174
8312
|
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 ?
|
|
8313
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint56(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
8176
8314
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
8177
8315
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
8178
8316
|
};
|
|
@@ -8213,7 +8351,7 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
8213
8351
|
y: -0.6
|
|
8214
8352
|
}
|
|
8215
8353
|
].map(
|
|
8216
|
-
(fontRelativePoint) =>
|
|
8354
|
+
(fontRelativePoint) => applyToPoint56(
|
|
8217
8355
|
compose11(
|
|
8218
8356
|
realToScreenTransform,
|
|
8219
8357
|
translate11(realAnchorPosition.x, realAnchorPosition.y),
|
|
@@ -8290,17 +8428,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
8290
8428
|
};
|
|
8291
8429
|
|
|
8292
8430
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
8293
|
-
import { applyToPoint as
|
|
8431
|
+
import { applyToPoint as applyToPoint57 } from "transformation-matrix";
|
|
8294
8432
|
var createSvgObjectsFromSchematicBox = ({
|
|
8295
8433
|
schematicBox,
|
|
8296
8434
|
transform,
|
|
8297
8435
|
colorMap: colorMap2
|
|
8298
8436
|
}) => {
|
|
8299
|
-
const topLeft =
|
|
8437
|
+
const topLeft = applyToPoint57(transform, {
|
|
8300
8438
|
x: schematicBox.x,
|
|
8301
8439
|
y: schematicBox.y
|
|
8302
8440
|
});
|
|
8303
|
-
const bottomRight =
|
|
8441
|
+
const bottomRight = applyToPoint57(transform, {
|
|
8304
8442
|
x: schematicBox.x + schematicBox.width,
|
|
8305
8443
|
y: schematicBox.y + schematicBox.height
|
|
8306
8444
|
});
|
|
@@ -8336,7 +8474,7 @@ var createSvgObjectsFromSchematicBox = ({
|
|
|
8336
8474
|
};
|
|
8337
8475
|
|
|
8338
8476
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-table.ts
|
|
8339
|
-
import { applyToPoint as
|
|
8477
|
+
import { applyToPoint as applyToPoint58 } from "transformation-matrix";
|
|
8340
8478
|
var createSvgObjectsFromSchematicTable = ({
|
|
8341
8479
|
schematicTable,
|
|
8342
8480
|
transform,
|
|
@@ -8369,11 +8507,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8369
8507
|
const svgObjects = [];
|
|
8370
8508
|
const borderStrokeWidth = border_width * Math.abs(transform.a);
|
|
8371
8509
|
const gridStrokeWidth = getSchStrokeSize(transform);
|
|
8372
|
-
const [screenTopLeftX, screenTopLeftY] =
|
|
8510
|
+
const [screenTopLeftX, screenTopLeftY] = applyToPoint58(transform, [
|
|
8373
8511
|
topLeftX,
|
|
8374
8512
|
topLeftY
|
|
8375
8513
|
]);
|
|
8376
|
-
const [screenBottomRightX, screenBottomRightY] =
|
|
8514
|
+
const [screenBottomRightX, screenBottomRightY] = applyToPoint58(transform, [
|
|
8377
8515
|
topLeftX + totalWidth,
|
|
8378
8516
|
topLeftY - totalHeight
|
|
8379
8517
|
]);
|
|
@@ -8405,8 +8543,8 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8405
8543
|
(cell) => cell.start_column_index <= i && cell.end_column_index > i && cell.start_row_index <= j && cell.end_row_index >= j
|
|
8406
8544
|
);
|
|
8407
8545
|
if (!isMerged) {
|
|
8408
|
-
const start =
|
|
8409
|
-
const end =
|
|
8546
|
+
const start = applyToPoint58(transform, { x: currentX, y: segmentStartY });
|
|
8547
|
+
const end = applyToPoint58(transform, { x: currentX, y: segmentEndY });
|
|
8410
8548
|
svgObjects.push({
|
|
8411
8549
|
name: "line",
|
|
8412
8550
|
type: "element",
|
|
@@ -8435,11 +8573,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8435
8573
|
(cell) => cell.start_row_index <= i && cell.end_row_index > i && cell.start_column_index <= j && cell.end_column_index >= j
|
|
8436
8574
|
);
|
|
8437
8575
|
if (!isMerged) {
|
|
8438
|
-
const start =
|
|
8576
|
+
const start = applyToPoint58(transform, {
|
|
8439
8577
|
x: segmentStartX,
|
|
8440
8578
|
y: currentY
|
|
8441
8579
|
});
|
|
8442
|
-
const end =
|
|
8580
|
+
const end = applyToPoint58(transform, { x: segmentEndX, y: currentY });
|
|
8443
8581
|
svgObjects.push({
|
|
8444
8582
|
name: "line",
|
|
8445
8583
|
type: "element",
|
|
@@ -8481,7 +8619,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8481
8619
|
} else if (vertical_align === "bottom") {
|
|
8482
8620
|
realTextAnchorPos.y = cellTopLeftY - cellHeight + cell_padding;
|
|
8483
8621
|
}
|
|
8484
|
-
const screenTextAnchorPos =
|
|
8622
|
+
const screenTextAnchorPos = applyToPoint58(transform, realTextAnchorPos);
|
|
8485
8623
|
const fontSize = getSchScreenFontSize(
|
|
8486
8624
|
transform,
|
|
8487
8625
|
"reference_designator",
|
|
@@ -8537,13 +8675,13 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8537
8675
|
|
|
8538
8676
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
|
|
8539
8677
|
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
8540
|
-
import { applyToPoint as
|
|
8678
|
+
import { applyToPoint as applyToPoint59 } from "transformation-matrix";
|
|
8541
8679
|
var PIN_CIRCLE_RADIUS_MM2 = 0.02;
|
|
8542
8680
|
var createSvgObjectsForSchPortHover = ({
|
|
8543
8681
|
schPort,
|
|
8544
8682
|
transform
|
|
8545
8683
|
}) => {
|
|
8546
|
-
const screenSchPortPos =
|
|
8684
|
+
const screenSchPortPos = applyToPoint59(transform, schPort.center);
|
|
8547
8685
|
const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
|
|
8548
8686
|
return [
|
|
8549
8687
|
{
|
|
@@ -8588,14 +8726,14 @@ var createSvgObjectsForSchComponentPortHovers = ({
|
|
|
8588
8726
|
};
|
|
8589
8727
|
|
|
8590
8728
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-line.ts
|
|
8591
|
-
import { applyToPoint as
|
|
8729
|
+
import { applyToPoint as applyToPoint60 } from "transformation-matrix";
|
|
8592
8730
|
function createSvgObjectsFromSchematicLine({
|
|
8593
8731
|
schLine,
|
|
8594
8732
|
transform,
|
|
8595
8733
|
colorMap: colorMap2
|
|
8596
8734
|
}) {
|
|
8597
|
-
const p1 =
|
|
8598
|
-
const p2 =
|
|
8735
|
+
const p1 = applyToPoint60(transform, { x: schLine.x1, y: schLine.y1 });
|
|
8736
|
+
const p2 = applyToPoint60(transform, { x: schLine.x2, y: schLine.y2 });
|
|
8599
8737
|
const strokeWidth = schLine.stroke_width ?? 0.02;
|
|
8600
8738
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
8601
8739
|
return [
|
|
@@ -8624,13 +8762,13 @@ function createSvgObjectsFromSchematicLine({
|
|
|
8624
8762
|
}
|
|
8625
8763
|
|
|
8626
8764
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-circle.ts
|
|
8627
|
-
import { applyToPoint as
|
|
8765
|
+
import { applyToPoint as applyToPoint61 } from "transformation-matrix";
|
|
8628
8766
|
function createSvgObjectsFromSchematicCircle({
|
|
8629
8767
|
schCircle,
|
|
8630
8768
|
transform,
|
|
8631
8769
|
colorMap: colorMap2
|
|
8632
8770
|
}) {
|
|
8633
|
-
const center =
|
|
8771
|
+
const center = applyToPoint61(transform, schCircle.center);
|
|
8634
8772
|
const transformedRadius = Math.abs(transform.a) * schCircle.radius;
|
|
8635
8773
|
const strokeWidth = schCircle.stroke_width ?? 0.02;
|
|
8636
8774
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -8660,13 +8798,13 @@ function createSvgObjectsFromSchematicCircle({
|
|
|
8660
8798
|
}
|
|
8661
8799
|
|
|
8662
8800
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-rect.ts
|
|
8663
|
-
import { applyToPoint as
|
|
8801
|
+
import { applyToPoint as applyToPoint62 } from "transformation-matrix";
|
|
8664
8802
|
function createSvgObjectsFromSchematicRect({
|
|
8665
8803
|
schRect,
|
|
8666
8804
|
transform,
|
|
8667
8805
|
colorMap: colorMap2
|
|
8668
8806
|
}) {
|
|
8669
|
-
const center =
|
|
8807
|
+
const center = applyToPoint62(transform, schRect.center);
|
|
8670
8808
|
const transformedWidth = Math.abs(transform.a) * schRect.width;
|
|
8671
8809
|
const transformedHeight = Math.abs(transform.d) * schRect.height;
|
|
8672
8810
|
const strokeWidth = schRect.stroke_width ?? 0.02;
|
|
@@ -8702,13 +8840,13 @@ function createSvgObjectsFromSchematicRect({
|
|
|
8702
8840
|
}
|
|
8703
8841
|
|
|
8704
8842
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-arc.ts
|
|
8705
|
-
import { applyToPoint as
|
|
8843
|
+
import { applyToPoint as applyToPoint63 } from "transformation-matrix";
|
|
8706
8844
|
function createSvgObjectsFromSchematicArc({
|
|
8707
8845
|
schArc,
|
|
8708
8846
|
transform,
|
|
8709
8847
|
colorMap: colorMap2
|
|
8710
8848
|
}) {
|
|
8711
|
-
const center =
|
|
8849
|
+
const center = applyToPoint63(transform, schArc.center);
|
|
8712
8850
|
const transformedRadius = Math.abs(transform.a) * schArc.radius;
|
|
8713
8851
|
const strokeWidth = schArc.stroke_width ?? 0.02;
|
|
8714
8852
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -9740,18 +9878,18 @@ function formatNumber2(value) {
|
|
|
9740
9878
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
9741
9879
|
import { stringify as stringify7 } from "svgson";
|
|
9742
9880
|
import {
|
|
9743
|
-
applyToPoint as
|
|
9881
|
+
applyToPoint as applyToPoint66,
|
|
9744
9882
|
compose as compose14,
|
|
9745
9883
|
scale as scale8,
|
|
9746
9884
|
translate as translate14
|
|
9747
9885
|
} from "transformation-matrix";
|
|
9748
9886
|
|
|
9749
9887
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
9750
|
-
import { applyToPoint as
|
|
9888
|
+
import { applyToPoint as applyToPoint65 } from "transformation-matrix";
|
|
9751
9889
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
9752
9890
|
const { transform, layer: layerFilter } = ctx;
|
|
9753
9891
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
9754
|
-
const [x, y] =
|
|
9892
|
+
const [x, y] = applyToPoint65(transform, [solderPaste.x, solderPaste.y]);
|
|
9755
9893
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
9756
9894
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
9757
9895
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -9962,8 +10100,8 @@ function createSvgObjects4({ elm, ctx }) {
|
|
|
9962
10100
|
}
|
|
9963
10101
|
}
|
|
9964
10102
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
9965
|
-
const [x1, y1] =
|
|
9966
|
-
const [x2, y2] =
|
|
10103
|
+
const [x1, y1] = applyToPoint66(transform, [minX, minY]);
|
|
10104
|
+
const [x2, y2] = applyToPoint66(transform, [maxX, maxY]);
|
|
9967
10105
|
const width = Math.abs(x2 - x1);
|
|
9968
10106
|
const height = Math.abs(y2 - y1);
|
|
9969
10107
|
const x = Math.min(x1, x2);
|