@tscircuit/circuit-json-util 0.0.117 → 0.0.118
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.d.ts +2002 -1342
- package/dist/index.js +36 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -831,7 +831,12 @@ cjuIndexed.unparsed = cjuIndexed;
|
|
|
831
831
|
var cju_indexed_default = cjuIndexed;
|
|
832
832
|
|
|
833
833
|
// lib/transform-soup-elements.ts
|
|
834
|
-
import {
|
|
834
|
+
import {
|
|
835
|
+
applyToPoint,
|
|
836
|
+
compose,
|
|
837
|
+
decomposeTSR,
|
|
838
|
+
rotateDEG
|
|
839
|
+
} from "transformation-matrix";
|
|
835
840
|
|
|
836
841
|
// lib/direction-to-vec.ts
|
|
837
842
|
var directionToVec = (direction) => {
|
|
@@ -989,7 +994,33 @@ var transformSchematicElement = (elm, matrix) => {
|
|
|
989
994
|
var transformSchematicElements = (elms, matrix) => {
|
|
990
995
|
return elms.map((elm) => transformSchematicElement(elm, matrix));
|
|
991
996
|
};
|
|
997
|
+
var transformPcbSoldermaskOpening = (opening, matrix) => {
|
|
998
|
+
if (opening.shape === "polygon") {
|
|
999
|
+
opening.points = opening.points.map((point) => applyToPoint(matrix, point));
|
|
1000
|
+
return opening;
|
|
1001
|
+
}
|
|
1002
|
+
const center = applyToPoint(matrix, { x: opening.x, y: opening.y });
|
|
1003
|
+
opening.x = center.x;
|
|
1004
|
+
opening.y = center.y;
|
|
1005
|
+
if (opening.shape === "circle") return opening;
|
|
1006
|
+
const rectRotation = opening.shape === "rotated_rect" ? opening.ccw_rotation : 0;
|
|
1007
|
+
const isReflected = matrix.a * matrix.d - matrix.b * matrix.c < 0;
|
|
1008
|
+
const transformedRotation = decomposeTSR(compose(matrix, rotateDEG(rectRotation)), false, isReflected).rotation.angle * 180 / Math.PI;
|
|
1009
|
+
if (Math.abs(transformedRotation) < 1e-8) {
|
|
1010
|
+
Object.assign(opening, { shape: "rect" });
|
|
1011
|
+
Reflect.deleteProperty(opening, "ccw_rotation");
|
|
1012
|
+
} else {
|
|
1013
|
+
Object.assign(opening, {
|
|
1014
|
+
shape: "rotated_rect",
|
|
1015
|
+
ccw_rotation: transformedRotation
|
|
1016
|
+
});
|
|
1017
|
+
}
|
|
1018
|
+
return opening;
|
|
1019
|
+
};
|
|
992
1020
|
var transformPCBElement = (elm, matrix) => {
|
|
1021
|
+
if (elm.type === "pcb_soldermask_opening") {
|
|
1022
|
+
return transformPcbSoldermaskOpening(elm, matrix);
|
|
1023
|
+
}
|
|
993
1024
|
const tsr = decomposeTSR(matrix);
|
|
994
1025
|
const flipPadWidthHeight = Math.abs(getQuarterTurns(tsr.rotation.angle)) % 2 === 1;
|
|
995
1026
|
const rotationDegrees = tsr.rotation.angle / Math.PI * 180;
|
|
@@ -1010,6 +1041,8 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
1010
1041
|
};
|
|
1011
1042
|
});
|
|
1012
1043
|
}
|
|
1044
|
+
} else if (elm.type === "pcb_keepout" && elm.shape === "outline") {
|
|
1045
|
+
elm.outline = elm.outline.map((point) => applyToPoint(matrix, point));
|
|
1013
1046
|
} else if (elm.type === "pcb_keepout" || elm.type === "pcb_board") {
|
|
1014
1047
|
elm.center = applyToPoint(matrix, elm.center);
|
|
1015
1048
|
} else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text" || elm.type === "pcb_note_text") {
|
|
@@ -2907,9 +2940,9 @@ import {
|
|
|
2907
2940
|
Polygon,
|
|
2908
2941
|
Segment
|
|
2909
2942
|
} from "@flatten-js/core";
|
|
2910
|
-
import { compose, rotate, translate as translate5 } from "transformation-matrix";
|
|
2943
|
+
import { compose as compose2, rotate, translate as translate5 } from "transformation-matrix";
|
|
2911
2944
|
var placePolygon = (polygon, center, degrees = 0) => {
|
|
2912
|
-
const { a, b, c, d, e, f } =
|
|
2945
|
+
const { a, b, c, d, e, f } = compose2(
|
|
2913
2946
|
translate5(center.x, center.y),
|
|
2914
2947
|
rotate(degrees * Math.PI / 180)
|
|
2915
2948
|
);
|