@tscircuit/circuit-json-util 0.0.128 → 0.0.129
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 +33 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1405,6 +1405,12 @@ var getReadableNameForElement = (soup, elm) => {
|
|
|
1405
1405
|
};
|
|
1406
1406
|
|
|
1407
1407
|
// lib/get-bounds-of-pcb-elements.ts
|
|
1408
|
+
import {
|
|
1409
|
+
applyToPoint as applyToPoint2,
|
|
1410
|
+
compose as compose2,
|
|
1411
|
+
rotateDEG as rotateDEG2,
|
|
1412
|
+
translate
|
|
1413
|
+
} from "transformation-matrix";
|
|
1408
1414
|
var mergeBounds = (currentBounds, nextBounds) => ({
|
|
1409
1415
|
minX: Math.min(currentBounds.minX, nextBounds.minX),
|
|
1410
1416
|
minY: Math.min(currentBounds.minY, nextBounds.minY),
|
|
@@ -1545,6 +1551,22 @@ var getPcbElementBounds = (elm) => {
|
|
|
1545
1551
|
);
|
|
1546
1552
|
platedHoleBounds = platedHoleBounds ? mergeBounds(platedHoleBounds, drillBounds) : drillBounds;
|
|
1547
1553
|
}
|
|
1554
|
+
if (elm.shape === "hole_with_polygon_pad") {
|
|
1555
|
+
const matrix = compose2(
|
|
1556
|
+
translate(elm.x, elm.y),
|
|
1557
|
+
rotateDEG2(elm.ccw_rotation ?? 0)
|
|
1558
|
+
);
|
|
1559
|
+
const outlineBounds2 = getBoundsFromPoints(
|
|
1560
|
+
elm.pad_outline.map((point) => applyToPoint2(matrix, point))
|
|
1561
|
+
);
|
|
1562
|
+
if (outlineBounds2) {
|
|
1563
|
+
if (platedHoleBounds) {
|
|
1564
|
+
platedHoleBounds = mergeBounds(platedHoleBounds, outlineBounds2);
|
|
1565
|
+
} else {
|
|
1566
|
+
platedHoleBounds = outlineBounds2;
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1548
1570
|
if (platedHoleBounds) return platedHoleBounds;
|
|
1549
1571
|
}
|
|
1550
1572
|
const elementRecord = elm;
|
|
@@ -2080,7 +2102,7 @@ var getPrimaryId = (element) => {
|
|
|
2080
2102
|
};
|
|
2081
2103
|
|
|
2082
2104
|
// lib/reposition-pcb-component.ts
|
|
2083
|
-
import { translate } from "transformation-matrix";
|
|
2105
|
+
import { translate as translate2 } from "transformation-matrix";
|
|
2084
2106
|
var repositionPcbComponentTo = (circuitJson, pcb_component_id, newCenter) => {
|
|
2085
2107
|
const pcbComponent = circuitJson.find(
|
|
2086
2108
|
(e) => e.type === "pcb_component" && e.pcb_component_id === pcb_component_id
|
|
@@ -2111,12 +2133,12 @@ var repositionPcbComponentTo = (circuitJson, pcb_component_id, newCenter) => {
|
|
|
2111
2133
|
return true;
|
|
2112
2134
|
return false;
|
|
2113
2135
|
});
|
|
2114
|
-
const matrix =
|
|
2136
|
+
const matrix = translate2(dx, dy);
|
|
2115
2137
|
transformPCBElements(elementsToMove, matrix);
|
|
2116
2138
|
};
|
|
2117
2139
|
|
|
2118
2140
|
// lib/reposition-pcb-group.ts
|
|
2119
|
-
import { translate as
|
|
2141
|
+
import { translate as translate3 } from "transformation-matrix";
|
|
2120
2142
|
var findAllDescendantGroupIds = (circuitJson, parentGroupId) => {
|
|
2121
2143
|
const childGroupIds = [];
|
|
2122
2144
|
const directChildren = circuitJson.filter(
|
|
@@ -2163,12 +2185,12 @@ var repositionPcbGroupTo = (circuitJson, source_group_id, newCenter) => {
|
|
|
2163
2185
|
const { center: currentCenter } = findBoundsAndCenter(pcbElements);
|
|
2164
2186
|
const dx = newCenter.x - currentCenter.x;
|
|
2165
2187
|
const dy = newCenter.y - currentCenter.y;
|
|
2166
|
-
const matrix =
|
|
2188
|
+
const matrix = translate3(dx, dy);
|
|
2167
2189
|
transformPCBElements(pcbElements, matrix);
|
|
2168
2190
|
};
|
|
2169
2191
|
|
|
2170
2192
|
// lib/reposition-schematic-component.ts
|
|
2171
|
-
import { translate as
|
|
2193
|
+
import { translate as translate4 } from "transformation-matrix";
|
|
2172
2194
|
var repositionSchematicComponentTo = (circuitJson, schematic_component_id, newCenter) => {
|
|
2173
2195
|
const schematicComponent = circuitJson.find(
|
|
2174
2196
|
(e) => e.type === "schematic_component" && e.schematic_component_id === schematic_component_id
|
|
@@ -2200,12 +2222,12 @@ var repositionSchematicComponentTo = (circuitJson, schematic_component_id, newCe
|
|
|
2200
2222
|
return true;
|
|
2201
2223
|
return false;
|
|
2202
2224
|
});
|
|
2203
|
-
const matrix =
|
|
2225
|
+
const matrix = translate4(dx, dy);
|
|
2204
2226
|
transformSchematicElements(elementsToMove, matrix);
|
|
2205
2227
|
};
|
|
2206
2228
|
|
|
2207
2229
|
// lib/reposition-schematic-group.ts
|
|
2208
|
-
import { translate as
|
|
2230
|
+
import { translate as translate5 } from "transformation-matrix";
|
|
2209
2231
|
var findAllDescendantGroupIds2 = (circuitJson, parentGroupId) => {
|
|
2210
2232
|
const childGroupIds = [];
|
|
2211
2233
|
const directChildren = circuitJson.filter(
|
|
@@ -2252,7 +2274,7 @@ var repositionSchematicGroupTo = (circuitJson, source_group_id, newCenter) => {
|
|
|
2252
2274
|
const { center: currentCenter } = findBoundsAndCenter(schematicElements);
|
|
2253
2275
|
const dx = newCenter.x - currentCenter.x;
|
|
2254
2276
|
const dy = newCenter.y - currentCenter.y;
|
|
2255
|
-
const matrix =
|
|
2277
|
+
const matrix = translate5(dx, dy);
|
|
2256
2278
|
transformSchematicElements(schematicElements, matrix);
|
|
2257
2279
|
};
|
|
2258
2280
|
|
|
@@ -3028,10 +3050,10 @@ import {
|
|
|
3028
3050
|
Segment,
|
|
3029
3051
|
Utils
|
|
3030
3052
|
} from "@flatten-js/core";
|
|
3031
|
-
import { compose as
|
|
3053
|
+
import { compose as compose3, rotate, translate as translate6 } from "transformation-matrix";
|
|
3032
3054
|
var placePolygon = (polygon, center, degrees = 0) => {
|
|
3033
|
-
const { a, b, c, d, e, f } =
|
|
3034
|
-
|
|
3055
|
+
const { a, b, c, d, e, f } = compose3(
|
|
3056
|
+
translate6(center.x, center.y),
|
|
3035
3057
|
rotate(degrees * Math.PI / 180)
|
|
3036
3058
|
);
|
|
3037
3059
|
return polygon.transform(new Matrix(a, b, c, d, e, f));
|