circuit-to-svg 0.0.231 → 0.0.232
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 +436 -187
- 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 applyToPoint26,
|
|
5
5
|
compose as compose5,
|
|
6
6
|
scale as scale2,
|
|
7
7
|
translate as translate5
|
|
@@ -680,11 +680,248 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
|
|
|
680
680
|
}
|
|
681
681
|
}
|
|
682
682
|
|
|
683
|
-
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-
|
|
683
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-text.ts
|
|
684
684
|
import { applyToPoint as applyToPoint6 } from "transformation-matrix";
|
|
685
|
+
var DEFAULT_OVERLAY_COLOR = "rgba(255,255,255,0.5)";
|
|
686
|
+
function createSvgObjectsFromPcbNoteText(note, ctx) {
|
|
687
|
+
const { transform } = ctx;
|
|
688
|
+
const {
|
|
689
|
+
anchor_position,
|
|
690
|
+
text,
|
|
691
|
+
font_size = 1,
|
|
692
|
+
anchor_alignment = "center",
|
|
693
|
+
color
|
|
694
|
+
} = note;
|
|
695
|
+
if (!anchor_position || typeof anchor_position.x !== "number" || typeof anchor_position.y !== "number") {
|
|
696
|
+
console.error("Invalid pcb_note_text anchor_position", anchor_position);
|
|
697
|
+
return [];
|
|
698
|
+
}
|
|
699
|
+
if (typeof text !== "string" || text.length === 0) {
|
|
700
|
+
console.error("Invalid pcb_note_text text", text);
|
|
701
|
+
return [];
|
|
702
|
+
}
|
|
703
|
+
const [x, y] = applyToPoint6(transform, [anchor_position.x, anchor_position.y]);
|
|
704
|
+
const transformedFontSize = font_size * Math.abs(transform.a);
|
|
705
|
+
let textAnchor = "middle";
|
|
706
|
+
let dominantBaseline = "central";
|
|
707
|
+
switch (anchor_alignment) {
|
|
708
|
+
case "top_left":
|
|
709
|
+
textAnchor = "start";
|
|
710
|
+
dominantBaseline = "text-before-edge";
|
|
711
|
+
break;
|
|
712
|
+
case "top_right":
|
|
713
|
+
textAnchor = "end";
|
|
714
|
+
dominantBaseline = "text-before-edge";
|
|
715
|
+
break;
|
|
716
|
+
case "bottom_left":
|
|
717
|
+
textAnchor = "start";
|
|
718
|
+
dominantBaseline = "text-after-edge";
|
|
719
|
+
break;
|
|
720
|
+
case "bottom_right":
|
|
721
|
+
textAnchor = "end";
|
|
722
|
+
dominantBaseline = "text-after-edge";
|
|
723
|
+
break;
|
|
724
|
+
case "center":
|
|
725
|
+
default:
|
|
726
|
+
textAnchor = "middle";
|
|
727
|
+
dominantBaseline = "central";
|
|
728
|
+
break;
|
|
729
|
+
}
|
|
730
|
+
const svgObject = {
|
|
731
|
+
name: "text",
|
|
732
|
+
type: "element",
|
|
733
|
+
value: "",
|
|
734
|
+
attributes: {
|
|
735
|
+
x: x.toString(),
|
|
736
|
+
y: y.toString(),
|
|
737
|
+
fill: color ?? DEFAULT_OVERLAY_COLOR,
|
|
738
|
+
"font-family": "Arial, sans-serif",
|
|
739
|
+
"font-size": transformedFontSize.toString(),
|
|
740
|
+
"text-anchor": textAnchor,
|
|
741
|
+
"dominant-baseline": dominantBaseline,
|
|
742
|
+
class: "pcb-note-text",
|
|
743
|
+
"data-type": "pcb_note_text",
|
|
744
|
+
"data-pcb-note-text-id": note.pcb_note_text_id,
|
|
745
|
+
"data-pcb-layer": "overlay"
|
|
746
|
+
},
|
|
747
|
+
children: [
|
|
748
|
+
{
|
|
749
|
+
type: "text",
|
|
750
|
+
name: "",
|
|
751
|
+
value: text,
|
|
752
|
+
attributes: {},
|
|
753
|
+
children: []
|
|
754
|
+
}
|
|
755
|
+
]
|
|
756
|
+
};
|
|
757
|
+
return [svgObject];
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-rect.ts
|
|
761
|
+
import { applyToPoint as applyToPoint7 } from "transformation-matrix";
|
|
762
|
+
var DEFAULT_OVERLAY_COLOR2 = "rgba(255,255,255,0.5)";
|
|
763
|
+
var DEFAULT_FILL_COLOR = "rgba(255,255,255,0.2)";
|
|
764
|
+
function createSvgObjectsFromPcbNoteRect(noteRect, ctx) {
|
|
765
|
+
const { transform } = ctx;
|
|
766
|
+
const {
|
|
767
|
+
center,
|
|
768
|
+
width,
|
|
769
|
+
height,
|
|
770
|
+
stroke_width,
|
|
771
|
+
is_filled,
|
|
772
|
+
has_stroke,
|
|
773
|
+
is_stroke_dashed,
|
|
774
|
+
color
|
|
775
|
+
} = noteRect;
|
|
776
|
+
if (!center || typeof center.x !== "number" || typeof center.y !== "number" || typeof width !== "number" || typeof height !== "number") {
|
|
777
|
+
console.error("Invalid pcb_note_rect data", { center, width, height });
|
|
778
|
+
return [];
|
|
779
|
+
}
|
|
780
|
+
const halfWidth = width / 2;
|
|
781
|
+
const halfHeight = height / 2;
|
|
782
|
+
const [topLeftX, topLeftY] = applyToPoint7(transform, [
|
|
783
|
+
center.x - halfWidth,
|
|
784
|
+
center.y + halfHeight
|
|
785
|
+
]);
|
|
786
|
+
const [bottomRightX, bottomRightY] = applyToPoint7(transform, [
|
|
787
|
+
center.x + halfWidth,
|
|
788
|
+
center.y - halfHeight
|
|
789
|
+
]);
|
|
790
|
+
const rectX = Math.min(topLeftX, bottomRightX);
|
|
791
|
+
const rectY = Math.min(topLeftY, bottomRightY);
|
|
792
|
+
const rectWidth = Math.abs(bottomRightX - topLeftX);
|
|
793
|
+
const rectHeight = Math.abs(bottomRightY - topLeftY);
|
|
794
|
+
const baseStrokeWidth = typeof stroke_width === "number" ? stroke_width : 0;
|
|
795
|
+
const transformedStrokeWidth = baseStrokeWidth * Math.abs(transform.a);
|
|
796
|
+
const overlayColor = color ?? DEFAULT_OVERLAY_COLOR2;
|
|
797
|
+
const attributes = {
|
|
798
|
+
x: rectX.toString(),
|
|
799
|
+
y: rectY.toString(),
|
|
800
|
+
width: rectWidth.toString(),
|
|
801
|
+
height: rectHeight.toString(),
|
|
802
|
+
class: "pcb-note-rect",
|
|
803
|
+
"data-type": "pcb_note_rect",
|
|
804
|
+
"data-pcb-note-rect-id": noteRect.pcb_note_rect_id,
|
|
805
|
+
"data-pcb-layer": "overlay"
|
|
806
|
+
};
|
|
807
|
+
if (is_filled) {
|
|
808
|
+
attributes.fill = color ?? DEFAULT_FILL_COLOR;
|
|
809
|
+
} else {
|
|
810
|
+
attributes.fill = "none";
|
|
811
|
+
}
|
|
812
|
+
const shouldDrawStroke = has_stroke ?? transformedStrokeWidth > 0;
|
|
813
|
+
if (shouldDrawStroke) {
|
|
814
|
+
attributes.stroke = overlayColor;
|
|
815
|
+
attributes["stroke-width"] = transformedStrokeWidth.toString();
|
|
816
|
+
if (is_stroke_dashed) {
|
|
817
|
+
const dash = 0.2 * Math.abs(transform.a);
|
|
818
|
+
const gap = 0.1 * Math.abs(transform.a);
|
|
819
|
+
attributes["stroke-dasharray"] = `${dash} ${gap}`;
|
|
820
|
+
}
|
|
821
|
+
} else {
|
|
822
|
+
attributes.stroke = "none";
|
|
823
|
+
}
|
|
824
|
+
const svgObject = {
|
|
825
|
+
name: "rect",
|
|
826
|
+
type: "element",
|
|
827
|
+
value: "",
|
|
828
|
+
attributes,
|
|
829
|
+
children: []
|
|
830
|
+
};
|
|
831
|
+
return [svgObject];
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-path.ts
|
|
835
|
+
import { applyToPoint as applyToPoint8 } from "transformation-matrix";
|
|
836
|
+
var DEFAULT_OVERLAY_COLOR3 = "rgba(255,255,255,0.5)";
|
|
837
|
+
function createSvgObjectsFromPcbNotePath(notePath, ctx) {
|
|
838
|
+
const { transform } = ctx;
|
|
839
|
+
if (!Array.isArray(notePath.route) || notePath.route.length === 0) {
|
|
840
|
+
console.error("Invalid pcb_note_path route", notePath.route);
|
|
841
|
+
return [];
|
|
842
|
+
}
|
|
843
|
+
for (const point of notePath.route) {
|
|
844
|
+
if (typeof point.x !== "number" || typeof point.y !== "number") {
|
|
845
|
+
console.error("Invalid point in pcb_note_path", point);
|
|
846
|
+
return [];
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
const pathD = notePath.route.map((point, index) => {
|
|
850
|
+
const [x, y] = applyToPoint8(transform, [point.x, point.y]);
|
|
851
|
+
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
852
|
+
}).join(" ");
|
|
853
|
+
const strokeWidth = notePath.stroke_width * Math.abs(transform.a);
|
|
854
|
+
const svgObject = {
|
|
855
|
+
name: "path",
|
|
856
|
+
type: "element",
|
|
857
|
+
value: "",
|
|
858
|
+
attributes: {
|
|
859
|
+
d: pathD,
|
|
860
|
+
stroke: notePath.color ?? DEFAULT_OVERLAY_COLOR3,
|
|
861
|
+
fill: "none",
|
|
862
|
+
"stroke-width": strokeWidth.toString(),
|
|
863
|
+
class: "pcb-note-path",
|
|
864
|
+
"data-type": "pcb_note_path",
|
|
865
|
+
"data-pcb-note-path-id": notePath.pcb_note_path_id,
|
|
866
|
+
"data-pcb-layer": "overlay"
|
|
867
|
+
},
|
|
868
|
+
children: []
|
|
869
|
+
};
|
|
870
|
+
return [svgObject];
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-line.ts
|
|
874
|
+
import { applyToPoint as applyToPoint9 } from "transformation-matrix";
|
|
875
|
+
var DEFAULT_OVERLAY_COLOR4 = "rgba(255,255,255,0.5)";
|
|
876
|
+
function createSvgObjectsFromPcbNoteLine(noteLine, ctx) {
|
|
877
|
+
const { transform } = ctx;
|
|
878
|
+
const { x1, y1, x2, y2, stroke_width, color, is_dashed } = noteLine;
|
|
879
|
+
if (typeof x1 !== "number" || typeof y1 !== "number" || typeof x2 !== "number" || typeof y2 !== "number") {
|
|
880
|
+
console.error("Invalid pcb_note_line coordinates", {
|
|
881
|
+
x1,
|
|
882
|
+
y1,
|
|
883
|
+
x2,
|
|
884
|
+
y2
|
|
885
|
+
});
|
|
886
|
+
return [];
|
|
887
|
+
}
|
|
888
|
+
const [startX, startY] = applyToPoint9(transform, [x1, y1]);
|
|
889
|
+
const [endX, endY] = applyToPoint9(transform, [x2, y2]);
|
|
890
|
+
const baseStrokeWidth = typeof stroke_width === "number" ? stroke_width : 0;
|
|
891
|
+
const transformedStrokeWidth = baseStrokeWidth * Math.abs(transform.a);
|
|
892
|
+
const attributes = {
|
|
893
|
+
x1: startX.toString(),
|
|
894
|
+
y1: startY.toString(),
|
|
895
|
+
x2: endX.toString(),
|
|
896
|
+
y2: endY.toString(),
|
|
897
|
+
stroke: color ?? DEFAULT_OVERLAY_COLOR4,
|
|
898
|
+
"stroke-width": transformedStrokeWidth.toString(),
|
|
899
|
+
"stroke-linecap": "round",
|
|
900
|
+
class: "pcb-note-line",
|
|
901
|
+
"data-type": "pcb_note_line",
|
|
902
|
+
"data-pcb-note-line-id": noteLine.pcb_note_line_id,
|
|
903
|
+
"data-pcb-layer": "overlay"
|
|
904
|
+
};
|
|
905
|
+
if (is_dashed) {
|
|
906
|
+
const dash = 0.2 * Math.abs(transform.a);
|
|
907
|
+
const gap = 0.1 * Math.abs(transform.a);
|
|
908
|
+
attributes["stroke-dasharray"] = `${dash} ${gap}`;
|
|
909
|
+
}
|
|
910
|
+
const svgObject = {
|
|
911
|
+
name: "line",
|
|
912
|
+
type: "element",
|
|
913
|
+
value: "",
|
|
914
|
+
attributes,
|
|
915
|
+
children: []
|
|
916
|
+
};
|
|
917
|
+
return [svgObject];
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-plated-hole.ts
|
|
921
|
+
import { applyToPoint as applyToPoint10 } from "transformation-matrix";
|
|
685
922
|
function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
686
923
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
687
|
-
const [x, y] =
|
|
924
|
+
const [x, y] = applyToPoint10(transform, [hole.x, hole.y]);
|
|
688
925
|
const copperLayer = Array.isArray(hole.layers) && hole.layers[0] || hole.layer || "top";
|
|
689
926
|
if (hole.shape === "pill") {
|
|
690
927
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
@@ -801,7 +1038,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
801
1038
|
const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
|
|
802
1039
|
const scaledRectBorderRadius = (hole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
803
1040
|
const holeRadius = scaledHoleDiameter / 2;
|
|
804
|
-
const [holeCx, holeCy] =
|
|
1041
|
+
const [holeCx, holeCy] = applyToPoint10(transform, [
|
|
805
1042
|
h.x + (h.hole_offset_x ?? 0),
|
|
806
1043
|
h.y + (h.hole_offset_y ?? 0)
|
|
807
1044
|
]);
|
|
@@ -866,7 +1103,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
866
1103
|
const pillHoleWithOffsets = pillHole;
|
|
867
1104
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
868
1105
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
869
|
-
const [holeCenterX, holeCenterY] =
|
|
1106
|
+
const [holeCenterX, holeCenterY] = applyToPoint10(transform, [
|
|
870
1107
|
pillHole.x + holeOffsetX,
|
|
871
1108
|
pillHole.y + holeOffsetY
|
|
872
1109
|
]);
|
|
@@ -935,7 +1172,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
935
1172
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
936
1173
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
937
1174
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
938
|
-
const [holeCenterX, holeCenterY] =
|
|
1175
|
+
const [holeCenterX, holeCenterY] = applyToPoint10(transform, [
|
|
939
1176
|
rotatedHole.x + holeOffsetX,
|
|
940
1177
|
rotatedHole.y + holeOffsetY
|
|
941
1178
|
]);
|
|
@@ -998,12 +1235,12 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
998
1235
|
}
|
|
999
1236
|
|
|
1000
1237
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-path.ts
|
|
1001
|
-
import { applyToPoint as
|
|
1238
|
+
import { applyToPoint as applyToPoint11 } from "transformation-matrix";
|
|
1002
1239
|
function createSvgObjectsFromPcbSilkscreenPath(silkscreenPath, ctx) {
|
|
1003
1240
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1004
1241
|
if (!silkscreenPath.route || !Array.isArray(silkscreenPath.route)) return [];
|
|
1005
1242
|
let path = silkscreenPath.route.map((point, index) => {
|
|
1006
|
-
const [x, y] =
|
|
1243
|
+
const [x, y] = applyToPoint11(transform, [point.x, point.y]);
|
|
1007
1244
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
1008
1245
|
}).join(" ");
|
|
1009
1246
|
const firstPoint = silkscreenPath.route[0];
|
|
@@ -1039,7 +1276,7 @@ function createSvgObjectsFromPcbSilkscreenPath(silkscreenPath, ctx) {
|
|
|
1039
1276
|
|
|
1040
1277
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-text.ts
|
|
1041
1278
|
import {
|
|
1042
|
-
applyToPoint as
|
|
1279
|
+
applyToPoint as applyToPoint12,
|
|
1043
1280
|
compose as compose2,
|
|
1044
1281
|
rotate as rotate2,
|
|
1045
1282
|
translate as translate2,
|
|
@@ -1061,7 +1298,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
1061
1298
|
console.error("Invalid anchor_position:", anchor_position);
|
|
1062
1299
|
return [];
|
|
1063
1300
|
}
|
|
1064
|
-
const [transformedX, transformedY] =
|
|
1301
|
+
const [transformedX, transformedY] = applyToPoint12(transform, [
|
|
1065
1302
|
anchor_position.x,
|
|
1066
1303
|
anchor_position.y
|
|
1067
1304
|
]);
|
|
@@ -1169,7 +1406,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
1169
1406
|
}
|
|
1170
1407
|
|
|
1171
1408
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-rect.ts
|
|
1172
|
-
import { applyToPoint as
|
|
1409
|
+
import { applyToPoint as applyToPoint13 } from "transformation-matrix";
|
|
1173
1410
|
function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
|
|
1174
1411
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1175
1412
|
const {
|
|
@@ -1188,7 +1425,7 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
|
|
|
1188
1425
|
console.error("Invalid rectangle data:", { center, width, height });
|
|
1189
1426
|
return [];
|
|
1190
1427
|
}
|
|
1191
|
-
const [transformedX, transformedY] =
|
|
1428
|
+
const [transformedX, transformedY] = applyToPoint13(transform, [
|
|
1192
1429
|
center.x,
|
|
1193
1430
|
center.y
|
|
1194
1431
|
]);
|
|
@@ -1235,7 +1472,7 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
|
|
|
1235
1472
|
}
|
|
1236
1473
|
|
|
1237
1474
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-circle.ts
|
|
1238
|
-
import { applyToPoint as
|
|
1475
|
+
import { applyToPoint as applyToPoint14 } from "transformation-matrix";
|
|
1239
1476
|
function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
1240
1477
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1241
1478
|
const {
|
|
@@ -1250,7 +1487,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
|
1250
1487
|
console.error("Invalid PCB Silkscreen Circle data:", { center, radius });
|
|
1251
1488
|
return [];
|
|
1252
1489
|
}
|
|
1253
|
-
const [transformedX, transformedY] =
|
|
1490
|
+
const [transformedX, transformedY] = applyToPoint14(transform, [
|
|
1254
1491
|
center.x,
|
|
1255
1492
|
center.y
|
|
1256
1493
|
]);
|
|
@@ -1278,7 +1515,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
|
1278
1515
|
}
|
|
1279
1516
|
|
|
1280
1517
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-line.ts
|
|
1281
|
-
import { applyToPoint as
|
|
1518
|
+
import { applyToPoint as applyToPoint15 } from "transformation-matrix";
|
|
1282
1519
|
function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
|
|
1283
1520
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1284
1521
|
const {
|
|
@@ -1295,8 +1532,8 @@ function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
|
|
|
1295
1532
|
console.error("Invalid coordinates:", { x1, y1, x2, y2 });
|
|
1296
1533
|
return [];
|
|
1297
1534
|
}
|
|
1298
|
-
const [transformedX1, transformedY1] =
|
|
1299
|
-
const [transformedX2, transformedY2] =
|
|
1535
|
+
const [transformedX1, transformedY1] = applyToPoint15(transform, [x1, y1]);
|
|
1536
|
+
const [transformedX2, transformedY2] = applyToPoint15(transform, [x2, y2]);
|
|
1300
1537
|
const transformedStrokeWidth = stroke_width * Math.abs(transform.a);
|
|
1301
1538
|
const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
|
|
1302
1539
|
return [
|
|
@@ -1331,7 +1568,7 @@ function pairs(arr) {
|
|
|
1331
1568
|
}
|
|
1332
1569
|
|
|
1333
1570
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace.ts
|
|
1334
|
-
import { applyToPoint as
|
|
1571
|
+
import { applyToPoint as applyToPoint16 } from "transformation-matrix";
|
|
1335
1572
|
|
|
1336
1573
|
// lib/pcb/colors.ts
|
|
1337
1574
|
var DEFAULT_PCB_COLOR_MAP = {
|
|
@@ -1387,8 +1624,8 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
|
1387
1624
|
const segments = pairs(trace.route);
|
|
1388
1625
|
const svgObjects = [];
|
|
1389
1626
|
for (const [start, end] of segments) {
|
|
1390
|
-
const startPoint =
|
|
1391
|
-
const endPoint =
|
|
1627
|
+
const startPoint = applyToPoint16(transform, [start.x, start.y]);
|
|
1628
|
+
const endPoint = applyToPoint16(transform, [end.x, end.y]);
|
|
1392
1629
|
const layer = "layer" in start ? start.layer : "layer" in end ? end.layer : null;
|
|
1393
1630
|
if (!layer) continue;
|
|
1394
1631
|
if (layerFilter && layer !== layerFilter) continue;
|
|
@@ -1460,7 +1697,7 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
|
1460
1697
|
}
|
|
1461
1698
|
|
|
1462
1699
|
// lib/pcb/svg-object-fns/create-svg-objects-from-smt-pads.ts
|
|
1463
|
-
import { applyToPoint as
|
|
1700
|
+
import { applyToPoint as applyToPoint17 } from "transformation-matrix";
|
|
1464
1701
|
function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
1465
1702
|
const { transform, layer: layerFilter, colorMap: colorMap2, renderSolderMask } = ctx;
|
|
1466
1703
|
if (layerFilter && pad.layer !== layerFilter) return [];
|
|
@@ -1470,7 +1707,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1470
1707
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
1471
1708
|
const width = pad.width * Math.abs(transform.a);
|
|
1472
1709
|
const height = pad.height * Math.abs(transform.d);
|
|
1473
|
-
const [x, y] =
|
|
1710
|
+
const [x, y] = applyToPoint17(transform, [pad.x, pad.y]);
|
|
1474
1711
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
1475
1712
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
1476
1713
|
const padElement2 = {
|
|
@@ -1552,7 +1789,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1552
1789
|
const width = pad.width * Math.abs(transform.a);
|
|
1553
1790
|
const height = pad.height * Math.abs(transform.d);
|
|
1554
1791
|
const radius = pad.radius * Math.abs(transform.a);
|
|
1555
|
-
const [x, y] =
|
|
1792
|
+
const [x, y] = applyToPoint17(transform, [pad.x, pad.y]);
|
|
1556
1793
|
const padElement = {
|
|
1557
1794
|
name: "rect",
|
|
1558
1795
|
type: "element",
|
|
@@ -1590,7 +1827,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1590
1827
|
}
|
|
1591
1828
|
if (pad.shape === "circle") {
|
|
1592
1829
|
const radius = pad.radius * Math.abs(transform.a);
|
|
1593
|
-
const [x, y] =
|
|
1830
|
+
const [x, y] = applyToPoint17(transform, [pad.x, pad.y]);
|
|
1594
1831
|
const padElement = {
|
|
1595
1832
|
name: "circle",
|
|
1596
1833
|
type: "element",
|
|
@@ -1625,7 +1862,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1625
1862
|
}
|
|
1626
1863
|
if (pad.shape === "polygon") {
|
|
1627
1864
|
const points = (pad.points ?? []).map(
|
|
1628
|
-
(point) =>
|
|
1865
|
+
(point) => applyToPoint17(transform, [point.x, point.y])
|
|
1629
1866
|
);
|
|
1630
1867
|
const padElement = {
|
|
1631
1868
|
name: "polygon",
|
|
@@ -1661,32 +1898,32 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1661
1898
|
}
|
|
1662
1899
|
|
|
1663
1900
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-board.ts
|
|
1664
|
-
import { applyToPoint as
|
|
1901
|
+
import { applyToPoint as applyToPoint18 } from "transformation-matrix";
|
|
1665
1902
|
function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
1666
1903
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
1667
1904
|
const { width, height, center, outline } = pcbBoard;
|
|
1668
1905
|
let path;
|
|
1669
1906
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
1670
1907
|
path = outline.map((point, index) => {
|
|
1671
|
-
const [x, y] =
|
|
1908
|
+
const [x, y] = applyToPoint18(transform, [point.x, point.y]);
|
|
1672
1909
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
1673
1910
|
}).join(" ");
|
|
1674
1911
|
} else {
|
|
1675
1912
|
const halfWidth = width / 2;
|
|
1676
1913
|
const halfHeight = height / 2;
|
|
1677
|
-
const topLeft =
|
|
1914
|
+
const topLeft = applyToPoint18(transform, [
|
|
1678
1915
|
center.x - halfWidth,
|
|
1679
1916
|
center.y - halfHeight
|
|
1680
1917
|
]);
|
|
1681
|
-
const topRight =
|
|
1918
|
+
const topRight = applyToPoint18(transform, [
|
|
1682
1919
|
center.x + halfWidth,
|
|
1683
1920
|
center.y - halfHeight
|
|
1684
1921
|
]);
|
|
1685
|
-
const bottomRight =
|
|
1922
|
+
const bottomRight = applyToPoint18(transform, [
|
|
1686
1923
|
center.x + halfWidth,
|
|
1687
1924
|
center.y + halfHeight
|
|
1688
1925
|
]);
|
|
1689
|
-
const bottomLeft =
|
|
1926
|
+
const bottomLeft = applyToPoint18(transform, [
|
|
1690
1927
|
center.x - halfWidth,
|
|
1691
1928
|
center.y + halfHeight
|
|
1692
1929
|
]);
|
|
@@ -1713,10 +1950,10 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
|
1713
1950
|
}
|
|
1714
1951
|
|
|
1715
1952
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-via.ts
|
|
1716
|
-
import { applyToPoint as
|
|
1953
|
+
import { applyToPoint as applyToPoint19 } from "transformation-matrix";
|
|
1717
1954
|
function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
1718
1955
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
1719
|
-
const [x, y] =
|
|
1956
|
+
const [x, y] = applyToPoint19(transform, [hole.x, hole.y]);
|
|
1720
1957
|
const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a);
|
|
1721
1958
|
const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a);
|
|
1722
1959
|
const scaledHoleWidth = hole.hole_diameter * Math.abs(transform.a);
|
|
@@ -1762,10 +1999,10 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
|
1762
1999
|
}
|
|
1763
2000
|
|
|
1764
2001
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-hole.ts
|
|
1765
|
-
import { applyToPoint as
|
|
2002
|
+
import { applyToPoint as applyToPoint20 } from "transformation-matrix";
|
|
1766
2003
|
function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
1767
2004
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
1768
|
-
const [x, y] =
|
|
2005
|
+
const [x, y] = applyToPoint20(transform, [hole.x, hole.y]);
|
|
1769
2006
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
1770
2007
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
1771
2008
|
const radius = scaledDiameter / 2;
|
|
@@ -1839,7 +2076,7 @@ import {
|
|
|
1839
2076
|
getFullConnectivityMapFromCircuitJson
|
|
1840
2077
|
} from "circuit-json-to-connectivity-map";
|
|
1841
2078
|
import "svgson";
|
|
1842
|
-
import { applyToPoint as
|
|
2079
|
+
import { applyToPoint as applyToPoint21 } from "transformation-matrix";
|
|
1843
2080
|
|
|
1844
2081
|
// lib/pcb/create-svg-objects-from-pcb-rats-nest/get-element-position.ts
|
|
1845
2082
|
import { su } from "@tscircuit/circuit-json-util";
|
|
@@ -1919,11 +2156,11 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
1919
2156
|
});
|
|
1920
2157
|
const svgObjects = [];
|
|
1921
2158
|
for (const line of ratsNestLines) {
|
|
1922
|
-
const transformedStart =
|
|
2159
|
+
const transformedStart = applyToPoint21(transform, [
|
|
1923
2160
|
line.startPoint.x,
|
|
1924
2161
|
line.startPoint.y
|
|
1925
2162
|
]);
|
|
1926
|
-
const transformedEnd =
|
|
2163
|
+
const transformedEnd = applyToPoint21(transform, [
|
|
1927
2164
|
line.endPoint.x,
|
|
1928
2165
|
line.endPoint.y
|
|
1929
2166
|
]);
|
|
@@ -1951,7 +2188,7 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
1951
2188
|
|
|
1952
2189
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-cutout.ts
|
|
1953
2190
|
import {
|
|
1954
|
-
applyToPoint as
|
|
2191
|
+
applyToPoint as applyToPoint22,
|
|
1955
2192
|
compose as compose3,
|
|
1956
2193
|
rotate as rotate3,
|
|
1957
2194
|
translate as translate3,
|
|
@@ -1961,7 +2198,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
1961
2198
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
1962
2199
|
if (cutout.shape === "rect") {
|
|
1963
2200
|
const rectCutout = cutout;
|
|
1964
|
-
const [cx, cy] =
|
|
2201
|
+
const [cx, cy] = applyToPoint22(transform, [
|
|
1965
2202
|
rectCutout.center.x,
|
|
1966
2203
|
rectCutout.center.y
|
|
1967
2204
|
]);
|
|
@@ -1992,7 +2229,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
1992
2229
|
}
|
|
1993
2230
|
if (cutout.shape === "circle") {
|
|
1994
2231
|
const circleCutout = cutout;
|
|
1995
|
-
const [cx, cy] =
|
|
2232
|
+
const [cx, cy] = applyToPoint22(transform, [
|
|
1996
2233
|
circleCutout.center.x,
|
|
1997
2234
|
circleCutout.center.y
|
|
1998
2235
|
]);
|
|
@@ -2019,7 +2256,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2019
2256
|
const polygonCutout = cutout;
|
|
2020
2257
|
if (!polygonCutout.points || polygonCutout.points.length === 0) return [];
|
|
2021
2258
|
const transformedPoints = polygonCutout.points.map(
|
|
2022
|
-
(p) =>
|
|
2259
|
+
(p) => applyToPoint22(transform, [p.x, p.y])
|
|
2023
2260
|
);
|
|
2024
2261
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
2025
2262
|
return [
|
|
@@ -2043,7 +2280,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2043
2280
|
|
|
2044
2281
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-copper-pour.ts
|
|
2045
2282
|
import {
|
|
2046
|
-
applyToPoint as
|
|
2283
|
+
applyToPoint as applyToPoint24,
|
|
2047
2284
|
compose as compose4,
|
|
2048
2285
|
rotate as rotate4,
|
|
2049
2286
|
toString as matrixToString7,
|
|
@@ -2051,11 +2288,11 @@ import {
|
|
|
2051
2288
|
} from "transformation-matrix";
|
|
2052
2289
|
|
|
2053
2290
|
// lib/utils/ring-to-path-d.ts
|
|
2054
|
-
import { applyToPoint as
|
|
2291
|
+
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
2055
2292
|
function ringToPathD(vertices, transform) {
|
|
2056
2293
|
if (vertices.length === 0) return "";
|
|
2057
2294
|
const transformedVertices = vertices.map((v) => {
|
|
2058
|
-
const [x, y] =
|
|
2295
|
+
const [x, y] = applyToPoint23(transform, [v.x, v.y]);
|
|
2059
2296
|
return { ...v, x, y };
|
|
2060
2297
|
});
|
|
2061
2298
|
let d = `M ${transformedVertices[0].x} ${transformedVertices[0].y}`;
|
|
@@ -2088,7 +2325,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
2088
2325
|
const color = layerNameToColor(layer, colorMap2);
|
|
2089
2326
|
const opacity = "0.5";
|
|
2090
2327
|
if (pour.shape === "rect") {
|
|
2091
|
-
const [cx, cy] =
|
|
2328
|
+
const [cx, cy] = applyToPoint24(transform, [pour.center.x, pour.center.y]);
|
|
2092
2329
|
const scaledWidth = pour.width * Math.abs(transform.a);
|
|
2093
2330
|
const scaledHeight = pour.height * Math.abs(transform.d);
|
|
2094
2331
|
const svgRotation = -(pour.rotation ?? 0);
|
|
@@ -2118,7 +2355,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
2118
2355
|
if (pour.shape === "polygon") {
|
|
2119
2356
|
if (!pour.points || pour.points.length === 0) return [];
|
|
2120
2357
|
const transformedPoints = pour.points.map(
|
|
2121
|
-
(p) =>
|
|
2358
|
+
(p) => applyToPoint24(transform, [p.x, p.y])
|
|
2122
2359
|
);
|
|
2123
2360
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
2124
2361
|
return [
|
|
@@ -2303,11 +2540,11 @@ function createMajorGridPatternChildren(cellSize, majorCellSize, lineColor, majo
|
|
|
2303
2540
|
}
|
|
2304
2541
|
|
|
2305
2542
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-component.ts
|
|
2306
|
-
import { applyToPoint as
|
|
2543
|
+
import { applyToPoint as applyToPoint25 } from "transformation-matrix";
|
|
2307
2544
|
function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
2308
2545
|
const { transform } = ctx;
|
|
2309
2546
|
const { center, width, height, rotation = 0 } = component;
|
|
2310
|
-
const [x, y] =
|
|
2547
|
+
const [x, y] = applyToPoint25(transform, [center.x, center.y]);
|
|
2311
2548
|
const scaledWidth = width * Math.abs(transform.a);
|
|
2312
2549
|
const scaledHeight = height * Math.abs(transform.d);
|
|
2313
2550
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
@@ -2357,7 +2594,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
2357
2594
|
var package_default = {
|
|
2358
2595
|
name: "circuit-to-svg",
|
|
2359
2596
|
type: "module",
|
|
2360
|
-
version: "0.0.
|
|
2597
|
+
version: "0.0.231",
|
|
2361
2598
|
description: "Convert Circuit JSON to SVG",
|
|
2362
2599
|
main: "dist/index.js",
|
|
2363
2600
|
files: [
|
|
@@ -2427,6 +2664,10 @@ var TYPE_PRIORITY = {
|
|
|
2427
2664
|
pcb_fabrication_note_text: 70,
|
|
2428
2665
|
pcb_fabrication_note_path: 70,
|
|
2429
2666
|
pcb_note_dimension: 70,
|
|
2667
|
+
pcb_note_text: 70,
|
|
2668
|
+
pcb_note_rect: 70,
|
|
2669
|
+
pcb_note_path: 70,
|
|
2670
|
+
pcb_note_line: 70,
|
|
2430
2671
|
pcb_trace_error: 80,
|
|
2431
2672
|
pcb_rats_nest: 85
|
|
2432
2673
|
};
|
|
@@ -2803,6 +3044,14 @@ function createSvgObjects({
|
|
|
2803
3044
|
return createSvgObjectsFromPcbFabricationNoteText(elm, ctx);
|
|
2804
3045
|
case "pcb_note_dimension":
|
|
2805
3046
|
return createSvgObjectsFromPcbNoteDimension(elm, ctx);
|
|
3047
|
+
case "pcb_note_text":
|
|
3048
|
+
return createSvgObjectsFromPcbNoteText(elm, ctx);
|
|
3049
|
+
case "pcb_note_rect":
|
|
3050
|
+
return createSvgObjectsFromPcbNoteRect(elm, ctx);
|
|
3051
|
+
case "pcb_note_path":
|
|
3052
|
+
return createSvgObjectsFromPcbNotePath(elm, ctx);
|
|
3053
|
+
case "pcb_note_line":
|
|
3054
|
+
return createSvgObjectsFromPcbNoteLine(elm, ctx);
|
|
2806
3055
|
case "pcb_silkscreen_path":
|
|
2807
3056
|
return createSvgObjectsFromPcbSilkscreenPath(elm, ctx);
|
|
2808
3057
|
case "pcb_board":
|
|
@@ -2816,8 +3065,8 @@ function createSvgObjects({
|
|
|
2816
3065
|
}
|
|
2817
3066
|
}
|
|
2818
3067
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
2819
|
-
const [x1, y1] =
|
|
2820
|
-
const [x2, y2] =
|
|
3068
|
+
const [x1, y1] = applyToPoint26(transform, [minX, minY]);
|
|
3069
|
+
const [x2, y2] = applyToPoint26(transform, [maxX, maxY]);
|
|
2821
3070
|
const width = Math.abs(x2 - x1);
|
|
2822
3071
|
const height = Math.abs(y2 - y1);
|
|
2823
3072
|
const x = Math.min(x1, x2);
|
|
@@ -2847,14 +3096,14 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
2847
3096
|
import { stringify as stringify2 } from "svgson";
|
|
2848
3097
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
2849
3098
|
import {
|
|
2850
|
-
applyToPoint as
|
|
3099
|
+
applyToPoint as applyToPoint33,
|
|
2851
3100
|
compose as compose6,
|
|
2852
3101
|
scale as scale3,
|
|
2853
3102
|
translate as translate6
|
|
2854
3103
|
} from "transformation-matrix";
|
|
2855
3104
|
|
|
2856
3105
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
2857
|
-
import { applyToPoint as
|
|
3106
|
+
import { applyToPoint as applyToPoint27 } from "transformation-matrix";
|
|
2858
3107
|
var DEFAULT_BOARD_STYLE = {
|
|
2859
3108
|
fill: "none",
|
|
2860
3109
|
stroke: "rgb(0,0,0)",
|
|
@@ -2866,25 +3115,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
2866
3115
|
let path;
|
|
2867
3116
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
2868
3117
|
path = outline.map((point, index) => {
|
|
2869
|
-
const [x, y] =
|
|
3118
|
+
const [x, y] = applyToPoint27(transform, [point.x, point.y]);
|
|
2870
3119
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
2871
3120
|
}).join(" ");
|
|
2872
3121
|
} else {
|
|
2873
3122
|
const halfWidth = width / 2;
|
|
2874
3123
|
const halfHeight = height / 2;
|
|
2875
|
-
const topLeft =
|
|
3124
|
+
const topLeft = applyToPoint27(transform, [
|
|
2876
3125
|
center.x - halfWidth,
|
|
2877
3126
|
center.y - halfHeight
|
|
2878
3127
|
]);
|
|
2879
|
-
const topRight =
|
|
3128
|
+
const topRight = applyToPoint27(transform, [
|
|
2880
3129
|
center.x + halfWidth,
|
|
2881
3130
|
center.y - halfHeight
|
|
2882
3131
|
]);
|
|
2883
|
-
const bottomRight =
|
|
3132
|
+
const bottomRight = applyToPoint27(transform, [
|
|
2884
3133
|
center.x + halfWidth,
|
|
2885
3134
|
center.y + halfHeight
|
|
2886
3135
|
]);
|
|
2887
|
-
const bottomLeft =
|
|
3136
|
+
const bottomLeft = applyToPoint27(transform, [
|
|
2888
3137
|
center.x - halfWidth,
|
|
2889
3138
|
center.y + halfHeight
|
|
2890
3139
|
]);
|
|
@@ -2910,7 +3159,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
2910
3159
|
}
|
|
2911
3160
|
|
|
2912
3161
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
2913
|
-
import { applyToPoint as
|
|
3162
|
+
import { applyToPoint as applyToPoint29 } from "transformation-matrix";
|
|
2914
3163
|
|
|
2915
3164
|
// lib/utils/get-sch-font-size.ts
|
|
2916
3165
|
import "transformation-matrix";
|
|
@@ -2936,8 +3185,8 @@ function createSvgObjectsFromAssemblyComponent(params, ctx) {
|
|
|
2936
3185
|
const { center, width, height, rotation = 0, layer = "top" } = elm;
|
|
2937
3186
|
if (!center || typeof width !== "number" || typeof height !== "number")
|
|
2938
3187
|
return null;
|
|
2939
|
-
const [x, y] =
|
|
2940
|
-
const [pinX, pinY] =
|
|
3188
|
+
const [x, y] = applyToPoint29(transform, [center.x, center.y]);
|
|
3189
|
+
const [pinX, pinY] = applyToPoint29(transform, [portPosition.x, portPosition.y]);
|
|
2941
3190
|
const scaledWidth = width * Math.abs(transform.a);
|
|
2942
3191
|
const scaledHeight = height * Math.abs(transform.d);
|
|
2943
3192
|
const isTopLayer = layer === "top";
|
|
@@ -3099,11 +3348,11 @@ function getRectPathData(w, h, rotation) {
|
|
|
3099
3348
|
}
|
|
3100
3349
|
|
|
3101
3350
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-hole.ts
|
|
3102
|
-
import { applyToPoint as
|
|
3351
|
+
import { applyToPoint as applyToPoint30 } from "transformation-matrix";
|
|
3103
3352
|
var HOLE_COLOR2 = "rgb(190, 190, 190)";
|
|
3104
3353
|
function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
3105
3354
|
const { transform } = ctx;
|
|
3106
|
-
const [x, y] =
|
|
3355
|
+
const [x, y] = applyToPoint30(transform, [hole.x, hole.y]);
|
|
3107
3356
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
3108
3357
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
3109
3358
|
const radius = scaledDiameter / 2;
|
|
@@ -3167,12 +3416,12 @@ function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
|
3167
3416
|
}
|
|
3168
3417
|
|
|
3169
3418
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-plated-hole.ts
|
|
3170
|
-
import { applyToPoint as
|
|
3419
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
3171
3420
|
var PAD_COLOR = "rgb(210, 210, 210)";
|
|
3172
3421
|
var HOLE_COLOR3 = "rgb(190, 190, 190)";
|
|
3173
3422
|
function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
3174
3423
|
const { transform } = ctx;
|
|
3175
|
-
const [x, y] =
|
|
3424
|
+
const [x, y] = applyToPoint31(transform, [hole.x, hole.y]);
|
|
3176
3425
|
if (hole.shape === "pill") {
|
|
3177
3426
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
3178
3427
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -3267,7 +3516,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3267
3516
|
const scaledRectPadHeight = circularHole.rect_pad_height * Math.abs(transform.a);
|
|
3268
3517
|
const scaledRectBorderRadius = (circularHole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
3269
3518
|
const holeRadius = scaledHoleDiameter / 2;
|
|
3270
|
-
const [holeCx, holeCy] =
|
|
3519
|
+
const [holeCx, holeCy] = applyToPoint31(transform, [
|
|
3271
3520
|
circularHole.x + circularHole.hole_offset_x,
|
|
3272
3521
|
circularHole.y + circularHole.hole_offset_y
|
|
3273
3522
|
]);
|
|
@@ -3325,7 +3574,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3325
3574
|
const pillHoleWithOffsets = pillHole;
|
|
3326
3575
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
3327
3576
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
3328
|
-
const [holeCenterX, holeCenterY] =
|
|
3577
|
+
const [holeCenterX, holeCenterY] = applyToPoint31(transform, [
|
|
3329
3578
|
pillHole.x + holeOffsetX,
|
|
3330
3579
|
pillHole.y + holeOffsetY
|
|
3331
3580
|
]);
|
|
@@ -3387,7 +3636,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3387
3636
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
3388
3637
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
3389
3638
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
3390
|
-
const [holeCenterX, holeCenterY] =
|
|
3639
|
+
const [holeCenterX, holeCenterY] = applyToPoint31(transform, [
|
|
3391
3640
|
rotatedHole.x + holeOffsetX,
|
|
3392
3641
|
rotatedHole.y + holeOffsetY
|
|
3393
3642
|
]);
|
|
@@ -3443,14 +3692,14 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3443
3692
|
}
|
|
3444
3693
|
|
|
3445
3694
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-smt-pad.ts
|
|
3446
|
-
import { applyToPoint as
|
|
3695
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
3447
3696
|
var PAD_COLOR2 = "rgb(210, 210, 210)";
|
|
3448
3697
|
function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
3449
3698
|
const { transform } = ctx;
|
|
3450
3699
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
3451
3700
|
const width = pad.width * Math.abs(transform.a);
|
|
3452
3701
|
const height = pad.height * Math.abs(transform.d);
|
|
3453
|
-
const [x, y] =
|
|
3702
|
+
const [x, y] = applyToPoint32(transform, [pad.x, pad.y]);
|
|
3454
3703
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
3455
3704
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
3456
3705
|
return [
|
|
@@ -3502,7 +3751,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3502
3751
|
const width = pad.width * Math.abs(transform.a);
|
|
3503
3752
|
const height = pad.height * Math.abs(transform.d);
|
|
3504
3753
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3505
|
-
const [x, y] =
|
|
3754
|
+
const [x, y] = applyToPoint32(transform, [pad.x, pad.y]);
|
|
3506
3755
|
return [
|
|
3507
3756
|
{
|
|
3508
3757
|
name: "rect",
|
|
@@ -3525,7 +3774,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3525
3774
|
}
|
|
3526
3775
|
if (pad.shape === "circle") {
|
|
3527
3776
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3528
|
-
const [x, y] =
|
|
3777
|
+
const [x, y] = applyToPoint32(transform, [pad.x, pad.y]);
|
|
3529
3778
|
return [
|
|
3530
3779
|
{
|
|
3531
3780
|
name: "circle",
|
|
@@ -3545,7 +3794,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3545
3794
|
}
|
|
3546
3795
|
if (pad.shape === "polygon") {
|
|
3547
3796
|
const points = (pad.points ?? []).map(
|
|
3548
|
-
(point) =>
|
|
3797
|
+
(point) => applyToPoint32(transform, [point.x, point.y])
|
|
3549
3798
|
);
|
|
3550
3799
|
return [
|
|
3551
3800
|
{
|
|
@@ -3722,8 +3971,8 @@ function createSvgObjects2(elm, ctx, soup) {
|
|
|
3722
3971
|
}
|
|
3723
3972
|
}
|
|
3724
3973
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
3725
|
-
const [x1, y1] =
|
|
3726
|
-
const [x2, y2] =
|
|
3974
|
+
const [x1, y1] = applyToPoint33(transform, [minX, minY]);
|
|
3975
|
+
const [x2, y2] = applyToPoint33(transform, [maxX, maxY]);
|
|
3727
3976
|
const width = Math.abs(x2 - x1);
|
|
3728
3977
|
const height = Math.abs(y2 - y1);
|
|
3729
3978
|
const x = Math.min(x1, x2);
|
|
@@ -3752,7 +4001,7 @@ import {
|
|
|
3752
4001
|
} from "transformation-matrix";
|
|
3753
4002
|
|
|
3754
4003
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-board.ts
|
|
3755
|
-
import { applyToPoint as
|
|
4004
|
+
import { applyToPoint as applyToPoint34 } from "transformation-matrix";
|
|
3756
4005
|
import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
3757
4006
|
var BOARD_FILL_COLOR = "rgb(26, 115, 143)";
|
|
3758
4007
|
var BOARD_STROKE_COLOR = "rgba(0,0,0,0.9)";
|
|
@@ -3762,25 +4011,25 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
3762
4011
|
let path;
|
|
3763
4012
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
3764
4013
|
path = outline.map((point, index) => {
|
|
3765
|
-
const [x, y] =
|
|
4014
|
+
const [x, y] = applyToPoint34(transform, [point.x, point.y]);
|
|
3766
4015
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
3767
4016
|
}).join(" ");
|
|
3768
4017
|
} else {
|
|
3769
4018
|
const halfWidth = width / 2;
|
|
3770
4019
|
const halfHeight = height / 2;
|
|
3771
|
-
const topLeft =
|
|
4020
|
+
const topLeft = applyToPoint34(transform, [
|
|
3772
4021
|
center.x - halfWidth,
|
|
3773
4022
|
center.y - halfHeight
|
|
3774
4023
|
]);
|
|
3775
|
-
const topRight =
|
|
4024
|
+
const topRight = applyToPoint34(transform, [
|
|
3776
4025
|
center.x + halfWidth,
|
|
3777
4026
|
center.y - halfHeight
|
|
3778
4027
|
]);
|
|
3779
|
-
const bottomRight =
|
|
4028
|
+
const bottomRight = applyToPoint34(transform, [
|
|
3780
4029
|
center.x + halfWidth,
|
|
3781
4030
|
center.y + halfHeight
|
|
3782
4031
|
]);
|
|
3783
|
-
const bottomLeft =
|
|
4032
|
+
const bottomLeft = applyToPoint34(transform, [
|
|
3784
4033
|
center.x - halfWidth,
|
|
3785
4034
|
center.y + halfHeight
|
|
3786
4035
|
]);
|
|
@@ -3798,10 +4047,10 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
3798
4047
|
const halfWidth = width2 / 2;
|
|
3799
4048
|
const halfHeight = height2 / 2;
|
|
3800
4049
|
const [tl, tr, br, bl] = [
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
4050
|
+
applyToPoint34(transform, [x - halfWidth, y - halfHeight]),
|
|
4051
|
+
applyToPoint34(transform, [x + halfWidth, y - halfHeight]),
|
|
4052
|
+
applyToPoint34(transform, [x + halfWidth, y + halfHeight]),
|
|
4053
|
+
applyToPoint34(transform, [x - halfWidth, y + halfHeight])
|
|
3805
4054
|
];
|
|
3806
4055
|
path += ` M ${tl[0]} ${tl[1]} L ${tr[0]} ${tr[1]} L ${br[0]} ${br[1]} L ${bl[0]} ${bl[1]} Z`;
|
|
3807
4056
|
} else if (cutout.shape === "circle") {
|
|
@@ -3828,7 +4077,7 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
3828
4077
|
|
|
3829
4078
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-component.ts
|
|
3830
4079
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
3831
|
-
import { applyToPoint as
|
|
4080
|
+
import { applyToPoint as applyToPoint35 } from "transformation-matrix";
|
|
3832
4081
|
var COMPONENT_FILL_COLOR = "rgba(120, 120, 120, 0.6)";
|
|
3833
4082
|
var COMPONENT_LABEL_COLOR = "rgba(255, 255, 255, 0.9)";
|
|
3834
4083
|
function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
@@ -3838,7 +4087,7 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
3838
4087
|
if (!center || typeof width !== "number" || typeof height !== "number" || width === 0 || height === 0) {
|
|
3839
4088
|
return [];
|
|
3840
4089
|
}
|
|
3841
|
-
const [x, y] =
|
|
4090
|
+
const [x, y] = applyToPoint35(transform, [center.x, center.y]);
|
|
3842
4091
|
const scaledWidth = width * Math.abs(transform.a);
|
|
3843
4092
|
const scaledHeight = height * Math.abs(transform.d);
|
|
3844
4093
|
const transformStr = `translate(${x}, ${y})`;
|
|
@@ -3899,11 +4148,11 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
3899
4148
|
}
|
|
3900
4149
|
|
|
3901
4150
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-hole.ts
|
|
3902
|
-
import { applyToPoint as
|
|
4151
|
+
import { applyToPoint as applyToPoint36 } from "transformation-matrix";
|
|
3903
4152
|
var HOLE_COLOR4 = "rgb(50, 50, 50)";
|
|
3904
4153
|
function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
3905
4154
|
const { transform } = ctx;
|
|
3906
|
-
const [x, y] =
|
|
4155
|
+
const [x, y] = applyToPoint36(transform, [hole.x, hole.y]);
|
|
3907
4156
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
3908
4157
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
3909
4158
|
const radius = scaledDiameter / 2;
|
|
@@ -3967,12 +4216,12 @@ function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
|
3967
4216
|
}
|
|
3968
4217
|
|
|
3969
4218
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-plated-hole.ts
|
|
3970
|
-
import { applyToPoint as
|
|
4219
|
+
import { applyToPoint as applyToPoint37 } from "transformation-matrix";
|
|
3971
4220
|
var PAD_COLOR3 = "rgb(218, 165, 32)";
|
|
3972
4221
|
var HOLE_COLOR5 = "rgb(40, 40, 40)";
|
|
3973
4222
|
function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
3974
4223
|
const { transform } = ctx;
|
|
3975
|
-
const [x, y] =
|
|
4224
|
+
const [x, y] = applyToPoint37(transform, [hole.x, hole.y]);
|
|
3976
4225
|
if (hole.shape === "pill") {
|
|
3977
4226
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
3978
4227
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -4207,14 +4456,14 @@ function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
|
4207
4456
|
}
|
|
4208
4457
|
|
|
4209
4458
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-smt-pad.ts
|
|
4210
|
-
import { applyToPoint as
|
|
4459
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
4211
4460
|
var PAD_COLOR4 = "rgb(218, 165, 32)";
|
|
4212
4461
|
function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
4213
4462
|
const { transform } = ctx;
|
|
4214
4463
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
4215
4464
|
const width = pad.width * Math.abs(transform.a);
|
|
4216
4465
|
const height = pad.height * Math.abs(transform.d);
|
|
4217
|
-
const [x, y] =
|
|
4466
|
+
const [x, y] = applyToPoint38(transform, [pad.x, pad.y]);
|
|
4218
4467
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
4219
4468
|
return [
|
|
4220
4469
|
{
|
|
@@ -4257,7 +4506,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4257
4506
|
const width = pad.width * Math.abs(transform.a);
|
|
4258
4507
|
const height = pad.height * Math.abs(transform.d);
|
|
4259
4508
|
const radius = pad.radius * Math.abs(transform.a);
|
|
4260
|
-
const [x, y] =
|
|
4509
|
+
const [x, y] = applyToPoint38(transform, [pad.x, pad.y]);
|
|
4261
4510
|
return [
|
|
4262
4511
|
{
|
|
4263
4512
|
name: "rect",
|
|
@@ -4280,7 +4529,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4280
4529
|
}
|
|
4281
4530
|
if (pad.shape === "circle") {
|
|
4282
4531
|
const radius = pad.radius * Math.abs(transform.a);
|
|
4283
|
-
const [x, y] =
|
|
4532
|
+
const [x, y] = applyToPoint38(transform, [pad.x, pad.y]);
|
|
4284
4533
|
return [
|
|
4285
4534
|
{
|
|
4286
4535
|
name: "circle",
|
|
@@ -4300,7 +4549,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4300
4549
|
}
|
|
4301
4550
|
if (pad.shape === "polygon") {
|
|
4302
4551
|
const points = (pad.points ?? []).map(
|
|
4303
|
-
(point) =>
|
|
4552
|
+
(point) => applyToPoint38(transform, [point.x, point.y])
|
|
4304
4553
|
);
|
|
4305
4554
|
return [
|
|
4306
4555
|
{
|
|
@@ -4321,7 +4570,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4321
4570
|
}
|
|
4322
4571
|
|
|
4323
4572
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-port.ts
|
|
4324
|
-
import { applyToPoint as
|
|
4573
|
+
import { applyToPoint as applyToPoint39 } from "transformation-matrix";
|
|
4325
4574
|
import { calculateElbow } from "calculate-elbow";
|
|
4326
4575
|
|
|
4327
4576
|
// lib/pinout/svg-object-fns/pinout-label-box.ts
|
|
@@ -4398,7 +4647,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
4398
4647
|
const label_info = ctx.label_positions.get(pcb_port.pcb_port_id);
|
|
4399
4648
|
if (!label_info) return [];
|
|
4400
4649
|
const { text: label, aliases, elbow_end, label_pos, edge } = label_info;
|
|
4401
|
-
const [port_x, port_y] =
|
|
4650
|
+
const [port_x, port_y] = applyToPoint39(ctx.transform, [pcb_port.x, pcb_port.y]);
|
|
4402
4651
|
const start_facing_direction = edge === "left" ? "x-" : edge === "right" ? "x+" : edge === "top" ? "y-" : "y+";
|
|
4403
4652
|
const end_facing_direction = edge === "left" ? "x+" : edge === "right" ? "x-" : edge === "top" ? "y+" : "y-";
|
|
4404
4653
|
const elbow_path = calculateElbow(
|
|
@@ -4539,7 +4788,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
4539
4788
|
}
|
|
4540
4789
|
|
|
4541
4790
|
// lib/pinout/calculate-label-positions.ts
|
|
4542
|
-
import { applyToPoint as
|
|
4791
|
+
import { applyToPoint as applyToPoint40 } from "transformation-matrix";
|
|
4543
4792
|
|
|
4544
4793
|
// lib/pinout/constants.ts
|
|
4545
4794
|
var LABEL_RECT_HEIGHT_BASE_MM = 1.6;
|
|
@@ -4577,7 +4826,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4577
4826
|
);
|
|
4578
4827
|
const mapToEdgePort = (pinout_label) => ({
|
|
4579
4828
|
pcb_port: pinout_label.pcb_port,
|
|
4580
|
-
y:
|
|
4829
|
+
y: applyToPoint40(transform, [
|
|
4581
4830
|
pinout_label.pcb_port.x,
|
|
4582
4831
|
pinout_label.pcb_port.y
|
|
4583
4832
|
])[1],
|
|
@@ -4592,7 +4841,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4592
4841
|
} else {
|
|
4593
4842
|
edge_ports = pinout_labels.map((pinout_label) => ({
|
|
4594
4843
|
pcb_port: pinout_label.pcb_port,
|
|
4595
|
-
y:
|
|
4844
|
+
y: applyToPoint40(transform, [
|
|
4596
4845
|
pinout_label.pcb_port.x,
|
|
4597
4846
|
pinout_label.pcb_port.y
|
|
4598
4847
|
])[1],
|
|
@@ -4600,7 +4849,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4600
4849
|
})).sort((a, b) => a.y - b.y);
|
|
4601
4850
|
}
|
|
4602
4851
|
if (edge_ports.length === 0) return;
|
|
4603
|
-
const board_edge_x =
|
|
4852
|
+
const board_edge_x = applyToPoint40(transform, [
|
|
4604
4853
|
edge === "left" ? board_bounds.minX : board_bounds.maxX,
|
|
4605
4854
|
0
|
|
4606
4855
|
])[0];
|
|
@@ -5249,14 +5498,14 @@ import {
|
|
|
5249
5498
|
} from "transformation-matrix";
|
|
5250
5499
|
|
|
5251
5500
|
// lib/sch/draw-schematic-grid.ts
|
|
5252
|
-
import { applyToPoint as
|
|
5501
|
+
import { applyToPoint as applyToPoint41 } from "transformation-matrix";
|
|
5253
5502
|
function drawSchematicGrid(params) {
|
|
5254
5503
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
5255
5504
|
const cellSize = params.cellSize ?? 1;
|
|
5256
5505
|
const labelCells = params.labelCells ?? false;
|
|
5257
5506
|
const gridLines = [];
|
|
5258
5507
|
const transformPoint = (x, y) => {
|
|
5259
|
-
const [transformedX, transformedY] =
|
|
5508
|
+
const [transformedX, transformedY] = applyToPoint41(params.transform, [x, y]);
|
|
5260
5509
|
return { x: transformedX, y: transformedY };
|
|
5261
5510
|
};
|
|
5262
5511
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -5337,15 +5586,15 @@ function drawSchematicGrid(params) {
|
|
|
5337
5586
|
}
|
|
5338
5587
|
|
|
5339
5588
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
5340
|
-
import { applyToPoint as
|
|
5589
|
+
import { applyToPoint as applyToPoint42 } from "transformation-matrix";
|
|
5341
5590
|
function drawSchematicLabeledPoints(params) {
|
|
5342
5591
|
const { points, transform } = params;
|
|
5343
5592
|
const labeledPointsGroup = [];
|
|
5344
5593
|
for (const point of points) {
|
|
5345
|
-
const [x1, y1] =
|
|
5346
|
-
const [x2, y2] =
|
|
5347
|
-
const [x3, y3] =
|
|
5348
|
-
const [x4, y4] =
|
|
5594
|
+
const [x1, y1] = applyToPoint42(transform, [point.x - 0.1, point.y - 0.1]);
|
|
5595
|
+
const [x2, y2] = applyToPoint42(transform, [point.x + 0.1, point.y + 0.1]);
|
|
5596
|
+
const [x3, y3] = applyToPoint42(transform, [point.x - 0.1, point.y + 0.1]);
|
|
5597
|
+
const [x4, y4] = applyToPoint42(transform, [point.x + 0.1, point.y - 0.1]);
|
|
5349
5598
|
labeledPointsGroup.push({
|
|
5350
5599
|
name: "path",
|
|
5351
5600
|
type: "element",
|
|
@@ -5356,7 +5605,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
5356
5605
|
"stroke-opacity": "0.7"
|
|
5357
5606
|
}
|
|
5358
5607
|
});
|
|
5359
|
-
const [labelX, labelY] =
|
|
5608
|
+
const [labelX, labelY] = applyToPoint42(transform, [
|
|
5360
5609
|
point.x + 0.15,
|
|
5361
5610
|
point.y - 0.15
|
|
5362
5611
|
]);
|
|
@@ -6450,7 +6699,7 @@ import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
|
6450
6699
|
import { symbols } from "schematic-symbols";
|
|
6451
6700
|
import "svgson";
|
|
6452
6701
|
import {
|
|
6453
|
-
applyToPoint as
|
|
6702
|
+
applyToPoint as applyToPoint44,
|
|
6454
6703
|
compose as compose9
|
|
6455
6704
|
} from "transformation-matrix";
|
|
6456
6705
|
|
|
@@ -6534,13 +6783,13 @@ function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
|
6534
6783
|
}
|
|
6535
6784
|
|
|
6536
6785
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
6537
|
-
import { applyToPoint as
|
|
6786
|
+
import { applyToPoint as applyToPoint43 } from "transformation-matrix";
|
|
6538
6787
|
var createSvgSchErrorText = ({
|
|
6539
6788
|
text,
|
|
6540
6789
|
realCenter,
|
|
6541
6790
|
realToScreenTransform
|
|
6542
6791
|
}) => {
|
|
6543
|
-
const screenCenter =
|
|
6792
|
+
const screenCenter = applyToPoint43(realToScreenTransform, realCenter);
|
|
6544
6793
|
return {
|
|
6545
6794
|
type: "element",
|
|
6546
6795
|
name: "text",
|
|
@@ -6649,11 +6898,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6649
6898
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
6650
6899
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
6651
6900
|
};
|
|
6652
|
-
const [screenMinX, screenMinY] =
|
|
6901
|
+
const [screenMinX, screenMinY] = applyToPoint44(
|
|
6653
6902
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6654
6903
|
[bounds.minX, bounds.minY]
|
|
6655
6904
|
);
|
|
6656
|
-
const [screenMaxX, screenMaxY] =
|
|
6905
|
+
const [screenMaxX, screenMaxY] = applyToPoint44(
|
|
6657
6906
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6658
6907
|
[bounds.maxX, bounds.maxY]
|
|
6659
6908
|
);
|
|
@@ -6682,7 +6931,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6682
6931
|
name: "path",
|
|
6683
6932
|
attributes: {
|
|
6684
6933
|
d: points.map((p, i) => {
|
|
6685
|
-
const [x, y] =
|
|
6934
|
+
const [x, y] = applyToPoint44(
|
|
6686
6935
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6687
6936
|
[p.x, p.y]
|
|
6688
6937
|
);
|
|
@@ -6698,7 +6947,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6698
6947
|
});
|
|
6699
6948
|
}
|
|
6700
6949
|
for (const text of texts) {
|
|
6701
|
-
const screenTextPos =
|
|
6950
|
+
const screenTextPos = applyToPoint44(
|
|
6702
6951
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6703
6952
|
text
|
|
6704
6953
|
);
|
|
@@ -6750,7 +6999,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6750
6999
|
});
|
|
6751
7000
|
}
|
|
6752
7001
|
for (const box of boxes) {
|
|
6753
|
-
const screenBoxPos =
|
|
7002
|
+
const screenBoxPos = applyToPoint44(
|
|
6754
7003
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6755
7004
|
box
|
|
6756
7005
|
);
|
|
@@ -6774,7 +7023,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6774
7023
|
}
|
|
6775
7024
|
for (const port of symbol.ports) {
|
|
6776
7025
|
if (connectedSymbolPorts.has(port)) continue;
|
|
6777
|
-
const screenPortPos =
|
|
7026
|
+
const screenPortPos = applyToPoint44(
|
|
6778
7027
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6779
7028
|
port
|
|
6780
7029
|
);
|
|
@@ -6794,7 +7043,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6794
7043
|
});
|
|
6795
7044
|
}
|
|
6796
7045
|
for (const circle of circles) {
|
|
6797
|
-
const screenCirclePos =
|
|
7046
|
+
const screenCirclePos = applyToPoint44(
|
|
6798
7047
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6799
7048
|
circle
|
|
6800
7049
|
);
|
|
@@ -6821,14 +7070,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6821
7070
|
import { su as su10 } from "@tscircuit/circuit-json-util";
|
|
6822
7071
|
import "schematic-symbols";
|
|
6823
7072
|
import "svgson";
|
|
6824
|
-
import { applyToPoint as
|
|
7073
|
+
import { applyToPoint as applyToPoint50 } from "transformation-matrix";
|
|
6825
7074
|
|
|
6826
7075
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
6827
7076
|
import "transformation-matrix";
|
|
6828
7077
|
import "@tscircuit/circuit-json-util";
|
|
6829
7078
|
|
|
6830
7079
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
6831
|
-
import { applyToPoint as
|
|
7080
|
+
import { applyToPoint as applyToPoint45 } from "transformation-matrix";
|
|
6832
7081
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
6833
7082
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
6834
7083
|
var createArrow = (tip, angle, size, color, strokeWidth) => {
|
|
@@ -6881,8 +7130,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
6881
7130
|
realEdgePos.y += realPinLineLength;
|
|
6882
7131
|
break;
|
|
6883
7132
|
}
|
|
6884
|
-
const screenSchPortPos =
|
|
6885
|
-
const screenRealEdgePos =
|
|
7133
|
+
const screenSchPortPos = applyToPoint45(transform, schPort.center);
|
|
7134
|
+
const screenRealEdgePos = applyToPoint45(transform, realEdgePos);
|
|
6886
7135
|
const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
|
|
6887
7136
|
const realLineEnd = { ...schPort.center };
|
|
6888
7137
|
if (!isConnected) {
|
|
@@ -6901,7 +7150,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
6901
7150
|
break;
|
|
6902
7151
|
}
|
|
6903
7152
|
}
|
|
6904
|
-
const screenLineEnd =
|
|
7153
|
+
const screenLineEnd = applyToPoint45(transform, realLineEnd);
|
|
6905
7154
|
svgObjects.push({
|
|
6906
7155
|
name: "line",
|
|
6907
7156
|
type: "element",
|
|
@@ -7022,7 +7271,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7022
7271
|
};
|
|
7023
7272
|
|
|
7024
7273
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
7025
|
-
import { applyToPoint as
|
|
7274
|
+
import { applyToPoint as applyToPoint46 } from "transformation-matrix";
|
|
7026
7275
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
7027
7276
|
const svgObjects = [];
|
|
7028
7277
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -7040,7 +7289,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
7040
7289
|
} else {
|
|
7041
7290
|
realPinNumberPos.y += 0.02;
|
|
7042
7291
|
}
|
|
7043
|
-
const screenPinNumberTextPos =
|
|
7292
|
+
const screenPinNumberTextPos = applyToPoint46(transform, realPinNumberPos);
|
|
7044
7293
|
svgObjects.push({
|
|
7045
7294
|
name: "text",
|
|
7046
7295
|
type: "element",
|
|
@@ -7070,7 +7319,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
7070
7319
|
};
|
|
7071
7320
|
|
|
7072
7321
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
7073
|
-
import { applyToPoint as
|
|
7322
|
+
import { applyToPoint as applyToPoint47 } from "transformation-matrix";
|
|
7074
7323
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
7075
7324
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
7076
7325
|
const svgObjects = [];
|
|
@@ -7084,7 +7333,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
7084
7333
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
7085
7334
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
7086
7335
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
7087
|
-
const screenPinNumberTextPos =
|
|
7336
|
+
const screenPinNumberTextPos = applyToPoint47(transform, realPinNumberPos);
|
|
7088
7337
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
7089
7338
|
if (!label) return [];
|
|
7090
7339
|
const isNegated = label.startsWith("N_");
|
|
@@ -7132,13 +7381,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
7132
7381
|
};
|
|
7133
7382
|
|
|
7134
7383
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
7135
|
-
import { applyToPoint as
|
|
7384
|
+
import { applyToPoint as applyToPoint49 } from "transformation-matrix";
|
|
7136
7385
|
var createSvgSchText = ({
|
|
7137
7386
|
elm,
|
|
7138
7387
|
transform,
|
|
7139
7388
|
colorMap: colorMap2
|
|
7140
7389
|
}) => {
|
|
7141
|
-
const center =
|
|
7390
|
+
const center = applyToPoint49(transform, elm.position);
|
|
7142
7391
|
const textAnchorMap = {
|
|
7143
7392
|
center: "middle",
|
|
7144
7393
|
center_right: "end",
|
|
@@ -7222,11 +7471,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
7222
7471
|
colorMap: colorMap2
|
|
7223
7472
|
}) => {
|
|
7224
7473
|
const svgObjects = [];
|
|
7225
|
-
const componentScreenTopLeft =
|
|
7474
|
+
const componentScreenTopLeft = applyToPoint50(transform, {
|
|
7226
7475
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
7227
7476
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
7228
7477
|
});
|
|
7229
|
-
const componentScreenBottomRight =
|
|
7478
|
+
const componentScreenBottomRight = applyToPoint50(transform, {
|
|
7230
7479
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
7231
7480
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
7232
7481
|
});
|
|
@@ -7312,13 +7561,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
7312
7561
|
}
|
|
7313
7562
|
|
|
7314
7563
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
7315
|
-
import { applyToPoint as
|
|
7564
|
+
import { applyToPoint as applyToPoint51 } from "transformation-matrix";
|
|
7316
7565
|
function createSvgObjectsFromSchVoltageProbe({
|
|
7317
7566
|
probe,
|
|
7318
7567
|
transform,
|
|
7319
7568
|
colorMap: colorMap2
|
|
7320
7569
|
}) {
|
|
7321
|
-
const [screenX, screenY] =
|
|
7570
|
+
const [screenX, screenY] = applyToPoint51(transform, [
|
|
7322
7571
|
probe.position.x,
|
|
7323
7572
|
probe.position.y
|
|
7324
7573
|
]);
|
|
@@ -7378,17 +7627,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
7378
7627
|
}
|
|
7379
7628
|
|
|
7380
7629
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
7381
|
-
import { applyToPoint as
|
|
7630
|
+
import { applyToPoint as applyToPoint52 } from "transformation-matrix";
|
|
7382
7631
|
function createSvgObjectsFromSchDebugObject({
|
|
7383
7632
|
debugObject,
|
|
7384
7633
|
transform
|
|
7385
7634
|
}) {
|
|
7386
7635
|
if (debugObject.shape === "rect") {
|
|
7387
|
-
let [screenLeft, screenTop] =
|
|
7636
|
+
let [screenLeft, screenTop] = applyToPoint52(transform, [
|
|
7388
7637
|
debugObject.center.x - debugObject.size.width / 2,
|
|
7389
7638
|
debugObject.center.y - debugObject.size.height / 2
|
|
7390
7639
|
]);
|
|
7391
|
-
let [screenRight, screenBottom] =
|
|
7640
|
+
let [screenRight, screenBottom] = applyToPoint52(transform, [
|
|
7392
7641
|
debugObject.center.x + debugObject.size.width / 2,
|
|
7393
7642
|
debugObject.center.y + debugObject.size.height / 2
|
|
7394
7643
|
]);
|
|
@@ -7398,7 +7647,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
7398
7647
|
];
|
|
7399
7648
|
const width = Math.abs(screenRight - screenLeft);
|
|
7400
7649
|
const height = Math.abs(screenBottom - screenTop);
|
|
7401
|
-
const [screenCenterX, screenCenterY] =
|
|
7650
|
+
const [screenCenterX, screenCenterY] = applyToPoint52(transform, [
|
|
7402
7651
|
debugObject.center.x,
|
|
7403
7652
|
debugObject.center.y
|
|
7404
7653
|
]);
|
|
@@ -7444,11 +7693,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
7444
7693
|
];
|
|
7445
7694
|
}
|
|
7446
7695
|
if (debugObject.shape === "line") {
|
|
7447
|
-
const [screenStartX, screenStartY] =
|
|
7696
|
+
const [screenStartX, screenStartY] = applyToPoint52(transform, [
|
|
7448
7697
|
debugObject.start.x,
|
|
7449
7698
|
debugObject.start.y
|
|
7450
7699
|
]);
|
|
7451
|
-
const [screenEndX, screenEndY] =
|
|
7700
|
+
const [screenEndX, screenEndY] = applyToPoint52(transform, [
|
|
7452
7701
|
debugObject.end.x,
|
|
7453
7702
|
debugObject.end.y
|
|
7454
7703
|
]);
|
|
@@ -7498,7 +7747,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
7498
7747
|
}
|
|
7499
7748
|
|
|
7500
7749
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
7501
|
-
import { applyToPoint as
|
|
7750
|
+
import { applyToPoint as applyToPoint53 } from "transformation-matrix";
|
|
7502
7751
|
function createSchematicTrace({
|
|
7503
7752
|
trace,
|
|
7504
7753
|
transform,
|
|
@@ -7512,11 +7761,11 @@ function createSchematicTrace({
|
|
|
7512
7761
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
7513
7762
|
const edge = edges[edgeIndex];
|
|
7514
7763
|
if (edge.is_crossing) continue;
|
|
7515
|
-
const [screenFromX, screenFromY] =
|
|
7764
|
+
const [screenFromX, screenFromY] = applyToPoint53(transform, [
|
|
7516
7765
|
edge.from.x,
|
|
7517
7766
|
edge.from.y
|
|
7518
7767
|
]);
|
|
7519
|
-
const [screenToX, screenToY] =
|
|
7768
|
+
const [screenToX, screenToY] = applyToPoint53(transform, [
|
|
7520
7769
|
edge.to.x,
|
|
7521
7770
|
edge.to.y
|
|
7522
7771
|
]);
|
|
@@ -7560,11 +7809,11 @@ function createSchematicTrace({
|
|
|
7560
7809
|
}
|
|
7561
7810
|
for (const edge of edges) {
|
|
7562
7811
|
if (!edge.is_crossing) continue;
|
|
7563
|
-
const [screenFromX, screenFromY] =
|
|
7812
|
+
const [screenFromX, screenFromY] = applyToPoint53(transform, [
|
|
7564
7813
|
edge.from.x,
|
|
7565
7814
|
edge.from.y
|
|
7566
7815
|
]);
|
|
7567
|
-
const [screenToX, screenToY] =
|
|
7816
|
+
const [screenToX, screenToY] = applyToPoint53(transform, [
|
|
7568
7817
|
edge.to.x,
|
|
7569
7818
|
edge.to.y
|
|
7570
7819
|
]);
|
|
@@ -7608,7 +7857,7 @@ function createSchematicTrace({
|
|
|
7608
7857
|
}
|
|
7609
7858
|
if (trace.junctions) {
|
|
7610
7859
|
for (const junction of trace.junctions) {
|
|
7611
|
-
const [screenX, screenY] =
|
|
7860
|
+
const [screenX, screenY] = applyToPoint53(transform, [
|
|
7612
7861
|
junction.x,
|
|
7613
7862
|
junction.y
|
|
7614
7863
|
]);
|
|
@@ -7663,7 +7912,7 @@ function createSchematicTrace({
|
|
|
7663
7912
|
|
|
7664
7913
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
7665
7914
|
import {
|
|
7666
|
-
applyToPoint as
|
|
7915
|
+
applyToPoint as applyToPoint55,
|
|
7667
7916
|
compose as compose11,
|
|
7668
7917
|
rotate as rotate6,
|
|
7669
7918
|
scale as scale6,
|
|
@@ -7672,7 +7921,7 @@ import {
|
|
|
7672
7921
|
|
|
7673
7922
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
7674
7923
|
import {
|
|
7675
|
-
applyToPoint as
|
|
7924
|
+
applyToPoint as applyToPoint54,
|
|
7676
7925
|
compose as compose10,
|
|
7677
7926
|
rotate as rotate5,
|
|
7678
7927
|
scale as scale5,
|
|
@@ -7747,7 +7996,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7747
7996
|
x: symbolBounds.minX,
|
|
7748
7997
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
7749
7998
|
};
|
|
7750
|
-
const rotatedSymbolEnd =
|
|
7999
|
+
const rotatedSymbolEnd = applyToPoint54(rotationMatrix, symbolEndPoint);
|
|
7751
8000
|
const symbolToRealTransform = compose10(
|
|
7752
8001
|
translate10(
|
|
7753
8002
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
@@ -7757,11 +8006,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7757
8006
|
scale5(1)
|
|
7758
8007
|
// Use full symbol size
|
|
7759
8008
|
);
|
|
7760
|
-
const [screenMinX, screenMinY] =
|
|
8009
|
+
const [screenMinX, screenMinY] = applyToPoint54(
|
|
7761
8010
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
7762
8011
|
[bounds.minX, bounds.minY]
|
|
7763
8012
|
);
|
|
7764
|
-
const [screenMaxX, screenMaxY] =
|
|
8013
|
+
const [screenMaxX, screenMaxY] = applyToPoint54(
|
|
7765
8014
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
7766
8015
|
[bounds.maxX, bounds.maxY]
|
|
7767
8016
|
);
|
|
@@ -7785,7 +8034,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7785
8034
|
});
|
|
7786
8035
|
for (const path of symbolPaths) {
|
|
7787
8036
|
const symbolPath = path.points.map((p, i) => {
|
|
7788
|
-
const [x, y] =
|
|
8037
|
+
const [x, y] = applyToPoint54(
|
|
7789
8038
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
7790
8039
|
[p.x, p.y]
|
|
7791
8040
|
);
|
|
@@ -7806,7 +8055,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7806
8055
|
});
|
|
7807
8056
|
}
|
|
7808
8057
|
for (const text of symbolTexts) {
|
|
7809
|
-
const screenTextPos =
|
|
8058
|
+
const screenTextPos = applyToPoint54(
|
|
7810
8059
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
7811
8060
|
text
|
|
7812
8061
|
);
|
|
@@ -7848,7 +8097,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7848
8097
|
});
|
|
7849
8098
|
}
|
|
7850
8099
|
for (const box of symbolBoxes) {
|
|
7851
|
-
const screenBoxPos =
|
|
8100
|
+
const screenBoxPos = applyToPoint54(
|
|
7852
8101
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
7853
8102
|
box
|
|
7854
8103
|
);
|
|
@@ -7871,7 +8120,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7871
8120
|
});
|
|
7872
8121
|
}
|
|
7873
8122
|
for (const circle of symbolCircles) {
|
|
7874
|
-
const screenCirclePos =
|
|
8123
|
+
const screenCirclePos = applyToPoint54(
|
|
7875
8124
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
7876
8125
|
circle
|
|
7877
8126
|
);
|
|
@@ -7916,14 +8165,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
7916
8165
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
7917
8166
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
7918
8167
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
7919
|
-
const screenCenter =
|
|
8168
|
+
const screenCenter = applyToPoint55(realToScreenTransform, schNetLabel.center);
|
|
7920
8169
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
7921
8170
|
schNetLabel.anchor_side
|
|
7922
8171
|
);
|
|
7923
8172
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
7924
8173
|
screenTextGrowthVec.y *= -1;
|
|
7925
8174
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
7926
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
8175
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint55(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
7927
8176
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
7928
8177
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
7929
8178
|
};
|
|
@@ -7964,7 +8213,7 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
7964
8213
|
y: -0.6
|
|
7965
8214
|
}
|
|
7966
8215
|
].map(
|
|
7967
|
-
(fontRelativePoint) =>
|
|
8216
|
+
(fontRelativePoint) => applyToPoint55(
|
|
7968
8217
|
compose11(
|
|
7969
8218
|
realToScreenTransform,
|
|
7970
8219
|
translate11(realAnchorPosition.x, realAnchorPosition.y),
|
|
@@ -8041,17 +8290,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
8041
8290
|
};
|
|
8042
8291
|
|
|
8043
8292
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
8044
|
-
import { applyToPoint as
|
|
8293
|
+
import { applyToPoint as applyToPoint56 } from "transformation-matrix";
|
|
8045
8294
|
var createSvgObjectsFromSchematicBox = ({
|
|
8046
8295
|
schematicBox,
|
|
8047
8296
|
transform,
|
|
8048
8297
|
colorMap: colorMap2
|
|
8049
8298
|
}) => {
|
|
8050
|
-
const topLeft =
|
|
8299
|
+
const topLeft = applyToPoint56(transform, {
|
|
8051
8300
|
x: schematicBox.x,
|
|
8052
8301
|
y: schematicBox.y
|
|
8053
8302
|
});
|
|
8054
|
-
const bottomRight =
|
|
8303
|
+
const bottomRight = applyToPoint56(transform, {
|
|
8055
8304
|
x: schematicBox.x + schematicBox.width,
|
|
8056
8305
|
y: schematicBox.y + schematicBox.height
|
|
8057
8306
|
});
|
|
@@ -8087,7 +8336,7 @@ var createSvgObjectsFromSchematicBox = ({
|
|
|
8087
8336
|
};
|
|
8088
8337
|
|
|
8089
8338
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-table.ts
|
|
8090
|
-
import { applyToPoint as
|
|
8339
|
+
import { applyToPoint as applyToPoint57 } from "transformation-matrix";
|
|
8091
8340
|
var createSvgObjectsFromSchematicTable = ({
|
|
8092
8341
|
schematicTable,
|
|
8093
8342
|
transform,
|
|
@@ -8120,11 +8369,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8120
8369
|
const svgObjects = [];
|
|
8121
8370
|
const borderStrokeWidth = border_width * Math.abs(transform.a);
|
|
8122
8371
|
const gridStrokeWidth = getSchStrokeSize(transform);
|
|
8123
|
-
const [screenTopLeftX, screenTopLeftY] =
|
|
8372
|
+
const [screenTopLeftX, screenTopLeftY] = applyToPoint57(transform, [
|
|
8124
8373
|
topLeftX,
|
|
8125
8374
|
topLeftY
|
|
8126
8375
|
]);
|
|
8127
|
-
const [screenBottomRightX, screenBottomRightY] =
|
|
8376
|
+
const [screenBottomRightX, screenBottomRightY] = applyToPoint57(transform, [
|
|
8128
8377
|
topLeftX + totalWidth,
|
|
8129
8378
|
topLeftY - totalHeight
|
|
8130
8379
|
]);
|
|
@@ -8156,8 +8405,8 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8156
8405
|
(cell) => cell.start_column_index <= i && cell.end_column_index > i && cell.start_row_index <= j && cell.end_row_index >= j
|
|
8157
8406
|
);
|
|
8158
8407
|
if (!isMerged) {
|
|
8159
|
-
const start =
|
|
8160
|
-
const end =
|
|
8408
|
+
const start = applyToPoint57(transform, { x: currentX, y: segmentStartY });
|
|
8409
|
+
const end = applyToPoint57(transform, { x: currentX, y: segmentEndY });
|
|
8161
8410
|
svgObjects.push({
|
|
8162
8411
|
name: "line",
|
|
8163
8412
|
type: "element",
|
|
@@ -8186,11 +8435,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8186
8435
|
(cell) => cell.start_row_index <= i && cell.end_row_index > i && cell.start_column_index <= j && cell.end_column_index >= j
|
|
8187
8436
|
);
|
|
8188
8437
|
if (!isMerged) {
|
|
8189
|
-
const start =
|
|
8438
|
+
const start = applyToPoint57(transform, {
|
|
8190
8439
|
x: segmentStartX,
|
|
8191
8440
|
y: currentY
|
|
8192
8441
|
});
|
|
8193
|
-
const end =
|
|
8442
|
+
const end = applyToPoint57(transform, { x: segmentEndX, y: currentY });
|
|
8194
8443
|
svgObjects.push({
|
|
8195
8444
|
name: "line",
|
|
8196
8445
|
type: "element",
|
|
@@ -8232,7 +8481,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8232
8481
|
} else if (vertical_align === "bottom") {
|
|
8233
8482
|
realTextAnchorPos.y = cellTopLeftY - cellHeight + cell_padding;
|
|
8234
8483
|
}
|
|
8235
|
-
const screenTextAnchorPos =
|
|
8484
|
+
const screenTextAnchorPos = applyToPoint57(transform, realTextAnchorPos);
|
|
8236
8485
|
const fontSize = getSchScreenFontSize(
|
|
8237
8486
|
transform,
|
|
8238
8487
|
"reference_designator",
|
|
@@ -8288,13 +8537,13 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8288
8537
|
|
|
8289
8538
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
|
|
8290
8539
|
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
8291
|
-
import { applyToPoint as
|
|
8540
|
+
import { applyToPoint as applyToPoint58 } from "transformation-matrix";
|
|
8292
8541
|
var PIN_CIRCLE_RADIUS_MM2 = 0.02;
|
|
8293
8542
|
var createSvgObjectsForSchPortHover = ({
|
|
8294
8543
|
schPort,
|
|
8295
8544
|
transform
|
|
8296
8545
|
}) => {
|
|
8297
|
-
const screenSchPortPos =
|
|
8546
|
+
const screenSchPortPos = applyToPoint58(transform, schPort.center);
|
|
8298
8547
|
const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
|
|
8299
8548
|
return [
|
|
8300
8549
|
{
|
|
@@ -8339,14 +8588,14 @@ var createSvgObjectsForSchComponentPortHovers = ({
|
|
|
8339
8588
|
};
|
|
8340
8589
|
|
|
8341
8590
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-line.ts
|
|
8342
|
-
import { applyToPoint as
|
|
8591
|
+
import { applyToPoint as applyToPoint59 } from "transformation-matrix";
|
|
8343
8592
|
function createSvgObjectsFromSchematicLine({
|
|
8344
8593
|
schLine,
|
|
8345
8594
|
transform,
|
|
8346
8595
|
colorMap: colorMap2
|
|
8347
8596
|
}) {
|
|
8348
|
-
const p1 =
|
|
8349
|
-
const p2 =
|
|
8597
|
+
const p1 = applyToPoint59(transform, { x: schLine.x1, y: schLine.y1 });
|
|
8598
|
+
const p2 = applyToPoint59(transform, { x: schLine.x2, y: schLine.y2 });
|
|
8350
8599
|
const strokeWidth = schLine.stroke_width ?? 0.02;
|
|
8351
8600
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
8352
8601
|
return [
|
|
@@ -8375,13 +8624,13 @@ function createSvgObjectsFromSchematicLine({
|
|
|
8375
8624
|
}
|
|
8376
8625
|
|
|
8377
8626
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-circle.ts
|
|
8378
|
-
import { applyToPoint as
|
|
8627
|
+
import { applyToPoint as applyToPoint60 } from "transformation-matrix";
|
|
8379
8628
|
function createSvgObjectsFromSchematicCircle({
|
|
8380
8629
|
schCircle,
|
|
8381
8630
|
transform,
|
|
8382
8631
|
colorMap: colorMap2
|
|
8383
8632
|
}) {
|
|
8384
|
-
const center =
|
|
8633
|
+
const center = applyToPoint60(transform, schCircle.center);
|
|
8385
8634
|
const transformedRadius = Math.abs(transform.a) * schCircle.radius;
|
|
8386
8635
|
const strokeWidth = schCircle.stroke_width ?? 0.02;
|
|
8387
8636
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -8411,13 +8660,13 @@ function createSvgObjectsFromSchematicCircle({
|
|
|
8411
8660
|
}
|
|
8412
8661
|
|
|
8413
8662
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-rect.ts
|
|
8414
|
-
import { applyToPoint as
|
|
8663
|
+
import { applyToPoint as applyToPoint61 } from "transformation-matrix";
|
|
8415
8664
|
function createSvgObjectsFromSchematicRect({
|
|
8416
8665
|
schRect,
|
|
8417
8666
|
transform,
|
|
8418
8667
|
colorMap: colorMap2
|
|
8419
8668
|
}) {
|
|
8420
|
-
const center =
|
|
8669
|
+
const center = applyToPoint61(transform, schRect.center);
|
|
8421
8670
|
const transformedWidth = Math.abs(transform.a) * schRect.width;
|
|
8422
8671
|
const transformedHeight = Math.abs(transform.d) * schRect.height;
|
|
8423
8672
|
const strokeWidth = schRect.stroke_width ?? 0.02;
|
|
@@ -8453,13 +8702,13 @@ function createSvgObjectsFromSchematicRect({
|
|
|
8453
8702
|
}
|
|
8454
8703
|
|
|
8455
8704
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-arc.ts
|
|
8456
|
-
import { applyToPoint as
|
|
8705
|
+
import { applyToPoint as applyToPoint62 } from "transformation-matrix";
|
|
8457
8706
|
function createSvgObjectsFromSchematicArc({
|
|
8458
8707
|
schArc,
|
|
8459
8708
|
transform,
|
|
8460
8709
|
colorMap: colorMap2
|
|
8461
8710
|
}) {
|
|
8462
|
-
const center =
|
|
8711
|
+
const center = applyToPoint62(transform, schArc.center);
|
|
8463
8712
|
const transformedRadius = Math.abs(transform.a) * schArc.radius;
|
|
8464
8713
|
const strokeWidth = schArc.stroke_width ?? 0.02;
|
|
8465
8714
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -9491,18 +9740,18 @@ function formatNumber2(value) {
|
|
|
9491
9740
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
9492
9741
|
import { stringify as stringify7 } from "svgson";
|
|
9493
9742
|
import {
|
|
9494
|
-
applyToPoint as
|
|
9743
|
+
applyToPoint as applyToPoint65,
|
|
9495
9744
|
compose as compose14,
|
|
9496
9745
|
scale as scale8,
|
|
9497
9746
|
translate as translate14
|
|
9498
9747
|
} from "transformation-matrix";
|
|
9499
9748
|
|
|
9500
9749
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
9501
|
-
import { applyToPoint as
|
|
9750
|
+
import { applyToPoint as applyToPoint64 } from "transformation-matrix";
|
|
9502
9751
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
9503
9752
|
const { transform, layer: layerFilter } = ctx;
|
|
9504
9753
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
9505
|
-
const [x, y] =
|
|
9754
|
+
const [x, y] = applyToPoint64(transform, [solderPaste.x, solderPaste.y]);
|
|
9506
9755
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
9507
9756
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
9508
9757
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -9713,8 +9962,8 @@ function createSvgObjects4({ elm, ctx }) {
|
|
|
9713
9962
|
}
|
|
9714
9963
|
}
|
|
9715
9964
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
9716
|
-
const [x1, y1] =
|
|
9717
|
-
const [x2, y2] =
|
|
9965
|
+
const [x1, y1] = applyToPoint65(transform, [minX, minY]);
|
|
9966
|
+
const [x2, y2] = applyToPoint65(transform, [maxX, maxY]);
|
|
9718
9967
|
const width = Math.abs(x2 - x1);
|
|
9719
9968
|
const height = Math.abs(y2 - y1);
|
|
9720
9969
|
const x = Math.min(x1, x2);
|