circuit-to-svg 0.0.234 → 0.0.236
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 +400 -207
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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 applyToPoint28,
|
|
5
5
|
compose as compose5,
|
|
6
6
|
scale as scale2,
|
|
7
7
|
translate as translate5
|
|
@@ -605,7 +605,7 @@ function createSvgObjectsFromPcbFabricationNoteRect(fabricationNoteRect, ctx) {
|
|
|
605
605
|
return [svgObject];
|
|
606
606
|
}
|
|
607
607
|
|
|
608
|
-
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-dimension.ts
|
|
608
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-fabrication-note-dimension.ts
|
|
609
609
|
import { applyToPoint as applyToPoint6 } from "transformation-matrix";
|
|
610
610
|
function normalize(vector) {
|
|
611
611
|
const length = Math.hypot(vector.x, vector.y) || 1;
|
|
@@ -616,6 +616,196 @@ function toPath(points) {
|
|
|
616
616
|
(point, index) => index === 0 ? `M ${point.x} ${point.y}` : `L ${point.x} ${point.y}`
|
|
617
617
|
).join(" ");
|
|
618
618
|
}
|
|
619
|
+
function createSvgObjectsFromPcbFabricationNoteDimension(dimension, ctx) {
|
|
620
|
+
const { transform, layer: layerFilter } = ctx;
|
|
621
|
+
const {
|
|
622
|
+
from,
|
|
623
|
+
to,
|
|
624
|
+
text,
|
|
625
|
+
font_size = 1,
|
|
626
|
+
color,
|
|
627
|
+
arrow_size,
|
|
628
|
+
layer,
|
|
629
|
+
pcb_component_id,
|
|
630
|
+
pcb_fabrication_note_dimension_id
|
|
631
|
+
} = dimension;
|
|
632
|
+
if (layerFilter && layer && layer !== layerFilter) return [];
|
|
633
|
+
if (!from || !to || typeof from !== "object" || typeof to !== "object") {
|
|
634
|
+
console.error("Invalid pcb_fabrication_note_dimension endpoints", {
|
|
635
|
+
from,
|
|
636
|
+
to
|
|
637
|
+
});
|
|
638
|
+
return [];
|
|
639
|
+
}
|
|
640
|
+
if (typeof from.x !== "number" || typeof from.y !== "number" || typeof to.x !== "number" || typeof to.y !== "number") {
|
|
641
|
+
console.error("Invalid pcb_fabrication_note_dimension point values", {
|
|
642
|
+
from,
|
|
643
|
+
to
|
|
644
|
+
});
|
|
645
|
+
return [];
|
|
646
|
+
}
|
|
647
|
+
const numericArrowSize = typeof arrow_size === "number" ? arrow_size : void 0;
|
|
648
|
+
if (numericArrowSize === void 0 || !Number.isFinite(numericArrowSize) || numericArrowSize <= 0) {
|
|
649
|
+
console.error(
|
|
650
|
+
"Invalid pcb_fabrication_note_dimension arrow_size",
|
|
651
|
+
arrow_size
|
|
652
|
+
);
|
|
653
|
+
return [];
|
|
654
|
+
}
|
|
655
|
+
const arrowSize = numericArrowSize;
|
|
656
|
+
const direction = normalize({ x: to.x - from.x, y: to.y - from.y });
|
|
657
|
+
if (Number.isNaN(direction.x) || Number.isNaN(direction.y)) {
|
|
658
|
+
return [];
|
|
659
|
+
}
|
|
660
|
+
const perpendicular = { x: -direction.y, y: direction.x };
|
|
661
|
+
const arrowHalfWidth = arrowSize / 2;
|
|
662
|
+
const fromBase = {
|
|
663
|
+
x: from.x + direction.x * arrowSize,
|
|
664
|
+
y: from.y + direction.y * arrowSize
|
|
665
|
+
};
|
|
666
|
+
const toBase = {
|
|
667
|
+
x: to.x - direction.x * arrowSize,
|
|
668
|
+
y: to.y - direction.y * arrowSize
|
|
669
|
+
};
|
|
670
|
+
const fromTriangle = [
|
|
671
|
+
toScreen(from),
|
|
672
|
+
toScreen({
|
|
673
|
+
x: fromBase.x + perpendicular.x * arrowHalfWidth,
|
|
674
|
+
y: fromBase.y + perpendicular.y * arrowHalfWidth
|
|
675
|
+
}),
|
|
676
|
+
toScreen({
|
|
677
|
+
x: fromBase.x - perpendicular.x * arrowHalfWidth,
|
|
678
|
+
y: fromBase.y - perpendicular.y * arrowHalfWidth
|
|
679
|
+
})
|
|
680
|
+
];
|
|
681
|
+
const toTriangle = [
|
|
682
|
+
toScreen(to),
|
|
683
|
+
toScreen({
|
|
684
|
+
x: toBase.x + perpendicular.x * arrowHalfWidth,
|
|
685
|
+
y: toBase.y + perpendicular.y * arrowHalfWidth
|
|
686
|
+
}),
|
|
687
|
+
toScreen({
|
|
688
|
+
x: toBase.x - perpendicular.x * arrowHalfWidth,
|
|
689
|
+
y: toBase.y - perpendicular.y * arrowHalfWidth
|
|
690
|
+
})
|
|
691
|
+
];
|
|
692
|
+
const [lineStartX, lineStartY] = applyToPoint6(transform, [
|
|
693
|
+
fromBase.x,
|
|
694
|
+
fromBase.y
|
|
695
|
+
]);
|
|
696
|
+
const [lineEndX, lineEndY] = applyToPoint6(transform, [toBase.x, toBase.y]);
|
|
697
|
+
const strokeWidth = arrowSize / 5 * Math.abs(transform.a);
|
|
698
|
+
const lineColor = color || "rgba(255,255,255,0.5)";
|
|
699
|
+
const midPoint = {
|
|
700
|
+
x: (from.x + to.x) / 2,
|
|
701
|
+
y: (from.y + to.y) / 2
|
|
702
|
+
};
|
|
703
|
+
const textOffset = arrowSize * 1.5;
|
|
704
|
+
const textPoint = {
|
|
705
|
+
x: midPoint.x + perpendicular.x * textOffset,
|
|
706
|
+
y: midPoint.y + perpendicular.y * textOffset
|
|
707
|
+
};
|
|
708
|
+
const [textX, textY] = applyToPoint6(transform, [textPoint.x, textPoint.y]);
|
|
709
|
+
const transformedFontSize = font_size * Math.abs(transform.a);
|
|
710
|
+
const children = [
|
|
711
|
+
{
|
|
712
|
+
name: "path",
|
|
713
|
+
type: "element",
|
|
714
|
+
value: "",
|
|
715
|
+
attributes: {
|
|
716
|
+
d: `M ${lineStartX} ${lineStartY} L ${lineEndX} ${lineEndY}`,
|
|
717
|
+
stroke: lineColor,
|
|
718
|
+
fill: "none",
|
|
719
|
+
"stroke-width": strokeWidth.toString(),
|
|
720
|
+
"stroke-linecap": "round",
|
|
721
|
+
class: "pcb-fabrication-note-dimension-line"
|
|
722
|
+
},
|
|
723
|
+
children: []
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
name: "path",
|
|
727
|
+
type: "element",
|
|
728
|
+
value: "",
|
|
729
|
+
attributes: {
|
|
730
|
+
d: `${toPath(fromTriangle)} Z`,
|
|
731
|
+
fill: lineColor,
|
|
732
|
+
class: "pcb-fabrication-note-dimension-arrow"
|
|
733
|
+
},
|
|
734
|
+
children: []
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
name: "path",
|
|
738
|
+
type: "element",
|
|
739
|
+
value: "",
|
|
740
|
+
attributes: {
|
|
741
|
+
d: `${toPath(toTriangle)} Z`,
|
|
742
|
+
fill: lineColor,
|
|
743
|
+
class: "pcb-fabrication-note-dimension-arrow"
|
|
744
|
+
},
|
|
745
|
+
children: []
|
|
746
|
+
}
|
|
747
|
+
];
|
|
748
|
+
if (text) {
|
|
749
|
+
children.push({
|
|
750
|
+
name: "text",
|
|
751
|
+
type: "element",
|
|
752
|
+
value: "",
|
|
753
|
+
attributes: {
|
|
754
|
+
x: textX.toString(),
|
|
755
|
+
y: textY.toString(),
|
|
756
|
+
fill: lineColor,
|
|
757
|
+
"font-size": transformedFontSize.toString(),
|
|
758
|
+
"font-family": "Arial, sans-serif",
|
|
759
|
+
"text-anchor": "middle",
|
|
760
|
+
"dominant-baseline": "central",
|
|
761
|
+
class: "pcb-fabrication-note-dimension-text"
|
|
762
|
+
},
|
|
763
|
+
children: [
|
|
764
|
+
{
|
|
765
|
+
type: "text",
|
|
766
|
+
name: "",
|
|
767
|
+
value: text,
|
|
768
|
+
attributes: {},
|
|
769
|
+
children: []
|
|
770
|
+
}
|
|
771
|
+
]
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
const attributes = {
|
|
775
|
+
class: "pcb-fabrication-note-dimension",
|
|
776
|
+
"data-type": "pcb_fabrication_note_dimension",
|
|
777
|
+
"data-pcb-fabrication-note-dimension-id": pcb_fabrication_note_dimension_id,
|
|
778
|
+
"data-pcb-layer": layer ?? "overlay"
|
|
779
|
+
};
|
|
780
|
+
if (pcb_component_id !== void 0) {
|
|
781
|
+
attributes["data-pcb-component-id"] = pcb_component_id;
|
|
782
|
+
}
|
|
783
|
+
return [
|
|
784
|
+
{
|
|
785
|
+
name: "g",
|
|
786
|
+
type: "element",
|
|
787
|
+
value: "",
|
|
788
|
+
attributes,
|
|
789
|
+
children
|
|
790
|
+
}
|
|
791
|
+
];
|
|
792
|
+
function toScreen(point) {
|
|
793
|
+
const [x, y] = applyToPoint6(transform, [point.x, point.y]);
|
|
794
|
+
return { x, y };
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-dimension.ts
|
|
799
|
+
import { applyToPoint as applyToPoint7 } from "transformation-matrix";
|
|
800
|
+
function normalize2(vector) {
|
|
801
|
+
const length = Math.hypot(vector.x, vector.y) || 1;
|
|
802
|
+
return { x: vector.x / length, y: vector.y / length };
|
|
803
|
+
}
|
|
804
|
+
function toPath2(points) {
|
|
805
|
+
return points.map(
|
|
806
|
+
(point, index) => index === 0 ? `M ${point.x} ${point.y}` : `L ${point.x} ${point.y}`
|
|
807
|
+
).join(" ");
|
|
808
|
+
}
|
|
619
809
|
function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
|
|
620
810
|
const { transform } = ctx;
|
|
621
811
|
const { from, to, text, font_size = 1, color, arrow_size } = dimension;
|
|
@@ -627,7 +817,7 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
|
|
|
627
817
|
console.error("Invalid pcb_note_dimension arrow_size", arrow_size);
|
|
628
818
|
return [];
|
|
629
819
|
}
|
|
630
|
-
const direction =
|
|
820
|
+
const direction = normalize2({ x: to.x - from.x, y: to.y - from.y });
|
|
631
821
|
if (Number.isNaN(direction.x) || Number.isNaN(direction.y)) {
|
|
632
822
|
return [];
|
|
633
823
|
}
|
|
@@ -663,11 +853,11 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
|
|
|
663
853
|
y: toBase.y - perpendicular.y * arrowHalfWidth
|
|
664
854
|
})
|
|
665
855
|
];
|
|
666
|
-
const [lineStartX, lineStartY] =
|
|
856
|
+
const [lineStartX, lineStartY] = applyToPoint7(transform, [
|
|
667
857
|
fromBase.x,
|
|
668
858
|
fromBase.y
|
|
669
859
|
]);
|
|
670
|
-
const [lineEndX, lineEndY] =
|
|
860
|
+
const [lineEndX, lineEndY] = applyToPoint7(transform, [toBase.x, toBase.y]);
|
|
671
861
|
const strokeWidth = arrow_size / 5 * Math.abs(transform.a);
|
|
672
862
|
const lineColor = color || "rgba(255,255,255,0.5)";
|
|
673
863
|
const midPoint = {
|
|
@@ -679,7 +869,7 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
|
|
|
679
869
|
x: midPoint.x + perpendicular.x * textOffset,
|
|
680
870
|
y: midPoint.y + perpendicular.y * textOffset
|
|
681
871
|
};
|
|
682
|
-
const [textX, textY] =
|
|
872
|
+
const [textX, textY] = applyToPoint7(transform, [textPoint.x, textPoint.y]);
|
|
683
873
|
const transformedFontSize = font_size * Math.abs(transform.a);
|
|
684
874
|
const children = [
|
|
685
875
|
{
|
|
@@ -701,7 +891,7 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
|
|
|
701
891
|
type: "element",
|
|
702
892
|
value: "",
|
|
703
893
|
attributes: {
|
|
704
|
-
d: `${
|
|
894
|
+
d: `${toPath2(fromTriangle)} Z`,
|
|
705
895
|
fill: lineColor,
|
|
706
896
|
class: "pcb-note-dimension-arrow"
|
|
707
897
|
},
|
|
@@ -712,7 +902,7 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
|
|
|
712
902
|
type: "element",
|
|
713
903
|
value: "",
|
|
714
904
|
attributes: {
|
|
715
|
-
d: `${
|
|
905
|
+
d: `${toPath2(toTriangle)} Z`,
|
|
716
906
|
fill: lineColor,
|
|
717
907
|
class: "pcb-note-dimension-arrow"
|
|
718
908
|
},
|
|
@@ -760,13 +950,13 @@ function createSvgObjectsFromPcbNoteDimension(dimension, ctx) {
|
|
|
760
950
|
}
|
|
761
951
|
];
|
|
762
952
|
function toScreen(point) {
|
|
763
|
-
const [x, y] =
|
|
953
|
+
const [x, y] = applyToPoint7(transform, [point.x, point.y]);
|
|
764
954
|
return { x, y };
|
|
765
955
|
}
|
|
766
956
|
}
|
|
767
957
|
|
|
768
958
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-text.ts
|
|
769
|
-
import { applyToPoint as
|
|
959
|
+
import { applyToPoint as applyToPoint8 } from "transformation-matrix";
|
|
770
960
|
var DEFAULT_OVERLAY_COLOR = "rgba(255,255,255,0.5)";
|
|
771
961
|
function createSvgObjectsFromPcbNoteText(note, ctx) {
|
|
772
962
|
const { transform } = ctx;
|
|
@@ -785,7 +975,7 @@ function createSvgObjectsFromPcbNoteText(note, ctx) {
|
|
|
785
975
|
console.error("Invalid pcb_note_text text", text);
|
|
786
976
|
return [];
|
|
787
977
|
}
|
|
788
|
-
const [x, y] =
|
|
978
|
+
const [x, y] = applyToPoint8(transform, [anchor_position.x, anchor_position.y]);
|
|
789
979
|
const transformedFontSize = font_size * Math.abs(transform.a);
|
|
790
980
|
let textAnchor = "middle";
|
|
791
981
|
let dominantBaseline = "central";
|
|
@@ -843,7 +1033,7 @@ function createSvgObjectsFromPcbNoteText(note, ctx) {
|
|
|
843
1033
|
}
|
|
844
1034
|
|
|
845
1035
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-rect.ts
|
|
846
|
-
import { applyToPoint as
|
|
1036
|
+
import { applyToPoint as applyToPoint9 } from "transformation-matrix";
|
|
847
1037
|
var DEFAULT_OVERLAY_COLOR2 = "rgba(255,255,255,0.5)";
|
|
848
1038
|
var DEFAULT_FILL_COLOR = "rgba(255,255,255,0.2)";
|
|
849
1039
|
function createSvgObjectsFromPcbNoteRect(noteRect, ctx) {
|
|
@@ -864,11 +1054,11 @@ function createSvgObjectsFromPcbNoteRect(noteRect, ctx) {
|
|
|
864
1054
|
}
|
|
865
1055
|
const halfWidth = width / 2;
|
|
866
1056
|
const halfHeight = height / 2;
|
|
867
|
-
const [topLeftX, topLeftY] =
|
|
1057
|
+
const [topLeftX, topLeftY] = applyToPoint9(transform, [
|
|
868
1058
|
center.x - halfWidth,
|
|
869
1059
|
center.y + halfHeight
|
|
870
1060
|
]);
|
|
871
|
-
const [bottomRightX, bottomRightY] =
|
|
1061
|
+
const [bottomRightX, bottomRightY] = applyToPoint9(transform, [
|
|
872
1062
|
center.x + halfWidth,
|
|
873
1063
|
center.y - halfHeight
|
|
874
1064
|
]);
|
|
@@ -917,7 +1107,7 @@ function createSvgObjectsFromPcbNoteRect(noteRect, ctx) {
|
|
|
917
1107
|
}
|
|
918
1108
|
|
|
919
1109
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-path.ts
|
|
920
|
-
import { applyToPoint as
|
|
1110
|
+
import { applyToPoint as applyToPoint10 } from "transformation-matrix";
|
|
921
1111
|
var DEFAULT_OVERLAY_COLOR3 = "rgba(255,255,255,0.5)";
|
|
922
1112
|
function createSvgObjectsFromPcbNotePath(notePath, ctx) {
|
|
923
1113
|
const { transform } = ctx;
|
|
@@ -932,7 +1122,7 @@ function createSvgObjectsFromPcbNotePath(notePath, ctx) {
|
|
|
932
1122
|
}
|
|
933
1123
|
}
|
|
934
1124
|
const pathD = notePath.route.map((point, index) => {
|
|
935
|
-
const [x, y] =
|
|
1125
|
+
const [x, y] = applyToPoint10(transform, [point.x, point.y]);
|
|
936
1126
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
937
1127
|
}).join(" ");
|
|
938
1128
|
const strokeWidth = notePath.stroke_width * Math.abs(transform.a);
|
|
@@ -956,7 +1146,7 @@ function createSvgObjectsFromPcbNotePath(notePath, ctx) {
|
|
|
956
1146
|
}
|
|
957
1147
|
|
|
958
1148
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-note-line.ts
|
|
959
|
-
import { applyToPoint as
|
|
1149
|
+
import { applyToPoint as applyToPoint11 } from "transformation-matrix";
|
|
960
1150
|
var DEFAULT_OVERLAY_COLOR4 = "rgba(255,255,255,0.5)";
|
|
961
1151
|
function createSvgObjectsFromPcbNoteLine(noteLine, ctx) {
|
|
962
1152
|
const { transform } = ctx;
|
|
@@ -970,8 +1160,8 @@ function createSvgObjectsFromPcbNoteLine(noteLine, ctx) {
|
|
|
970
1160
|
});
|
|
971
1161
|
return [];
|
|
972
1162
|
}
|
|
973
|
-
const [startX, startY] =
|
|
974
|
-
const [endX, endY] =
|
|
1163
|
+
const [startX, startY] = applyToPoint11(transform, [x1, y1]);
|
|
1164
|
+
const [endX, endY] = applyToPoint11(transform, [x2, y2]);
|
|
975
1165
|
const baseStrokeWidth = typeof stroke_width === "number" ? stroke_width : 0;
|
|
976
1166
|
const transformedStrokeWidth = baseStrokeWidth * Math.abs(transform.a);
|
|
977
1167
|
const attributes = {
|
|
@@ -1003,10 +1193,10 @@ function createSvgObjectsFromPcbNoteLine(noteLine, ctx) {
|
|
|
1003
1193
|
}
|
|
1004
1194
|
|
|
1005
1195
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-plated-hole.ts
|
|
1006
|
-
import { applyToPoint as
|
|
1196
|
+
import { applyToPoint as applyToPoint12 } from "transformation-matrix";
|
|
1007
1197
|
function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
1008
1198
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
1009
|
-
const [x, y] =
|
|
1199
|
+
const [x, y] = applyToPoint12(transform, [hole.x, hole.y]);
|
|
1010
1200
|
const copperLayer = Array.isArray(hole.layers) && hole.layers[0] || hole.layer || "top";
|
|
1011
1201
|
if (hole.shape === "pill") {
|
|
1012
1202
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
@@ -1123,7 +1313,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
1123
1313
|
const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
|
|
1124
1314
|
const scaledRectBorderRadius = (hole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
1125
1315
|
const holeRadius = scaledHoleDiameter / 2;
|
|
1126
|
-
const [holeCx, holeCy] =
|
|
1316
|
+
const [holeCx, holeCy] = applyToPoint12(transform, [
|
|
1127
1317
|
h.x + (h.hole_offset_x ?? 0),
|
|
1128
1318
|
h.y + (h.hole_offset_y ?? 0)
|
|
1129
1319
|
]);
|
|
@@ -1188,7 +1378,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
1188
1378
|
const pillHoleWithOffsets = pillHole;
|
|
1189
1379
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
1190
1380
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
1191
|
-
const [holeCenterX, holeCenterY] =
|
|
1381
|
+
const [holeCenterX, holeCenterY] = applyToPoint12(transform, [
|
|
1192
1382
|
pillHole.x + holeOffsetX,
|
|
1193
1383
|
pillHole.y + holeOffsetY
|
|
1194
1384
|
]);
|
|
@@ -1257,7 +1447,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
1257
1447
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
1258
1448
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
1259
1449
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
1260
|
-
const [holeCenterX, holeCenterY] =
|
|
1450
|
+
const [holeCenterX, holeCenterY] = applyToPoint12(transform, [
|
|
1261
1451
|
rotatedHole.x + holeOffsetX,
|
|
1262
1452
|
rotatedHole.y + holeOffsetY
|
|
1263
1453
|
]);
|
|
@@ -1320,12 +1510,12 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
1320
1510
|
}
|
|
1321
1511
|
|
|
1322
1512
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-path.ts
|
|
1323
|
-
import { applyToPoint as
|
|
1513
|
+
import { applyToPoint as applyToPoint13 } from "transformation-matrix";
|
|
1324
1514
|
function createSvgObjectsFromPcbSilkscreenPath(silkscreenPath, ctx) {
|
|
1325
1515
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1326
1516
|
if (!silkscreenPath.route || !Array.isArray(silkscreenPath.route)) return [];
|
|
1327
1517
|
let path = silkscreenPath.route.map((point, index) => {
|
|
1328
|
-
const [x, y] =
|
|
1518
|
+
const [x, y] = applyToPoint13(transform, [point.x, point.y]);
|
|
1329
1519
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
1330
1520
|
}).join(" ");
|
|
1331
1521
|
const firstPoint = silkscreenPath.route[0];
|
|
@@ -1361,7 +1551,7 @@ function createSvgObjectsFromPcbSilkscreenPath(silkscreenPath, ctx) {
|
|
|
1361
1551
|
|
|
1362
1552
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-text.ts
|
|
1363
1553
|
import {
|
|
1364
|
-
applyToPoint as
|
|
1554
|
+
applyToPoint as applyToPoint14,
|
|
1365
1555
|
compose as compose2,
|
|
1366
1556
|
rotate as rotate2,
|
|
1367
1557
|
translate as translate2,
|
|
@@ -1383,7 +1573,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
1383
1573
|
console.error("Invalid anchor_position:", anchor_position);
|
|
1384
1574
|
return [];
|
|
1385
1575
|
}
|
|
1386
|
-
const [transformedX, transformedY] =
|
|
1576
|
+
const [transformedX, transformedY] = applyToPoint14(transform, [
|
|
1387
1577
|
anchor_position.x,
|
|
1388
1578
|
anchor_position.y
|
|
1389
1579
|
]);
|
|
@@ -1491,7 +1681,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
1491
1681
|
}
|
|
1492
1682
|
|
|
1493
1683
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-rect.ts
|
|
1494
|
-
import { applyToPoint as
|
|
1684
|
+
import { applyToPoint as applyToPoint15 } from "transformation-matrix";
|
|
1495
1685
|
function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
|
|
1496
1686
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1497
1687
|
const {
|
|
@@ -1510,7 +1700,7 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
|
|
|
1510
1700
|
console.error("Invalid rectangle data:", { center, width, height });
|
|
1511
1701
|
return [];
|
|
1512
1702
|
}
|
|
1513
|
-
const [transformedX, transformedY] =
|
|
1703
|
+
const [transformedX, transformedY] = applyToPoint15(transform, [
|
|
1514
1704
|
center.x,
|
|
1515
1705
|
center.y
|
|
1516
1706
|
]);
|
|
@@ -1557,7 +1747,7 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
|
|
|
1557
1747
|
}
|
|
1558
1748
|
|
|
1559
1749
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-circle.ts
|
|
1560
|
-
import { applyToPoint as
|
|
1750
|
+
import { applyToPoint as applyToPoint16 } from "transformation-matrix";
|
|
1561
1751
|
function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
1562
1752
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1563
1753
|
const {
|
|
@@ -1572,7 +1762,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
|
1572
1762
|
console.error("Invalid PCB Silkscreen Circle data:", { center, radius });
|
|
1573
1763
|
return [];
|
|
1574
1764
|
}
|
|
1575
|
-
const [transformedX, transformedY] =
|
|
1765
|
+
const [transformedX, transformedY] = applyToPoint16(transform, [
|
|
1576
1766
|
center.x,
|
|
1577
1767
|
center.y
|
|
1578
1768
|
]);
|
|
@@ -1600,7 +1790,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
|
1600
1790
|
}
|
|
1601
1791
|
|
|
1602
1792
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-line.ts
|
|
1603
|
-
import { applyToPoint as
|
|
1793
|
+
import { applyToPoint as applyToPoint17 } from "transformation-matrix";
|
|
1604
1794
|
function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
|
|
1605
1795
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1606
1796
|
const {
|
|
@@ -1617,8 +1807,8 @@ function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
|
|
|
1617
1807
|
console.error("Invalid coordinates:", { x1, y1, x2, y2 });
|
|
1618
1808
|
return [];
|
|
1619
1809
|
}
|
|
1620
|
-
const [transformedX1, transformedY1] =
|
|
1621
|
-
const [transformedX2, transformedY2] =
|
|
1810
|
+
const [transformedX1, transformedY1] = applyToPoint17(transform, [x1, y1]);
|
|
1811
|
+
const [transformedX2, transformedY2] = applyToPoint17(transform, [x2, y2]);
|
|
1622
1812
|
const transformedStrokeWidth = stroke_width * Math.abs(transform.a);
|
|
1623
1813
|
const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
|
|
1624
1814
|
return [
|
|
@@ -1653,7 +1843,7 @@ function pairs(arr) {
|
|
|
1653
1843
|
}
|
|
1654
1844
|
|
|
1655
1845
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace.ts
|
|
1656
|
-
import { applyToPoint as
|
|
1846
|
+
import { applyToPoint as applyToPoint18 } from "transformation-matrix";
|
|
1657
1847
|
|
|
1658
1848
|
// lib/pcb/colors.ts
|
|
1659
1849
|
var DEFAULT_PCB_COLOR_MAP = {
|
|
@@ -1709,8 +1899,8 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
|
1709
1899
|
const segments = pairs(trace.route);
|
|
1710
1900
|
const svgObjects = [];
|
|
1711
1901
|
for (const [start, end] of segments) {
|
|
1712
|
-
const startPoint =
|
|
1713
|
-
const endPoint =
|
|
1902
|
+
const startPoint = applyToPoint18(transform, [start.x, start.y]);
|
|
1903
|
+
const endPoint = applyToPoint18(transform, [end.x, end.y]);
|
|
1714
1904
|
const layer = "layer" in start ? start.layer : "layer" in end ? end.layer : null;
|
|
1715
1905
|
if (!layer) continue;
|
|
1716
1906
|
if (layerFilter && layer !== layerFilter) continue;
|
|
@@ -1782,7 +1972,7 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
|
1782
1972
|
}
|
|
1783
1973
|
|
|
1784
1974
|
// lib/pcb/svg-object-fns/create-svg-objects-from-smt-pads.ts
|
|
1785
|
-
import { applyToPoint as
|
|
1975
|
+
import { applyToPoint as applyToPoint19 } from "transformation-matrix";
|
|
1786
1976
|
function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
1787
1977
|
const { transform, layer: layerFilter, colorMap: colorMap2, renderSolderMask } = ctx;
|
|
1788
1978
|
if (layerFilter && pad.layer !== layerFilter) return [];
|
|
@@ -1792,7 +1982,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1792
1982
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
1793
1983
|
const width = pad.width * Math.abs(transform.a);
|
|
1794
1984
|
const height = pad.height * Math.abs(transform.d);
|
|
1795
|
-
const [x, y] =
|
|
1985
|
+
const [x, y] = applyToPoint19(transform, [pad.x, pad.y]);
|
|
1796
1986
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
1797
1987
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
1798
1988
|
const padElement2 = {
|
|
@@ -1874,7 +2064,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1874
2064
|
const width = pad.width * Math.abs(transform.a);
|
|
1875
2065
|
const height = pad.height * Math.abs(transform.d);
|
|
1876
2066
|
const radius = pad.radius * Math.abs(transform.a);
|
|
1877
|
-
const [x, y] =
|
|
2067
|
+
const [x, y] = applyToPoint19(transform, [pad.x, pad.y]);
|
|
1878
2068
|
const padElement = {
|
|
1879
2069
|
name: "rect",
|
|
1880
2070
|
type: "element",
|
|
@@ -1912,7 +2102,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1912
2102
|
}
|
|
1913
2103
|
if (pad.shape === "circle") {
|
|
1914
2104
|
const radius = pad.radius * Math.abs(transform.a);
|
|
1915
|
-
const [x, y] =
|
|
2105
|
+
const [x, y] = applyToPoint19(transform, [pad.x, pad.y]);
|
|
1916
2106
|
const padElement = {
|
|
1917
2107
|
name: "circle",
|
|
1918
2108
|
type: "element",
|
|
@@ -1947,7 +2137,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1947
2137
|
}
|
|
1948
2138
|
if (pad.shape === "polygon") {
|
|
1949
2139
|
const points = (pad.points ?? []).map(
|
|
1950
|
-
(point) =>
|
|
2140
|
+
(point) => applyToPoint19(transform, [point.x, point.y])
|
|
1951
2141
|
);
|
|
1952
2142
|
const padElement = {
|
|
1953
2143
|
name: "polygon",
|
|
@@ -1983,32 +2173,32 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1983
2173
|
}
|
|
1984
2174
|
|
|
1985
2175
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-board.ts
|
|
1986
|
-
import { applyToPoint as
|
|
2176
|
+
import { applyToPoint as applyToPoint20 } from "transformation-matrix";
|
|
1987
2177
|
function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
1988
2178
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
1989
2179
|
const { width, height, center, outline } = pcbBoard;
|
|
1990
2180
|
let path;
|
|
1991
2181
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
1992
2182
|
path = outline.map((point, index) => {
|
|
1993
|
-
const [x, y] =
|
|
2183
|
+
const [x, y] = applyToPoint20(transform, [point.x, point.y]);
|
|
1994
2184
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
1995
2185
|
}).join(" ");
|
|
1996
2186
|
} else {
|
|
1997
2187
|
const halfWidth = width / 2;
|
|
1998
2188
|
const halfHeight = height / 2;
|
|
1999
|
-
const topLeft =
|
|
2189
|
+
const topLeft = applyToPoint20(transform, [
|
|
2000
2190
|
center.x - halfWidth,
|
|
2001
2191
|
center.y - halfHeight
|
|
2002
2192
|
]);
|
|
2003
|
-
const topRight =
|
|
2193
|
+
const topRight = applyToPoint20(transform, [
|
|
2004
2194
|
center.x + halfWidth,
|
|
2005
2195
|
center.y - halfHeight
|
|
2006
2196
|
]);
|
|
2007
|
-
const bottomRight =
|
|
2197
|
+
const bottomRight = applyToPoint20(transform, [
|
|
2008
2198
|
center.x + halfWidth,
|
|
2009
2199
|
center.y + halfHeight
|
|
2010
2200
|
]);
|
|
2011
|
-
const bottomLeft =
|
|
2201
|
+
const bottomLeft = applyToPoint20(transform, [
|
|
2012
2202
|
center.x - halfWidth,
|
|
2013
2203
|
center.y + halfHeight
|
|
2014
2204
|
]);
|
|
@@ -2035,10 +2225,10 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
|
2035
2225
|
}
|
|
2036
2226
|
|
|
2037
2227
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-via.ts
|
|
2038
|
-
import { applyToPoint as
|
|
2228
|
+
import { applyToPoint as applyToPoint21 } from "transformation-matrix";
|
|
2039
2229
|
function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
2040
2230
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
2041
|
-
const [x, y] =
|
|
2231
|
+
const [x, y] = applyToPoint21(transform, [hole.x, hole.y]);
|
|
2042
2232
|
const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a);
|
|
2043
2233
|
const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a);
|
|
2044
2234
|
const scaledHoleWidth = hole.hole_diameter * Math.abs(transform.a);
|
|
@@ -2084,10 +2274,10 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
|
2084
2274
|
}
|
|
2085
2275
|
|
|
2086
2276
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-hole.ts
|
|
2087
|
-
import { applyToPoint as
|
|
2277
|
+
import { applyToPoint as applyToPoint22 } from "transformation-matrix";
|
|
2088
2278
|
function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
2089
2279
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
2090
|
-
const [x, y] =
|
|
2280
|
+
const [x, y] = applyToPoint22(transform, [hole.x, hole.y]);
|
|
2091
2281
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
2092
2282
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
2093
2283
|
const radius = scaledDiameter / 2;
|
|
@@ -2179,7 +2369,7 @@ function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
|
2179
2369
|
const scaledHeight = hole.hole_height * Math.abs(transform.a);
|
|
2180
2370
|
const radiusX = scaledWidth / 2;
|
|
2181
2371
|
const straightLength = scaledHeight - scaledWidth;
|
|
2182
|
-
const rotation = hole.
|
|
2372
|
+
const rotation = "ccw_rotation" in hole ? hole.ccw_rotation ?? 0 : 0;
|
|
2183
2373
|
return [
|
|
2184
2374
|
{
|
|
2185
2375
|
name: "path",
|
|
@@ -2205,7 +2395,7 @@ import {
|
|
|
2205
2395
|
getFullConnectivityMapFromCircuitJson
|
|
2206
2396
|
} from "circuit-json-to-connectivity-map";
|
|
2207
2397
|
import "svgson";
|
|
2208
|
-
import { applyToPoint as
|
|
2398
|
+
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
2209
2399
|
|
|
2210
2400
|
// lib/pcb/create-svg-objects-from-pcb-rats-nest/get-element-position.ts
|
|
2211
2401
|
import { su } from "@tscircuit/circuit-json-util";
|
|
@@ -2285,11 +2475,11 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
2285
2475
|
});
|
|
2286
2476
|
const svgObjects = [];
|
|
2287
2477
|
for (const line of ratsNestLines) {
|
|
2288
|
-
const transformedStart =
|
|
2478
|
+
const transformedStart = applyToPoint23(transform, [
|
|
2289
2479
|
line.startPoint.x,
|
|
2290
2480
|
line.startPoint.y
|
|
2291
2481
|
]);
|
|
2292
|
-
const transformedEnd =
|
|
2482
|
+
const transformedEnd = applyToPoint23(transform, [
|
|
2293
2483
|
line.endPoint.x,
|
|
2294
2484
|
line.endPoint.y
|
|
2295
2485
|
]);
|
|
@@ -2317,7 +2507,7 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
2317
2507
|
|
|
2318
2508
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-cutout.ts
|
|
2319
2509
|
import {
|
|
2320
|
-
applyToPoint as
|
|
2510
|
+
applyToPoint as applyToPoint24,
|
|
2321
2511
|
compose as compose3,
|
|
2322
2512
|
rotate as rotate3,
|
|
2323
2513
|
translate as translate3,
|
|
@@ -2327,7 +2517,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2327
2517
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
2328
2518
|
if (cutout.shape === "rect") {
|
|
2329
2519
|
const rectCutout = cutout;
|
|
2330
|
-
const [cx, cy] =
|
|
2520
|
+
const [cx, cy] = applyToPoint24(transform, [
|
|
2331
2521
|
rectCutout.center.x,
|
|
2332
2522
|
rectCutout.center.y
|
|
2333
2523
|
]);
|
|
@@ -2358,7 +2548,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2358
2548
|
}
|
|
2359
2549
|
if (cutout.shape === "circle") {
|
|
2360
2550
|
const circleCutout = cutout;
|
|
2361
|
-
const [cx, cy] =
|
|
2551
|
+
const [cx, cy] = applyToPoint24(transform, [
|
|
2362
2552
|
circleCutout.center.x,
|
|
2363
2553
|
circleCutout.center.y
|
|
2364
2554
|
]);
|
|
@@ -2385,7 +2575,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2385
2575
|
const polygonCutout = cutout;
|
|
2386
2576
|
if (!polygonCutout.points || polygonCutout.points.length === 0) return [];
|
|
2387
2577
|
const transformedPoints = polygonCutout.points.map(
|
|
2388
|
-
(p) =>
|
|
2578
|
+
(p) => applyToPoint24(transform, [p.x, p.y])
|
|
2389
2579
|
);
|
|
2390
2580
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
2391
2581
|
return [
|
|
@@ -2409,7 +2599,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2409
2599
|
|
|
2410
2600
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-copper-pour.ts
|
|
2411
2601
|
import {
|
|
2412
|
-
applyToPoint as
|
|
2602
|
+
applyToPoint as applyToPoint26,
|
|
2413
2603
|
compose as compose4,
|
|
2414
2604
|
rotate as rotate4,
|
|
2415
2605
|
toString as matrixToString7,
|
|
@@ -2417,11 +2607,11 @@ import {
|
|
|
2417
2607
|
} from "transformation-matrix";
|
|
2418
2608
|
|
|
2419
2609
|
// lib/utils/ring-to-path-d.ts
|
|
2420
|
-
import { applyToPoint as
|
|
2610
|
+
import { applyToPoint as applyToPoint25 } from "transformation-matrix";
|
|
2421
2611
|
function ringToPathD(vertices, transform) {
|
|
2422
2612
|
if (vertices.length === 0) return "";
|
|
2423
2613
|
const transformedVertices = vertices.map((v) => {
|
|
2424
|
-
const [x, y] =
|
|
2614
|
+
const [x, y] = applyToPoint25(transform, [v.x, v.y]);
|
|
2425
2615
|
return { ...v, x, y };
|
|
2426
2616
|
});
|
|
2427
2617
|
let d = `M ${transformedVertices[0].x} ${transformedVertices[0].y}`;
|
|
@@ -2454,7 +2644,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
2454
2644
|
const color = layerNameToColor(layer, colorMap2);
|
|
2455
2645
|
const opacity = "0.5";
|
|
2456
2646
|
if (pour.shape === "rect") {
|
|
2457
|
-
const [cx, cy] =
|
|
2647
|
+
const [cx, cy] = applyToPoint26(transform, [pour.center.x, pour.center.y]);
|
|
2458
2648
|
const scaledWidth = pour.width * Math.abs(transform.a);
|
|
2459
2649
|
const scaledHeight = pour.height * Math.abs(transform.d);
|
|
2460
2650
|
const svgRotation = -(pour.rotation ?? 0);
|
|
@@ -2484,7 +2674,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
2484
2674
|
if (pour.shape === "polygon") {
|
|
2485
2675
|
if (!pour.points || pour.points.length === 0) return [];
|
|
2486
2676
|
const transformedPoints = pour.points.map(
|
|
2487
|
-
(p) =>
|
|
2677
|
+
(p) => applyToPoint26(transform, [p.x, p.y])
|
|
2488
2678
|
);
|
|
2489
2679
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
2490
2680
|
return [
|
|
@@ -2669,11 +2859,11 @@ function createMajorGridPatternChildren(cellSize, majorCellSize, lineColor, majo
|
|
|
2669
2859
|
}
|
|
2670
2860
|
|
|
2671
2861
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-component.ts
|
|
2672
|
-
import { applyToPoint as
|
|
2862
|
+
import { applyToPoint as applyToPoint27 } from "transformation-matrix";
|
|
2673
2863
|
function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
2674
2864
|
const { transform } = ctx;
|
|
2675
2865
|
const { center, width, height, rotation = 0 } = component;
|
|
2676
|
-
const [x, y] =
|
|
2866
|
+
const [x, y] = applyToPoint27(transform, [center.x, center.y]);
|
|
2677
2867
|
const scaledWidth = width * Math.abs(transform.a);
|
|
2678
2868
|
const scaledHeight = height * Math.abs(transform.d);
|
|
2679
2869
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
@@ -2723,7 +2913,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
2723
2913
|
var package_default = {
|
|
2724
2914
|
name: "circuit-to-svg",
|
|
2725
2915
|
type: "module",
|
|
2726
|
-
version: "0.0.
|
|
2916
|
+
version: "0.0.235",
|
|
2727
2917
|
description: "Convert Circuit JSON to SVG",
|
|
2728
2918
|
main: "dist/index.js",
|
|
2729
2919
|
files: [
|
|
@@ -2747,7 +2937,7 @@ var package_default = {
|
|
|
2747
2937
|
"bun-match-svg": "^0.0.12",
|
|
2748
2938
|
esbuild: "^0.20.2",
|
|
2749
2939
|
"performance-now": "^2.1.0",
|
|
2750
|
-
"circuit-json": "^0.0.
|
|
2940
|
+
"circuit-json": "^0.0.278",
|
|
2751
2941
|
react: "19.1.0",
|
|
2752
2942
|
"react-cosmos": "7.0.0",
|
|
2753
2943
|
"react-cosmos-plugin-vite": "7.0.0",
|
|
@@ -2793,6 +2983,7 @@ var TYPE_PRIORITY = {
|
|
|
2793
2983
|
pcb_fabrication_note_text: 70,
|
|
2794
2984
|
pcb_fabrication_note_path: 70,
|
|
2795
2985
|
pcb_fabrication_note_rect: 70,
|
|
2986
|
+
pcb_fabrication_note_dimension: 70,
|
|
2796
2987
|
pcb_note_dimension: 70,
|
|
2797
2988
|
pcb_note_text: 70,
|
|
2798
2989
|
pcb_note_rect: 70,
|
|
@@ -3180,6 +3371,8 @@ function createSvgObjects({
|
|
|
3180
3371
|
return createSvgObjectsFromPcbFabricationNoteText(elm, ctx);
|
|
3181
3372
|
case "pcb_fabrication_note_rect":
|
|
3182
3373
|
return createSvgObjectsFromPcbFabricationNoteRect(elm, ctx);
|
|
3374
|
+
case "pcb_fabrication_note_dimension":
|
|
3375
|
+
return createSvgObjectsFromPcbFabricationNoteDimension(elm, ctx);
|
|
3183
3376
|
case "pcb_note_dimension":
|
|
3184
3377
|
return createSvgObjectsFromPcbNoteDimension(elm, ctx);
|
|
3185
3378
|
case "pcb_note_text":
|
|
@@ -3203,8 +3396,8 @@ function createSvgObjects({
|
|
|
3203
3396
|
}
|
|
3204
3397
|
}
|
|
3205
3398
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
3206
|
-
const [x1, y1] =
|
|
3207
|
-
const [x2, y2] =
|
|
3399
|
+
const [x1, y1] = applyToPoint28(transform, [minX, minY]);
|
|
3400
|
+
const [x2, y2] = applyToPoint28(transform, [maxX, maxY]);
|
|
3208
3401
|
const width = Math.abs(x2 - x1);
|
|
3209
3402
|
const height = Math.abs(y2 - y1);
|
|
3210
3403
|
const x = Math.min(x1, x2);
|
|
@@ -3234,14 +3427,14 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
3234
3427
|
import { stringify as stringify2 } from "svgson";
|
|
3235
3428
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
3236
3429
|
import {
|
|
3237
|
-
applyToPoint as
|
|
3430
|
+
applyToPoint as applyToPoint35,
|
|
3238
3431
|
compose as compose6,
|
|
3239
3432
|
scale as scale3,
|
|
3240
3433
|
translate as translate6
|
|
3241
3434
|
} from "transformation-matrix";
|
|
3242
3435
|
|
|
3243
3436
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
3244
|
-
import { applyToPoint as
|
|
3437
|
+
import { applyToPoint as applyToPoint29 } from "transformation-matrix";
|
|
3245
3438
|
var DEFAULT_BOARD_STYLE = {
|
|
3246
3439
|
fill: "none",
|
|
3247
3440
|
stroke: "rgb(0,0,0)",
|
|
@@ -3253,25 +3446,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
3253
3446
|
let path;
|
|
3254
3447
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
3255
3448
|
path = outline.map((point, index) => {
|
|
3256
|
-
const [x, y] =
|
|
3449
|
+
const [x, y] = applyToPoint29(transform, [point.x, point.y]);
|
|
3257
3450
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
3258
3451
|
}).join(" ");
|
|
3259
3452
|
} else {
|
|
3260
3453
|
const halfWidth = width / 2;
|
|
3261
3454
|
const halfHeight = height / 2;
|
|
3262
|
-
const topLeft =
|
|
3455
|
+
const topLeft = applyToPoint29(transform, [
|
|
3263
3456
|
center.x - halfWidth,
|
|
3264
3457
|
center.y - halfHeight
|
|
3265
3458
|
]);
|
|
3266
|
-
const topRight =
|
|
3459
|
+
const topRight = applyToPoint29(transform, [
|
|
3267
3460
|
center.x + halfWidth,
|
|
3268
3461
|
center.y - halfHeight
|
|
3269
3462
|
]);
|
|
3270
|
-
const bottomRight =
|
|
3463
|
+
const bottomRight = applyToPoint29(transform, [
|
|
3271
3464
|
center.x + halfWidth,
|
|
3272
3465
|
center.y + halfHeight
|
|
3273
3466
|
]);
|
|
3274
|
-
const bottomLeft =
|
|
3467
|
+
const bottomLeft = applyToPoint29(transform, [
|
|
3275
3468
|
center.x - halfWidth,
|
|
3276
3469
|
center.y + halfHeight
|
|
3277
3470
|
]);
|
|
@@ -3297,7 +3490,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
3297
3490
|
}
|
|
3298
3491
|
|
|
3299
3492
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
3300
|
-
import { applyToPoint as
|
|
3493
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
3301
3494
|
|
|
3302
3495
|
// lib/utils/get-sch-font-size.ts
|
|
3303
3496
|
import "transformation-matrix";
|
|
@@ -3323,8 +3516,8 @@ function createSvgObjectsFromAssemblyComponent(params, ctx) {
|
|
|
3323
3516
|
const { center, width, height, rotation = 0, layer = "top" } = elm;
|
|
3324
3517
|
if (!center || typeof width !== "number" || typeof height !== "number")
|
|
3325
3518
|
return null;
|
|
3326
|
-
const [x, y] =
|
|
3327
|
-
const [pinX, pinY] =
|
|
3519
|
+
const [x, y] = applyToPoint31(transform, [center.x, center.y]);
|
|
3520
|
+
const [pinX, pinY] = applyToPoint31(transform, [portPosition.x, portPosition.y]);
|
|
3328
3521
|
const scaledWidth = width * Math.abs(transform.a);
|
|
3329
3522
|
const scaledHeight = height * Math.abs(transform.d);
|
|
3330
3523
|
const isTopLayer = layer === "top";
|
|
@@ -3486,11 +3679,11 @@ function getRectPathData(w, h, rotation) {
|
|
|
3486
3679
|
}
|
|
3487
3680
|
|
|
3488
3681
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-hole.ts
|
|
3489
|
-
import { applyToPoint as
|
|
3682
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
3490
3683
|
var HOLE_COLOR2 = "rgb(190, 190, 190)";
|
|
3491
3684
|
function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
3492
3685
|
const { transform } = ctx;
|
|
3493
|
-
const [x, y] =
|
|
3686
|
+
const [x, y] = applyToPoint32(transform, [hole.x, hole.y]);
|
|
3494
3687
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
3495
3688
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
3496
3689
|
const radius = scaledDiameter / 2;
|
|
@@ -3554,12 +3747,12 @@ function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
|
3554
3747
|
}
|
|
3555
3748
|
|
|
3556
3749
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-plated-hole.ts
|
|
3557
|
-
import { applyToPoint as
|
|
3750
|
+
import { applyToPoint as applyToPoint33 } from "transformation-matrix";
|
|
3558
3751
|
var PAD_COLOR = "rgb(210, 210, 210)";
|
|
3559
3752
|
var HOLE_COLOR3 = "rgb(190, 190, 190)";
|
|
3560
3753
|
function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
3561
3754
|
const { transform } = ctx;
|
|
3562
|
-
const [x, y] =
|
|
3755
|
+
const [x, y] = applyToPoint33(transform, [hole.x, hole.y]);
|
|
3563
3756
|
if (hole.shape === "pill") {
|
|
3564
3757
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
3565
3758
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -3654,7 +3847,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3654
3847
|
const scaledRectPadHeight = circularHole.rect_pad_height * Math.abs(transform.a);
|
|
3655
3848
|
const scaledRectBorderRadius = (circularHole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
3656
3849
|
const holeRadius = scaledHoleDiameter / 2;
|
|
3657
|
-
const [holeCx, holeCy] =
|
|
3850
|
+
const [holeCx, holeCy] = applyToPoint33(transform, [
|
|
3658
3851
|
circularHole.x + circularHole.hole_offset_x,
|
|
3659
3852
|
circularHole.y + circularHole.hole_offset_y
|
|
3660
3853
|
]);
|
|
@@ -3712,7 +3905,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3712
3905
|
const pillHoleWithOffsets = pillHole;
|
|
3713
3906
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
3714
3907
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
3715
|
-
const [holeCenterX, holeCenterY] =
|
|
3908
|
+
const [holeCenterX, holeCenterY] = applyToPoint33(transform, [
|
|
3716
3909
|
pillHole.x + holeOffsetX,
|
|
3717
3910
|
pillHole.y + holeOffsetY
|
|
3718
3911
|
]);
|
|
@@ -3774,7 +3967,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3774
3967
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
3775
3968
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
3776
3969
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
3777
|
-
const [holeCenterX, holeCenterY] =
|
|
3970
|
+
const [holeCenterX, holeCenterY] = applyToPoint33(transform, [
|
|
3778
3971
|
rotatedHole.x + holeOffsetX,
|
|
3779
3972
|
rotatedHole.y + holeOffsetY
|
|
3780
3973
|
]);
|
|
@@ -3830,14 +4023,14 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
3830
4023
|
}
|
|
3831
4024
|
|
|
3832
4025
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-smt-pad.ts
|
|
3833
|
-
import { applyToPoint as
|
|
4026
|
+
import { applyToPoint as applyToPoint34 } from "transformation-matrix";
|
|
3834
4027
|
var PAD_COLOR2 = "rgb(210, 210, 210)";
|
|
3835
4028
|
function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
3836
4029
|
const { transform } = ctx;
|
|
3837
4030
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
3838
4031
|
const width = pad.width * Math.abs(transform.a);
|
|
3839
4032
|
const height = pad.height * Math.abs(transform.d);
|
|
3840
|
-
const [x, y] =
|
|
4033
|
+
const [x, y] = applyToPoint34(transform, [pad.x, pad.y]);
|
|
3841
4034
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
3842
4035
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
3843
4036
|
return [
|
|
@@ -3889,7 +4082,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3889
4082
|
const width = pad.width * Math.abs(transform.a);
|
|
3890
4083
|
const height = pad.height * Math.abs(transform.d);
|
|
3891
4084
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3892
|
-
const [x, y] =
|
|
4085
|
+
const [x, y] = applyToPoint34(transform, [pad.x, pad.y]);
|
|
3893
4086
|
return [
|
|
3894
4087
|
{
|
|
3895
4088
|
name: "rect",
|
|
@@ -3912,7 +4105,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3912
4105
|
}
|
|
3913
4106
|
if (pad.shape === "circle") {
|
|
3914
4107
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3915
|
-
const [x, y] =
|
|
4108
|
+
const [x, y] = applyToPoint34(transform, [pad.x, pad.y]);
|
|
3916
4109
|
return [
|
|
3917
4110
|
{
|
|
3918
4111
|
name: "circle",
|
|
@@ -3932,7 +4125,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3932
4125
|
}
|
|
3933
4126
|
if (pad.shape === "polygon") {
|
|
3934
4127
|
const points = (pad.points ?? []).map(
|
|
3935
|
-
(point) =>
|
|
4128
|
+
(point) => applyToPoint34(transform, [point.x, point.y])
|
|
3936
4129
|
);
|
|
3937
4130
|
return [
|
|
3938
4131
|
{
|
|
@@ -4109,8 +4302,8 @@ function createSvgObjects2(elm, ctx, soup) {
|
|
|
4109
4302
|
}
|
|
4110
4303
|
}
|
|
4111
4304
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
4112
|
-
const [x1, y1] =
|
|
4113
|
-
const [x2, y2] =
|
|
4305
|
+
const [x1, y1] = applyToPoint35(transform, [minX, minY]);
|
|
4306
|
+
const [x2, y2] = applyToPoint35(transform, [maxX, maxY]);
|
|
4114
4307
|
const width = Math.abs(x2 - x1);
|
|
4115
4308
|
const height = Math.abs(y2 - y1);
|
|
4116
4309
|
const x = Math.min(x1, x2);
|
|
@@ -4139,7 +4332,7 @@ import {
|
|
|
4139
4332
|
} from "transformation-matrix";
|
|
4140
4333
|
|
|
4141
4334
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-board.ts
|
|
4142
|
-
import { applyToPoint as
|
|
4335
|
+
import { applyToPoint as applyToPoint36 } from "transformation-matrix";
|
|
4143
4336
|
import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
4144
4337
|
var BOARD_FILL_COLOR = "rgb(26, 115, 143)";
|
|
4145
4338
|
var BOARD_STROKE_COLOR = "rgba(0,0,0,0.9)";
|
|
@@ -4149,25 +4342,25 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4149
4342
|
let path;
|
|
4150
4343
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
4151
4344
|
path = outline.map((point, index) => {
|
|
4152
|
-
const [x, y] =
|
|
4345
|
+
const [x, y] = applyToPoint36(transform, [point.x, point.y]);
|
|
4153
4346
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
4154
4347
|
}).join(" ");
|
|
4155
4348
|
} else {
|
|
4156
4349
|
const halfWidth = width / 2;
|
|
4157
4350
|
const halfHeight = height / 2;
|
|
4158
|
-
const topLeft =
|
|
4351
|
+
const topLeft = applyToPoint36(transform, [
|
|
4159
4352
|
center.x - halfWidth,
|
|
4160
4353
|
center.y - halfHeight
|
|
4161
4354
|
]);
|
|
4162
|
-
const topRight =
|
|
4355
|
+
const topRight = applyToPoint36(transform, [
|
|
4163
4356
|
center.x + halfWidth,
|
|
4164
4357
|
center.y - halfHeight
|
|
4165
4358
|
]);
|
|
4166
|
-
const bottomRight =
|
|
4359
|
+
const bottomRight = applyToPoint36(transform, [
|
|
4167
4360
|
center.x + halfWidth,
|
|
4168
4361
|
center.y + halfHeight
|
|
4169
4362
|
]);
|
|
4170
|
-
const bottomLeft =
|
|
4363
|
+
const bottomLeft = applyToPoint36(transform, [
|
|
4171
4364
|
center.x - halfWidth,
|
|
4172
4365
|
center.y + halfHeight
|
|
4173
4366
|
]);
|
|
@@ -4185,10 +4378,10 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4185
4378
|
const halfWidth = width2 / 2;
|
|
4186
4379
|
const halfHeight = height2 / 2;
|
|
4187
4380
|
const [tl, tr, br, bl] = [
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4381
|
+
applyToPoint36(transform, [x - halfWidth, y - halfHeight]),
|
|
4382
|
+
applyToPoint36(transform, [x + halfWidth, y - halfHeight]),
|
|
4383
|
+
applyToPoint36(transform, [x + halfWidth, y + halfHeight]),
|
|
4384
|
+
applyToPoint36(transform, [x - halfWidth, y + halfHeight])
|
|
4192
4385
|
];
|
|
4193
4386
|
path += ` M ${tl[0]} ${tl[1]} L ${tr[0]} ${tr[1]} L ${br[0]} ${br[1]} L ${bl[0]} ${bl[1]} Z`;
|
|
4194
4387
|
} else if (cutout.shape === "circle") {
|
|
@@ -4215,7 +4408,7 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4215
4408
|
|
|
4216
4409
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-component.ts
|
|
4217
4410
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
4218
|
-
import { applyToPoint as
|
|
4411
|
+
import { applyToPoint as applyToPoint37 } from "transformation-matrix";
|
|
4219
4412
|
var COMPONENT_FILL_COLOR = "rgba(120, 120, 120, 0.6)";
|
|
4220
4413
|
var COMPONENT_LABEL_COLOR = "rgba(255, 255, 255, 0.9)";
|
|
4221
4414
|
function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
@@ -4225,7 +4418,7 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
4225
4418
|
if (!center || typeof width !== "number" || typeof height !== "number" || width === 0 || height === 0) {
|
|
4226
4419
|
return [];
|
|
4227
4420
|
}
|
|
4228
|
-
const [x, y] =
|
|
4421
|
+
const [x, y] = applyToPoint37(transform, [center.x, center.y]);
|
|
4229
4422
|
const scaledWidth = width * Math.abs(transform.a);
|
|
4230
4423
|
const scaledHeight = height * Math.abs(transform.d);
|
|
4231
4424
|
const transformStr = `translate(${x}, ${y})`;
|
|
@@ -4286,11 +4479,11 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
4286
4479
|
}
|
|
4287
4480
|
|
|
4288
4481
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-hole.ts
|
|
4289
|
-
import { applyToPoint as
|
|
4482
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
4290
4483
|
var HOLE_COLOR4 = "rgb(50, 50, 50)";
|
|
4291
4484
|
function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
4292
4485
|
const { transform } = ctx;
|
|
4293
|
-
const [x, y] =
|
|
4486
|
+
const [x, y] = applyToPoint38(transform, [hole.x, hole.y]);
|
|
4294
4487
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
4295
4488
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
4296
4489
|
const radius = scaledDiameter / 2;
|
|
@@ -4354,12 +4547,12 @@ function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
|
4354
4547
|
}
|
|
4355
4548
|
|
|
4356
4549
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-plated-hole.ts
|
|
4357
|
-
import { applyToPoint as
|
|
4550
|
+
import { applyToPoint as applyToPoint39 } from "transformation-matrix";
|
|
4358
4551
|
var PAD_COLOR3 = "rgb(218, 165, 32)";
|
|
4359
4552
|
var HOLE_COLOR5 = "rgb(40, 40, 40)";
|
|
4360
4553
|
function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
4361
4554
|
const { transform } = ctx;
|
|
4362
|
-
const [x, y] =
|
|
4555
|
+
const [x, y] = applyToPoint39(transform, [hole.x, hole.y]);
|
|
4363
4556
|
if (hole.shape === "pill") {
|
|
4364
4557
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
4365
4558
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -4594,14 +4787,14 @@ function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
|
4594
4787
|
}
|
|
4595
4788
|
|
|
4596
4789
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-smt-pad.ts
|
|
4597
|
-
import { applyToPoint as
|
|
4790
|
+
import { applyToPoint as applyToPoint40 } from "transformation-matrix";
|
|
4598
4791
|
var PAD_COLOR4 = "rgb(218, 165, 32)";
|
|
4599
4792
|
function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
4600
4793
|
const { transform } = ctx;
|
|
4601
4794
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
4602
4795
|
const width = pad.width * Math.abs(transform.a);
|
|
4603
4796
|
const height = pad.height * Math.abs(transform.d);
|
|
4604
|
-
const [x, y] =
|
|
4797
|
+
const [x, y] = applyToPoint40(transform, [pad.x, pad.y]);
|
|
4605
4798
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
4606
4799
|
return [
|
|
4607
4800
|
{
|
|
@@ -4644,7 +4837,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4644
4837
|
const width = pad.width * Math.abs(transform.a);
|
|
4645
4838
|
const height = pad.height * Math.abs(transform.d);
|
|
4646
4839
|
const radius = pad.radius * Math.abs(transform.a);
|
|
4647
|
-
const [x, y] =
|
|
4840
|
+
const [x, y] = applyToPoint40(transform, [pad.x, pad.y]);
|
|
4648
4841
|
return [
|
|
4649
4842
|
{
|
|
4650
4843
|
name: "rect",
|
|
@@ -4667,7 +4860,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4667
4860
|
}
|
|
4668
4861
|
if (pad.shape === "circle") {
|
|
4669
4862
|
const radius = pad.radius * Math.abs(transform.a);
|
|
4670
|
-
const [x, y] =
|
|
4863
|
+
const [x, y] = applyToPoint40(transform, [pad.x, pad.y]);
|
|
4671
4864
|
return [
|
|
4672
4865
|
{
|
|
4673
4866
|
name: "circle",
|
|
@@ -4687,7 +4880,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4687
4880
|
}
|
|
4688
4881
|
if (pad.shape === "polygon") {
|
|
4689
4882
|
const points = (pad.points ?? []).map(
|
|
4690
|
-
(point) =>
|
|
4883
|
+
(point) => applyToPoint40(transform, [point.x, point.y])
|
|
4691
4884
|
);
|
|
4692
4885
|
return [
|
|
4693
4886
|
{
|
|
@@ -4708,7 +4901,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
4708
4901
|
}
|
|
4709
4902
|
|
|
4710
4903
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-port.ts
|
|
4711
|
-
import { applyToPoint as
|
|
4904
|
+
import { applyToPoint as applyToPoint41 } from "transformation-matrix";
|
|
4712
4905
|
import { calculateElbow } from "calculate-elbow";
|
|
4713
4906
|
|
|
4714
4907
|
// lib/pinout/svg-object-fns/pinout-label-box.ts
|
|
@@ -4785,7 +4978,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
4785
4978
|
const label_info = ctx.label_positions.get(pcb_port.pcb_port_id);
|
|
4786
4979
|
if (!label_info) return [];
|
|
4787
4980
|
const { text: label, aliases, elbow_end, label_pos, edge } = label_info;
|
|
4788
|
-
const [port_x, port_y] =
|
|
4981
|
+
const [port_x, port_y] = applyToPoint41(ctx.transform, [pcb_port.x, pcb_port.y]);
|
|
4789
4982
|
const start_facing_direction = edge === "left" ? "x-" : edge === "right" ? "x+" : edge === "top" ? "y-" : "y+";
|
|
4790
4983
|
const end_facing_direction = edge === "left" ? "x+" : edge === "right" ? "x-" : edge === "top" ? "y+" : "y-";
|
|
4791
4984
|
const elbow_path = calculateElbow(
|
|
@@ -4926,7 +5119,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
4926
5119
|
}
|
|
4927
5120
|
|
|
4928
5121
|
// lib/pinout/calculate-label-positions.ts
|
|
4929
|
-
import { applyToPoint as
|
|
5122
|
+
import { applyToPoint as applyToPoint42 } from "transformation-matrix";
|
|
4930
5123
|
|
|
4931
5124
|
// lib/pinout/constants.ts
|
|
4932
5125
|
var LABEL_RECT_HEIGHT_BASE_MM = 1.6;
|
|
@@ -4964,7 +5157,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4964
5157
|
);
|
|
4965
5158
|
const mapToEdgePort = (pinout_label) => ({
|
|
4966
5159
|
pcb_port: pinout_label.pcb_port,
|
|
4967
|
-
y:
|
|
5160
|
+
y: applyToPoint42(transform, [
|
|
4968
5161
|
pinout_label.pcb_port.x,
|
|
4969
5162
|
pinout_label.pcb_port.y
|
|
4970
5163
|
])[1],
|
|
@@ -4979,7 +5172,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4979
5172
|
} else {
|
|
4980
5173
|
edge_ports = pinout_labels.map((pinout_label) => ({
|
|
4981
5174
|
pcb_port: pinout_label.pcb_port,
|
|
4982
|
-
y:
|
|
5175
|
+
y: applyToPoint42(transform, [
|
|
4983
5176
|
pinout_label.pcb_port.x,
|
|
4984
5177
|
pinout_label.pcb_port.y
|
|
4985
5178
|
])[1],
|
|
@@ -4987,7 +5180,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4987
5180
|
})).sort((a, b) => a.y - b.y);
|
|
4988
5181
|
}
|
|
4989
5182
|
if (edge_ports.length === 0) return;
|
|
4990
|
-
const board_edge_x =
|
|
5183
|
+
const board_edge_x = applyToPoint42(transform, [
|
|
4991
5184
|
edge === "left" ? board_bounds.minX : board_bounds.maxX,
|
|
4992
5185
|
0
|
|
4993
5186
|
])[0];
|
|
@@ -5636,14 +5829,14 @@ import {
|
|
|
5636
5829
|
} from "transformation-matrix";
|
|
5637
5830
|
|
|
5638
5831
|
// lib/sch/draw-schematic-grid.ts
|
|
5639
|
-
import { applyToPoint as
|
|
5832
|
+
import { applyToPoint as applyToPoint43 } from "transformation-matrix";
|
|
5640
5833
|
function drawSchematicGrid(params) {
|
|
5641
5834
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
5642
5835
|
const cellSize = params.cellSize ?? 1;
|
|
5643
5836
|
const labelCells = params.labelCells ?? false;
|
|
5644
5837
|
const gridLines = [];
|
|
5645
5838
|
const transformPoint = (x, y) => {
|
|
5646
|
-
const [transformedX, transformedY] =
|
|
5839
|
+
const [transformedX, transformedY] = applyToPoint43(params.transform, [x, y]);
|
|
5647
5840
|
return { x: transformedX, y: transformedY };
|
|
5648
5841
|
};
|
|
5649
5842
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -5724,15 +5917,15 @@ function drawSchematicGrid(params) {
|
|
|
5724
5917
|
}
|
|
5725
5918
|
|
|
5726
5919
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
5727
|
-
import { applyToPoint as
|
|
5920
|
+
import { applyToPoint as applyToPoint44 } from "transformation-matrix";
|
|
5728
5921
|
function drawSchematicLabeledPoints(params) {
|
|
5729
5922
|
const { points, transform } = params;
|
|
5730
5923
|
const labeledPointsGroup = [];
|
|
5731
5924
|
for (const point of points) {
|
|
5732
|
-
const [x1, y1] =
|
|
5733
|
-
const [x2, y2] =
|
|
5734
|
-
const [x3, y3] =
|
|
5735
|
-
const [x4, y4] =
|
|
5925
|
+
const [x1, y1] = applyToPoint44(transform, [point.x - 0.1, point.y - 0.1]);
|
|
5926
|
+
const [x2, y2] = applyToPoint44(transform, [point.x + 0.1, point.y + 0.1]);
|
|
5927
|
+
const [x3, y3] = applyToPoint44(transform, [point.x - 0.1, point.y + 0.1]);
|
|
5928
|
+
const [x4, y4] = applyToPoint44(transform, [point.x + 0.1, point.y - 0.1]);
|
|
5736
5929
|
labeledPointsGroup.push({
|
|
5737
5930
|
name: "path",
|
|
5738
5931
|
type: "element",
|
|
@@ -5743,7 +5936,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
5743
5936
|
"stroke-opacity": "0.7"
|
|
5744
5937
|
}
|
|
5745
5938
|
});
|
|
5746
|
-
const [labelX, labelY] =
|
|
5939
|
+
const [labelX, labelY] = applyToPoint44(transform, [
|
|
5747
5940
|
point.x + 0.15,
|
|
5748
5941
|
point.y - 0.15
|
|
5749
5942
|
]);
|
|
@@ -6837,7 +7030,7 @@ import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
|
6837
7030
|
import { symbols } from "schematic-symbols";
|
|
6838
7031
|
import "svgson";
|
|
6839
7032
|
import {
|
|
6840
|
-
applyToPoint as
|
|
7033
|
+
applyToPoint as applyToPoint46,
|
|
6841
7034
|
compose as compose9
|
|
6842
7035
|
} from "transformation-matrix";
|
|
6843
7036
|
|
|
@@ -6921,13 +7114,13 @@ function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
|
6921
7114
|
}
|
|
6922
7115
|
|
|
6923
7116
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
6924
|
-
import { applyToPoint as
|
|
7117
|
+
import { applyToPoint as applyToPoint45 } from "transformation-matrix";
|
|
6925
7118
|
var createSvgSchErrorText = ({
|
|
6926
7119
|
text,
|
|
6927
7120
|
realCenter,
|
|
6928
7121
|
realToScreenTransform
|
|
6929
7122
|
}) => {
|
|
6930
|
-
const screenCenter =
|
|
7123
|
+
const screenCenter = applyToPoint45(realToScreenTransform, realCenter);
|
|
6931
7124
|
return {
|
|
6932
7125
|
type: "element",
|
|
6933
7126
|
name: "text",
|
|
@@ -7036,11 +7229,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7036
7229
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
7037
7230
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
7038
7231
|
};
|
|
7039
|
-
const [screenMinX, screenMinY] =
|
|
7232
|
+
const [screenMinX, screenMinY] = applyToPoint46(
|
|
7040
7233
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7041
7234
|
[bounds.minX, bounds.minY]
|
|
7042
7235
|
);
|
|
7043
|
-
const [screenMaxX, screenMaxY] =
|
|
7236
|
+
const [screenMaxX, screenMaxY] = applyToPoint46(
|
|
7044
7237
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7045
7238
|
[bounds.maxX, bounds.maxY]
|
|
7046
7239
|
);
|
|
@@ -7069,7 +7262,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7069
7262
|
name: "path",
|
|
7070
7263
|
attributes: {
|
|
7071
7264
|
d: points.map((p, i) => {
|
|
7072
|
-
const [x, y] =
|
|
7265
|
+
const [x, y] = applyToPoint46(
|
|
7073
7266
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7074
7267
|
[p.x, p.y]
|
|
7075
7268
|
);
|
|
@@ -7085,7 +7278,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7085
7278
|
});
|
|
7086
7279
|
}
|
|
7087
7280
|
for (const text of texts) {
|
|
7088
|
-
const screenTextPos =
|
|
7281
|
+
const screenTextPos = applyToPoint46(
|
|
7089
7282
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7090
7283
|
text
|
|
7091
7284
|
);
|
|
@@ -7137,7 +7330,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7137
7330
|
});
|
|
7138
7331
|
}
|
|
7139
7332
|
for (const box of boxes) {
|
|
7140
|
-
const screenBoxPos =
|
|
7333
|
+
const screenBoxPos = applyToPoint46(
|
|
7141
7334
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7142
7335
|
box
|
|
7143
7336
|
);
|
|
@@ -7161,7 +7354,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7161
7354
|
}
|
|
7162
7355
|
for (const port of symbol.ports) {
|
|
7163
7356
|
if (connectedSymbolPorts.has(port)) continue;
|
|
7164
|
-
const screenPortPos =
|
|
7357
|
+
const screenPortPos = applyToPoint46(
|
|
7165
7358
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7166
7359
|
port
|
|
7167
7360
|
);
|
|
@@ -7181,7 +7374,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7181
7374
|
});
|
|
7182
7375
|
}
|
|
7183
7376
|
for (const circle of circles) {
|
|
7184
|
-
const screenCirclePos =
|
|
7377
|
+
const screenCirclePos = applyToPoint46(
|
|
7185
7378
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7186
7379
|
circle
|
|
7187
7380
|
);
|
|
@@ -7208,14 +7401,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7208
7401
|
import { su as su10 } from "@tscircuit/circuit-json-util";
|
|
7209
7402
|
import "schematic-symbols";
|
|
7210
7403
|
import "svgson";
|
|
7211
|
-
import { applyToPoint as
|
|
7404
|
+
import { applyToPoint as applyToPoint52 } from "transformation-matrix";
|
|
7212
7405
|
|
|
7213
7406
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
7214
7407
|
import "transformation-matrix";
|
|
7215
7408
|
import "@tscircuit/circuit-json-util";
|
|
7216
7409
|
|
|
7217
7410
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
7218
|
-
import { applyToPoint as
|
|
7411
|
+
import { applyToPoint as applyToPoint47 } from "transformation-matrix";
|
|
7219
7412
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
7220
7413
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
7221
7414
|
var createArrow = (tip, angle, size, color, strokeWidth) => {
|
|
@@ -7268,8 +7461,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7268
7461
|
realEdgePos.y += realPinLineLength;
|
|
7269
7462
|
break;
|
|
7270
7463
|
}
|
|
7271
|
-
const screenSchPortPos =
|
|
7272
|
-
const screenRealEdgePos =
|
|
7464
|
+
const screenSchPortPos = applyToPoint47(transform, schPort.center);
|
|
7465
|
+
const screenRealEdgePos = applyToPoint47(transform, realEdgePos);
|
|
7273
7466
|
const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
|
|
7274
7467
|
const realLineEnd = { ...schPort.center };
|
|
7275
7468
|
if (!isConnected) {
|
|
@@ -7288,7 +7481,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7288
7481
|
break;
|
|
7289
7482
|
}
|
|
7290
7483
|
}
|
|
7291
|
-
const screenLineEnd =
|
|
7484
|
+
const screenLineEnd = applyToPoint47(transform, realLineEnd);
|
|
7292
7485
|
svgObjects.push({
|
|
7293
7486
|
name: "line",
|
|
7294
7487
|
type: "element",
|
|
@@ -7409,7 +7602,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7409
7602
|
};
|
|
7410
7603
|
|
|
7411
7604
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
7412
|
-
import { applyToPoint as
|
|
7605
|
+
import { applyToPoint as applyToPoint48 } from "transformation-matrix";
|
|
7413
7606
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
7414
7607
|
const svgObjects = [];
|
|
7415
7608
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -7427,7 +7620,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
7427
7620
|
} else {
|
|
7428
7621
|
realPinNumberPos.y += 0.02;
|
|
7429
7622
|
}
|
|
7430
|
-
const screenPinNumberTextPos =
|
|
7623
|
+
const screenPinNumberTextPos = applyToPoint48(transform, realPinNumberPos);
|
|
7431
7624
|
svgObjects.push({
|
|
7432
7625
|
name: "text",
|
|
7433
7626
|
type: "element",
|
|
@@ -7457,7 +7650,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
7457
7650
|
};
|
|
7458
7651
|
|
|
7459
7652
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
7460
|
-
import { applyToPoint as
|
|
7653
|
+
import { applyToPoint as applyToPoint49 } from "transformation-matrix";
|
|
7461
7654
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
7462
7655
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
7463
7656
|
const svgObjects = [];
|
|
@@ -7471,7 +7664,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
7471
7664
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
7472
7665
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
7473
7666
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
7474
|
-
const screenPinNumberTextPos =
|
|
7667
|
+
const screenPinNumberTextPos = applyToPoint49(transform, realPinNumberPos);
|
|
7475
7668
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
7476
7669
|
if (!label) return [];
|
|
7477
7670
|
const isNegated = label.startsWith("N_");
|
|
@@ -7519,13 +7712,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
7519
7712
|
};
|
|
7520
7713
|
|
|
7521
7714
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
7522
|
-
import { applyToPoint as
|
|
7715
|
+
import { applyToPoint as applyToPoint51 } from "transformation-matrix";
|
|
7523
7716
|
var createSvgSchText = ({
|
|
7524
7717
|
elm,
|
|
7525
7718
|
transform,
|
|
7526
7719
|
colorMap: colorMap2
|
|
7527
7720
|
}) => {
|
|
7528
|
-
const center =
|
|
7721
|
+
const center = applyToPoint51(transform, elm.position);
|
|
7529
7722
|
const textAnchorMap = {
|
|
7530
7723
|
center: "middle",
|
|
7531
7724
|
center_right: "end",
|
|
@@ -7609,11 +7802,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
7609
7802
|
colorMap: colorMap2
|
|
7610
7803
|
}) => {
|
|
7611
7804
|
const svgObjects = [];
|
|
7612
|
-
const componentScreenTopLeft =
|
|
7805
|
+
const componentScreenTopLeft = applyToPoint52(transform, {
|
|
7613
7806
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
7614
7807
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
7615
7808
|
});
|
|
7616
|
-
const componentScreenBottomRight =
|
|
7809
|
+
const componentScreenBottomRight = applyToPoint52(transform, {
|
|
7617
7810
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
7618
7811
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
7619
7812
|
});
|
|
@@ -7699,13 +7892,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
7699
7892
|
}
|
|
7700
7893
|
|
|
7701
7894
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
7702
|
-
import { applyToPoint as
|
|
7895
|
+
import { applyToPoint as applyToPoint53 } from "transformation-matrix";
|
|
7703
7896
|
function createSvgObjectsFromSchVoltageProbe({
|
|
7704
7897
|
probe,
|
|
7705
7898
|
transform,
|
|
7706
7899
|
colorMap: colorMap2
|
|
7707
7900
|
}) {
|
|
7708
|
-
const [screenX, screenY] =
|
|
7901
|
+
const [screenX, screenY] = applyToPoint53(transform, [
|
|
7709
7902
|
probe.position.x,
|
|
7710
7903
|
probe.position.y
|
|
7711
7904
|
]);
|
|
@@ -7765,17 +7958,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
7765
7958
|
}
|
|
7766
7959
|
|
|
7767
7960
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
7768
|
-
import { applyToPoint as
|
|
7961
|
+
import { applyToPoint as applyToPoint54 } from "transformation-matrix";
|
|
7769
7962
|
function createSvgObjectsFromSchDebugObject({
|
|
7770
7963
|
debugObject,
|
|
7771
7964
|
transform
|
|
7772
7965
|
}) {
|
|
7773
7966
|
if (debugObject.shape === "rect") {
|
|
7774
|
-
let [screenLeft, screenTop] =
|
|
7967
|
+
let [screenLeft, screenTop] = applyToPoint54(transform, [
|
|
7775
7968
|
debugObject.center.x - debugObject.size.width / 2,
|
|
7776
7969
|
debugObject.center.y - debugObject.size.height / 2
|
|
7777
7970
|
]);
|
|
7778
|
-
let [screenRight, screenBottom] =
|
|
7971
|
+
let [screenRight, screenBottom] = applyToPoint54(transform, [
|
|
7779
7972
|
debugObject.center.x + debugObject.size.width / 2,
|
|
7780
7973
|
debugObject.center.y + debugObject.size.height / 2
|
|
7781
7974
|
]);
|
|
@@ -7785,7 +7978,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
7785
7978
|
];
|
|
7786
7979
|
const width = Math.abs(screenRight - screenLeft);
|
|
7787
7980
|
const height = Math.abs(screenBottom - screenTop);
|
|
7788
|
-
const [screenCenterX, screenCenterY] =
|
|
7981
|
+
const [screenCenterX, screenCenterY] = applyToPoint54(transform, [
|
|
7789
7982
|
debugObject.center.x,
|
|
7790
7983
|
debugObject.center.y
|
|
7791
7984
|
]);
|
|
@@ -7831,11 +8024,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
7831
8024
|
];
|
|
7832
8025
|
}
|
|
7833
8026
|
if (debugObject.shape === "line") {
|
|
7834
|
-
const [screenStartX, screenStartY] =
|
|
8027
|
+
const [screenStartX, screenStartY] = applyToPoint54(transform, [
|
|
7835
8028
|
debugObject.start.x,
|
|
7836
8029
|
debugObject.start.y
|
|
7837
8030
|
]);
|
|
7838
|
-
const [screenEndX, screenEndY] =
|
|
8031
|
+
const [screenEndX, screenEndY] = applyToPoint54(transform, [
|
|
7839
8032
|
debugObject.end.x,
|
|
7840
8033
|
debugObject.end.y
|
|
7841
8034
|
]);
|
|
@@ -7885,7 +8078,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
7885
8078
|
}
|
|
7886
8079
|
|
|
7887
8080
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
7888
|
-
import { applyToPoint as
|
|
8081
|
+
import { applyToPoint as applyToPoint55 } from "transformation-matrix";
|
|
7889
8082
|
function createSchematicTrace({
|
|
7890
8083
|
trace,
|
|
7891
8084
|
transform,
|
|
@@ -7899,11 +8092,11 @@ function createSchematicTrace({
|
|
|
7899
8092
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
7900
8093
|
const edge = edges[edgeIndex];
|
|
7901
8094
|
if (edge.is_crossing) continue;
|
|
7902
|
-
const [screenFromX, screenFromY] =
|
|
8095
|
+
const [screenFromX, screenFromY] = applyToPoint55(transform, [
|
|
7903
8096
|
edge.from.x,
|
|
7904
8097
|
edge.from.y
|
|
7905
8098
|
]);
|
|
7906
|
-
const [screenToX, screenToY] =
|
|
8099
|
+
const [screenToX, screenToY] = applyToPoint55(transform, [
|
|
7907
8100
|
edge.to.x,
|
|
7908
8101
|
edge.to.y
|
|
7909
8102
|
]);
|
|
@@ -7947,11 +8140,11 @@ function createSchematicTrace({
|
|
|
7947
8140
|
}
|
|
7948
8141
|
for (const edge of edges) {
|
|
7949
8142
|
if (!edge.is_crossing) continue;
|
|
7950
|
-
const [screenFromX, screenFromY] =
|
|
8143
|
+
const [screenFromX, screenFromY] = applyToPoint55(transform, [
|
|
7951
8144
|
edge.from.x,
|
|
7952
8145
|
edge.from.y
|
|
7953
8146
|
]);
|
|
7954
|
-
const [screenToX, screenToY] =
|
|
8147
|
+
const [screenToX, screenToY] = applyToPoint55(transform, [
|
|
7955
8148
|
edge.to.x,
|
|
7956
8149
|
edge.to.y
|
|
7957
8150
|
]);
|
|
@@ -7995,7 +8188,7 @@ function createSchematicTrace({
|
|
|
7995
8188
|
}
|
|
7996
8189
|
if (trace.junctions) {
|
|
7997
8190
|
for (const junction of trace.junctions) {
|
|
7998
|
-
const [screenX, screenY] =
|
|
8191
|
+
const [screenX, screenY] = applyToPoint55(transform, [
|
|
7999
8192
|
junction.x,
|
|
8000
8193
|
junction.y
|
|
8001
8194
|
]);
|
|
@@ -8050,7 +8243,7 @@ function createSchematicTrace({
|
|
|
8050
8243
|
|
|
8051
8244
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
8052
8245
|
import {
|
|
8053
|
-
applyToPoint as
|
|
8246
|
+
applyToPoint as applyToPoint57,
|
|
8054
8247
|
compose as compose11,
|
|
8055
8248
|
rotate as rotate6,
|
|
8056
8249
|
scale as scale6,
|
|
@@ -8059,7 +8252,7 @@ import {
|
|
|
8059
8252
|
|
|
8060
8253
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
8061
8254
|
import {
|
|
8062
|
-
applyToPoint as
|
|
8255
|
+
applyToPoint as applyToPoint56,
|
|
8063
8256
|
compose as compose10,
|
|
8064
8257
|
rotate as rotate5,
|
|
8065
8258
|
scale as scale5,
|
|
@@ -8134,7 +8327,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8134
8327
|
x: symbolBounds.minX,
|
|
8135
8328
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
8136
8329
|
};
|
|
8137
|
-
const rotatedSymbolEnd =
|
|
8330
|
+
const rotatedSymbolEnd = applyToPoint56(rotationMatrix, symbolEndPoint);
|
|
8138
8331
|
const symbolToRealTransform = compose10(
|
|
8139
8332
|
translate10(
|
|
8140
8333
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
@@ -8144,11 +8337,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8144
8337
|
scale5(1)
|
|
8145
8338
|
// Use full symbol size
|
|
8146
8339
|
);
|
|
8147
|
-
const [screenMinX, screenMinY] =
|
|
8340
|
+
const [screenMinX, screenMinY] = applyToPoint56(
|
|
8148
8341
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8149
8342
|
[bounds.minX, bounds.minY]
|
|
8150
8343
|
);
|
|
8151
|
-
const [screenMaxX, screenMaxY] =
|
|
8344
|
+
const [screenMaxX, screenMaxY] = applyToPoint56(
|
|
8152
8345
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8153
8346
|
[bounds.maxX, bounds.maxY]
|
|
8154
8347
|
);
|
|
@@ -8172,7 +8365,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8172
8365
|
});
|
|
8173
8366
|
for (const path of symbolPaths) {
|
|
8174
8367
|
const symbolPath = path.points.map((p, i) => {
|
|
8175
|
-
const [x, y] =
|
|
8368
|
+
const [x, y] = applyToPoint56(
|
|
8176
8369
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8177
8370
|
[p.x, p.y]
|
|
8178
8371
|
);
|
|
@@ -8193,7 +8386,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8193
8386
|
});
|
|
8194
8387
|
}
|
|
8195
8388
|
for (const text of symbolTexts) {
|
|
8196
|
-
const screenTextPos =
|
|
8389
|
+
const screenTextPos = applyToPoint56(
|
|
8197
8390
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8198
8391
|
text
|
|
8199
8392
|
);
|
|
@@ -8235,7 +8428,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8235
8428
|
});
|
|
8236
8429
|
}
|
|
8237
8430
|
for (const box of symbolBoxes) {
|
|
8238
|
-
const screenBoxPos =
|
|
8431
|
+
const screenBoxPos = applyToPoint56(
|
|
8239
8432
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8240
8433
|
box
|
|
8241
8434
|
);
|
|
@@ -8258,7 +8451,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8258
8451
|
});
|
|
8259
8452
|
}
|
|
8260
8453
|
for (const circle of symbolCircles) {
|
|
8261
|
-
const screenCirclePos =
|
|
8454
|
+
const screenCirclePos = applyToPoint56(
|
|
8262
8455
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8263
8456
|
circle
|
|
8264
8457
|
);
|
|
@@ -8303,14 +8496,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
8303
8496
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
8304
8497
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
8305
8498
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
8306
|
-
const screenCenter =
|
|
8499
|
+
const screenCenter = applyToPoint57(realToScreenTransform, schNetLabel.center);
|
|
8307
8500
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
8308
8501
|
schNetLabel.anchor_side
|
|
8309
8502
|
);
|
|
8310
8503
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
8311
8504
|
screenTextGrowthVec.y *= -1;
|
|
8312
8505
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
8313
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
8506
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint57(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
8314
8507
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
8315
8508
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
8316
8509
|
};
|
|
@@ -8351,7 +8544,7 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
8351
8544
|
y: -0.6
|
|
8352
8545
|
}
|
|
8353
8546
|
].map(
|
|
8354
|
-
(fontRelativePoint) =>
|
|
8547
|
+
(fontRelativePoint) => applyToPoint57(
|
|
8355
8548
|
compose11(
|
|
8356
8549
|
realToScreenTransform,
|
|
8357
8550
|
translate11(realAnchorPosition.x, realAnchorPosition.y),
|
|
@@ -8428,17 +8621,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
8428
8621
|
};
|
|
8429
8622
|
|
|
8430
8623
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
8431
|
-
import { applyToPoint as
|
|
8624
|
+
import { applyToPoint as applyToPoint58 } from "transformation-matrix";
|
|
8432
8625
|
var createSvgObjectsFromSchematicBox = ({
|
|
8433
8626
|
schematicBox,
|
|
8434
8627
|
transform,
|
|
8435
8628
|
colorMap: colorMap2
|
|
8436
8629
|
}) => {
|
|
8437
|
-
const topLeft =
|
|
8630
|
+
const topLeft = applyToPoint58(transform, {
|
|
8438
8631
|
x: schematicBox.x,
|
|
8439
8632
|
y: schematicBox.y
|
|
8440
8633
|
});
|
|
8441
|
-
const bottomRight =
|
|
8634
|
+
const bottomRight = applyToPoint58(transform, {
|
|
8442
8635
|
x: schematicBox.x + schematicBox.width,
|
|
8443
8636
|
y: schematicBox.y + schematicBox.height
|
|
8444
8637
|
});
|
|
@@ -8474,7 +8667,7 @@ var createSvgObjectsFromSchematicBox = ({
|
|
|
8474
8667
|
};
|
|
8475
8668
|
|
|
8476
8669
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-table.ts
|
|
8477
|
-
import { applyToPoint as
|
|
8670
|
+
import { applyToPoint as applyToPoint59 } from "transformation-matrix";
|
|
8478
8671
|
var createSvgObjectsFromSchematicTable = ({
|
|
8479
8672
|
schematicTable,
|
|
8480
8673
|
transform,
|
|
@@ -8507,11 +8700,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8507
8700
|
const svgObjects = [];
|
|
8508
8701
|
const borderStrokeWidth = border_width * Math.abs(transform.a);
|
|
8509
8702
|
const gridStrokeWidth = getSchStrokeSize(transform);
|
|
8510
|
-
const [screenTopLeftX, screenTopLeftY] =
|
|
8703
|
+
const [screenTopLeftX, screenTopLeftY] = applyToPoint59(transform, [
|
|
8511
8704
|
topLeftX,
|
|
8512
8705
|
topLeftY
|
|
8513
8706
|
]);
|
|
8514
|
-
const [screenBottomRightX, screenBottomRightY] =
|
|
8707
|
+
const [screenBottomRightX, screenBottomRightY] = applyToPoint59(transform, [
|
|
8515
8708
|
topLeftX + totalWidth,
|
|
8516
8709
|
topLeftY - totalHeight
|
|
8517
8710
|
]);
|
|
@@ -8543,8 +8736,8 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8543
8736
|
(cell) => cell.start_column_index <= i && cell.end_column_index > i && cell.start_row_index <= j && cell.end_row_index >= j
|
|
8544
8737
|
);
|
|
8545
8738
|
if (!isMerged) {
|
|
8546
|
-
const start =
|
|
8547
|
-
const end =
|
|
8739
|
+
const start = applyToPoint59(transform, { x: currentX, y: segmentStartY });
|
|
8740
|
+
const end = applyToPoint59(transform, { x: currentX, y: segmentEndY });
|
|
8548
8741
|
svgObjects.push({
|
|
8549
8742
|
name: "line",
|
|
8550
8743
|
type: "element",
|
|
@@ -8573,11 +8766,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8573
8766
|
(cell) => cell.start_row_index <= i && cell.end_row_index > i && cell.start_column_index <= j && cell.end_column_index >= j
|
|
8574
8767
|
);
|
|
8575
8768
|
if (!isMerged) {
|
|
8576
|
-
const start =
|
|
8769
|
+
const start = applyToPoint59(transform, {
|
|
8577
8770
|
x: segmentStartX,
|
|
8578
8771
|
y: currentY
|
|
8579
8772
|
});
|
|
8580
|
-
const end =
|
|
8773
|
+
const end = applyToPoint59(transform, { x: segmentEndX, y: currentY });
|
|
8581
8774
|
svgObjects.push({
|
|
8582
8775
|
name: "line",
|
|
8583
8776
|
type: "element",
|
|
@@ -8619,7 +8812,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8619
8812
|
} else if (vertical_align === "bottom") {
|
|
8620
8813
|
realTextAnchorPos.y = cellTopLeftY - cellHeight + cell_padding;
|
|
8621
8814
|
}
|
|
8622
|
-
const screenTextAnchorPos =
|
|
8815
|
+
const screenTextAnchorPos = applyToPoint59(transform, realTextAnchorPos);
|
|
8623
8816
|
const fontSize = getSchScreenFontSize(
|
|
8624
8817
|
transform,
|
|
8625
8818
|
"reference_designator",
|
|
@@ -8675,13 +8868,13 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8675
8868
|
|
|
8676
8869
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
|
|
8677
8870
|
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
8678
|
-
import { applyToPoint as
|
|
8871
|
+
import { applyToPoint as applyToPoint60 } from "transformation-matrix";
|
|
8679
8872
|
var PIN_CIRCLE_RADIUS_MM2 = 0.02;
|
|
8680
8873
|
var createSvgObjectsForSchPortHover = ({
|
|
8681
8874
|
schPort,
|
|
8682
8875
|
transform
|
|
8683
8876
|
}) => {
|
|
8684
|
-
const screenSchPortPos =
|
|
8877
|
+
const screenSchPortPos = applyToPoint60(transform, schPort.center);
|
|
8685
8878
|
const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
|
|
8686
8879
|
return [
|
|
8687
8880
|
{
|
|
@@ -8726,14 +8919,14 @@ var createSvgObjectsForSchComponentPortHovers = ({
|
|
|
8726
8919
|
};
|
|
8727
8920
|
|
|
8728
8921
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-line.ts
|
|
8729
|
-
import { applyToPoint as
|
|
8922
|
+
import { applyToPoint as applyToPoint61 } from "transformation-matrix";
|
|
8730
8923
|
function createSvgObjectsFromSchematicLine({
|
|
8731
8924
|
schLine,
|
|
8732
8925
|
transform,
|
|
8733
8926
|
colorMap: colorMap2
|
|
8734
8927
|
}) {
|
|
8735
|
-
const p1 =
|
|
8736
|
-
const p2 =
|
|
8928
|
+
const p1 = applyToPoint61(transform, { x: schLine.x1, y: schLine.y1 });
|
|
8929
|
+
const p2 = applyToPoint61(transform, { x: schLine.x2, y: schLine.y2 });
|
|
8737
8930
|
const strokeWidth = schLine.stroke_width ?? 0.02;
|
|
8738
8931
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
8739
8932
|
return [
|
|
@@ -8762,13 +8955,13 @@ function createSvgObjectsFromSchematicLine({
|
|
|
8762
8955
|
}
|
|
8763
8956
|
|
|
8764
8957
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-circle.ts
|
|
8765
|
-
import { applyToPoint as
|
|
8958
|
+
import { applyToPoint as applyToPoint62 } from "transformation-matrix";
|
|
8766
8959
|
function createSvgObjectsFromSchematicCircle({
|
|
8767
8960
|
schCircle,
|
|
8768
8961
|
transform,
|
|
8769
8962
|
colorMap: colorMap2
|
|
8770
8963
|
}) {
|
|
8771
|
-
const center =
|
|
8964
|
+
const center = applyToPoint62(transform, schCircle.center);
|
|
8772
8965
|
const transformedRadius = Math.abs(transform.a) * schCircle.radius;
|
|
8773
8966
|
const strokeWidth = schCircle.stroke_width ?? 0.02;
|
|
8774
8967
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -8798,13 +8991,13 @@ function createSvgObjectsFromSchematicCircle({
|
|
|
8798
8991
|
}
|
|
8799
8992
|
|
|
8800
8993
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-rect.ts
|
|
8801
|
-
import { applyToPoint as
|
|
8994
|
+
import { applyToPoint as applyToPoint63 } from "transformation-matrix";
|
|
8802
8995
|
function createSvgObjectsFromSchematicRect({
|
|
8803
8996
|
schRect,
|
|
8804
8997
|
transform,
|
|
8805
8998
|
colorMap: colorMap2
|
|
8806
8999
|
}) {
|
|
8807
|
-
const center =
|
|
9000
|
+
const center = applyToPoint63(transform, schRect.center);
|
|
8808
9001
|
const transformedWidth = Math.abs(transform.a) * schRect.width;
|
|
8809
9002
|
const transformedHeight = Math.abs(transform.d) * schRect.height;
|
|
8810
9003
|
const strokeWidth = schRect.stroke_width ?? 0.02;
|
|
@@ -8840,13 +9033,13 @@ function createSvgObjectsFromSchematicRect({
|
|
|
8840
9033
|
}
|
|
8841
9034
|
|
|
8842
9035
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-arc.ts
|
|
8843
|
-
import { applyToPoint as
|
|
9036
|
+
import { applyToPoint as applyToPoint64 } from "transformation-matrix";
|
|
8844
9037
|
function createSvgObjectsFromSchematicArc({
|
|
8845
9038
|
schArc,
|
|
8846
9039
|
transform,
|
|
8847
9040
|
colorMap: colorMap2
|
|
8848
9041
|
}) {
|
|
8849
|
-
const center =
|
|
9042
|
+
const center = applyToPoint64(transform, schArc.center);
|
|
8850
9043
|
const transformedRadius = Math.abs(transform.a) * schArc.radius;
|
|
8851
9044
|
const strokeWidth = schArc.stroke_width ?? 0.02;
|
|
8852
9045
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -9878,18 +10071,18 @@ function formatNumber2(value) {
|
|
|
9878
10071
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
9879
10072
|
import { stringify as stringify7 } from "svgson";
|
|
9880
10073
|
import {
|
|
9881
|
-
applyToPoint as
|
|
10074
|
+
applyToPoint as applyToPoint67,
|
|
9882
10075
|
compose as compose14,
|
|
9883
10076
|
scale as scale8,
|
|
9884
10077
|
translate as translate14
|
|
9885
10078
|
} from "transformation-matrix";
|
|
9886
10079
|
|
|
9887
10080
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
9888
|
-
import { applyToPoint as
|
|
10081
|
+
import { applyToPoint as applyToPoint66 } from "transformation-matrix";
|
|
9889
10082
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
9890
10083
|
const { transform, layer: layerFilter } = ctx;
|
|
9891
10084
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
9892
|
-
const [x, y] =
|
|
10085
|
+
const [x, y] = applyToPoint66(transform, [solderPaste.x, solderPaste.y]);
|
|
9893
10086
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
9894
10087
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
9895
10088
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -10100,8 +10293,8 @@ function createSvgObjects4({ elm, ctx }) {
|
|
|
10100
10293
|
}
|
|
10101
10294
|
}
|
|
10102
10295
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
10103
|
-
const [x1, y1] =
|
|
10104
|
-
const [x2, y2] =
|
|
10296
|
+
const [x1, y1] = applyToPoint67(transform, [minX, minY]);
|
|
10297
|
+
const [x2, y2] = applyToPoint67(transform, [maxX, maxY]);
|
|
10105
10298
|
const width = Math.abs(x2 - x1);
|
|
10106
10299
|
const height = Math.abs(y2 - y1);
|
|
10107
10300
|
const x = Math.min(x1, x2);
|