circuit-to-svg 0.0.245 → 0.0.247
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 +250 -183
- 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 applyToPoint30,
|
|
5
5
|
compose as compose5,
|
|
6
6
|
scale as scale2,
|
|
7
7
|
translate as translate5
|
|
@@ -2466,11 +2466,45 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
|
2466
2466
|
];
|
|
2467
2467
|
}
|
|
2468
2468
|
|
|
2469
|
-
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-
|
|
2469
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-panel.ts
|
|
2470
2470
|
import { applyToPoint as applyToPoint21 } from "transformation-matrix";
|
|
2471
|
+
function createSvgObjectsFromPcbPanel(pcbPanel, ctx) {
|
|
2472
|
+
const { transform, colorMap: colorMap2, renderSolderMask } = ctx;
|
|
2473
|
+
const width = Number(pcbPanel.width);
|
|
2474
|
+
const height = Number(pcbPanel.height);
|
|
2475
|
+
const topLeft = applyToPoint21(transform, [0, 0]);
|
|
2476
|
+
const topRight = applyToPoint21(transform, [width, 0]);
|
|
2477
|
+
const bottomRight = applyToPoint21(transform, [width, height]);
|
|
2478
|
+
const bottomLeft = applyToPoint21(transform, [0, height]);
|
|
2479
|
+
const path = `M ${topLeft[0]} ${topLeft[1]} L ${topRight[0]} ${topRight[1]} L ${bottomRight[0]} ${bottomRight[1]} L ${bottomLeft[0]} ${bottomLeft[1]} Z`;
|
|
2480
|
+
const isCoveredWithSolderMask = pcbPanel.covered_with_solder_mask !== false;
|
|
2481
|
+
const shouldRenderSolderMask = Boolean(
|
|
2482
|
+
renderSolderMask && isCoveredWithSolderMask
|
|
2483
|
+
);
|
|
2484
|
+
return [
|
|
2485
|
+
{
|
|
2486
|
+
name: "path",
|
|
2487
|
+
type: "element",
|
|
2488
|
+
value: "",
|
|
2489
|
+
children: [],
|
|
2490
|
+
attributes: {
|
|
2491
|
+
class: "pcb-panel",
|
|
2492
|
+
d: path,
|
|
2493
|
+
fill: shouldRenderSolderMask ? colorMap2.soldermask.top : "none",
|
|
2494
|
+
stroke: colorMap2.boardOutline,
|
|
2495
|
+
"stroke-width": (0.1 * Math.abs(transform.a)).toString(),
|
|
2496
|
+
"data-type": "pcb_panel",
|
|
2497
|
+
"data-pcb-layer": "board"
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
];
|
|
2501
|
+
}
|
|
2502
|
+
|
|
2503
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-via.ts
|
|
2504
|
+
import { applyToPoint as applyToPoint22 } from "transformation-matrix";
|
|
2471
2505
|
function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
2472
2506
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
2473
|
-
const [x, y] =
|
|
2507
|
+
const [x, y] = applyToPoint22(transform, [hole.x, hole.y]);
|
|
2474
2508
|
const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a);
|
|
2475
2509
|
const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a);
|
|
2476
2510
|
const scaledHoleWidth = hole.hole_diameter * Math.abs(transform.a);
|
|
@@ -2516,10 +2550,10 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
|
2516
2550
|
}
|
|
2517
2551
|
|
|
2518
2552
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-hole.ts
|
|
2519
|
-
import { applyToPoint as
|
|
2553
|
+
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
2520
2554
|
function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
2521
2555
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
2522
|
-
const [x, y] =
|
|
2556
|
+
const [x, y] = applyToPoint23(transform, [hole.x, hole.y]);
|
|
2523
2557
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
2524
2558
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
2525
2559
|
const radius = scaledDiameter / 2;
|
|
@@ -2657,7 +2691,7 @@ import {
|
|
|
2657
2691
|
getFullConnectivityMapFromCircuitJson
|
|
2658
2692
|
} from "circuit-json-to-connectivity-map";
|
|
2659
2693
|
import "svgson";
|
|
2660
|
-
import { applyToPoint as
|
|
2694
|
+
import { applyToPoint as applyToPoint24 } from "transformation-matrix";
|
|
2661
2695
|
|
|
2662
2696
|
// lib/pcb/create-svg-objects-from-pcb-rats-nest/get-element-position.ts
|
|
2663
2697
|
import { su } from "@tscircuit/circuit-json-util";
|
|
@@ -2737,11 +2771,11 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
2737
2771
|
});
|
|
2738
2772
|
const svgObjects = [];
|
|
2739
2773
|
for (const line of ratsNestLines) {
|
|
2740
|
-
const transformedStart =
|
|
2774
|
+
const transformedStart = applyToPoint24(transform, [
|
|
2741
2775
|
line.startPoint.x,
|
|
2742
2776
|
line.startPoint.y
|
|
2743
2777
|
]);
|
|
2744
|
-
const transformedEnd =
|
|
2778
|
+
const transformedEnd = applyToPoint24(transform, [
|
|
2745
2779
|
line.endPoint.x,
|
|
2746
2780
|
line.endPoint.y
|
|
2747
2781
|
]);
|
|
@@ -2769,7 +2803,7 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
2769
2803
|
|
|
2770
2804
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-cutout.ts
|
|
2771
2805
|
import {
|
|
2772
|
-
applyToPoint as
|
|
2806
|
+
applyToPoint as applyToPoint25,
|
|
2773
2807
|
compose as compose3,
|
|
2774
2808
|
rotate as rotate3,
|
|
2775
2809
|
translate as translate3,
|
|
@@ -2779,7 +2813,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2779
2813
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
2780
2814
|
if (cutout.shape === "rect") {
|
|
2781
2815
|
const rectCutout = cutout;
|
|
2782
|
-
const [cx, cy] =
|
|
2816
|
+
const [cx, cy] = applyToPoint25(transform, [
|
|
2783
2817
|
rectCutout.center.x,
|
|
2784
2818
|
rectCutout.center.y
|
|
2785
2819
|
]);
|
|
@@ -2810,7 +2844,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2810
2844
|
}
|
|
2811
2845
|
if (cutout.shape === "circle") {
|
|
2812
2846
|
const circleCutout = cutout;
|
|
2813
|
-
const [cx, cy] =
|
|
2847
|
+
const [cx, cy] = applyToPoint25(transform, [
|
|
2814
2848
|
circleCutout.center.x,
|
|
2815
2849
|
circleCutout.center.y
|
|
2816
2850
|
]);
|
|
@@ -2837,7 +2871,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2837
2871
|
const polygonCutout = cutout;
|
|
2838
2872
|
if (!polygonCutout.points || polygonCutout.points.length === 0) return [];
|
|
2839
2873
|
const transformedPoints = polygonCutout.points.map(
|
|
2840
|
-
(p) =>
|
|
2874
|
+
(p) => applyToPoint25(transform, [p.x, p.y])
|
|
2841
2875
|
);
|
|
2842
2876
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
2843
2877
|
return [
|
|
@@ -2861,7 +2895,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
2861
2895
|
|
|
2862
2896
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-copper-pour.ts
|
|
2863
2897
|
import {
|
|
2864
|
-
applyToPoint as
|
|
2898
|
+
applyToPoint as applyToPoint27,
|
|
2865
2899
|
compose as compose4,
|
|
2866
2900
|
rotate as rotate4,
|
|
2867
2901
|
toString as matrixToString7,
|
|
@@ -2869,11 +2903,11 @@ import {
|
|
|
2869
2903
|
} from "transformation-matrix";
|
|
2870
2904
|
|
|
2871
2905
|
// lib/utils/ring-to-path-d.ts
|
|
2872
|
-
import { applyToPoint as
|
|
2906
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
2873
2907
|
function ringToPathD(vertices, transform) {
|
|
2874
2908
|
if (vertices.length === 0) return "";
|
|
2875
2909
|
const transformedVertices = vertices.map((v) => {
|
|
2876
|
-
const [x, y] =
|
|
2910
|
+
const [x, y] = applyToPoint26(transform, [v.x, v.y]);
|
|
2877
2911
|
return { ...v, x, y };
|
|
2878
2912
|
});
|
|
2879
2913
|
let d = `M ${transformedVertices[0].x} ${transformedVertices[0].y}`;
|
|
@@ -2906,7 +2940,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
2906
2940
|
const color = layerNameToColor(layer, colorMap2);
|
|
2907
2941
|
const opacity = "0.5";
|
|
2908
2942
|
if (pour.shape === "rect") {
|
|
2909
|
-
const [cx, cy] =
|
|
2943
|
+
const [cx, cy] = applyToPoint27(transform, [pour.center.x, pour.center.y]);
|
|
2910
2944
|
const scaledWidth = pour.width * Math.abs(transform.a);
|
|
2911
2945
|
const scaledHeight = pour.height * Math.abs(transform.d);
|
|
2912
2946
|
const svgRotation = -(pour.rotation ?? 0);
|
|
@@ -2936,7 +2970,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
2936
2970
|
if (pour.shape === "polygon") {
|
|
2937
2971
|
if (!pour.points || pour.points.length === 0) return [];
|
|
2938
2972
|
const transformedPoints = pour.points.map(
|
|
2939
|
-
(p) =>
|
|
2973
|
+
(p) => applyToPoint27(transform, [p.x, p.y])
|
|
2940
2974
|
);
|
|
2941
2975
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
2942
2976
|
return [
|
|
@@ -3121,11 +3155,11 @@ function createMajorGridPatternChildren(cellSize, majorCellSize, lineColor, majo
|
|
|
3121
3155
|
}
|
|
3122
3156
|
|
|
3123
3157
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-component.ts
|
|
3124
|
-
import { applyToPoint as
|
|
3158
|
+
import { applyToPoint as applyToPoint28 } from "transformation-matrix";
|
|
3125
3159
|
function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
3126
3160
|
const { transform } = ctx;
|
|
3127
3161
|
const { center, width, height, rotation = 0 } = component;
|
|
3128
|
-
const [x, y] =
|
|
3162
|
+
const [x, y] = applyToPoint28(transform, [center.x, center.y]);
|
|
3129
3163
|
const scaledWidth = width * Math.abs(transform.a);
|
|
3130
3164
|
const scaledHeight = height * Math.abs(transform.d);
|
|
3131
3165
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
@@ -3164,23 +3198,60 @@ function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
|
3164
3198
|
}
|
|
3165
3199
|
|
|
3166
3200
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-group.ts
|
|
3167
|
-
import { applyToPoint as
|
|
3201
|
+
import { applyToPoint as applyToPoint29 } from "transformation-matrix";
|
|
3168
3202
|
var DEFAULT_GROUP_COLOR = "rgba(100, 200, 255, 0.6)";
|
|
3169
3203
|
var DEFAULT_STROKE_WIDTH = 0.1;
|
|
3170
3204
|
function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
3171
3205
|
const { transform } = ctx;
|
|
3172
3206
|
const { center, width, height } = pcbGroup;
|
|
3207
|
+
const outline = Array.isArray(pcbGroup.outline) ? pcbGroup.outline : void 0;
|
|
3208
|
+
const transformedStrokeWidth = DEFAULT_STROKE_WIDTH * Math.abs(transform.a);
|
|
3209
|
+
const dashLength = 0.3 * Math.abs(transform.a);
|
|
3210
|
+
const gapLength = 0.15 * Math.abs(transform.a);
|
|
3211
|
+
const baseAttributes = {
|
|
3212
|
+
class: "pcb-group",
|
|
3213
|
+
fill: "none",
|
|
3214
|
+
stroke: DEFAULT_GROUP_COLOR,
|
|
3215
|
+
"stroke-width": transformedStrokeWidth.toString(),
|
|
3216
|
+
"stroke-dasharray": `${dashLength} ${gapLength}`,
|
|
3217
|
+
"data-type": "pcb_group",
|
|
3218
|
+
"data-pcb-group-id": pcbGroup.pcb_group_id,
|
|
3219
|
+
"data-pcb-layer": "overlay"
|
|
3220
|
+
};
|
|
3221
|
+
if (pcbGroup.name) {
|
|
3222
|
+
baseAttributes["data-group-name"] = pcbGroup.name;
|
|
3223
|
+
}
|
|
3224
|
+
if (outline && outline.length >= 3 && outline.every(
|
|
3225
|
+
(point) => point && typeof point.x === "number" && typeof point.y === "number"
|
|
3226
|
+
)) {
|
|
3227
|
+
const path = outline.map((point, index) => {
|
|
3228
|
+
const [x, y] = applyToPoint29(transform, [point.x, point.y]);
|
|
3229
|
+
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
3230
|
+
}).join(" ");
|
|
3231
|
+
return [
|
|
3232
|
+
{
|
|
3233
|
+
name: "path",
|
|
3234
|
+
type: "element",
|
|
3235
|
+
value: "",
|
|
3236
|
+
children: [],
|
|
3237
|
+
attributes: {
|
|
3238
|
+
...baseAttributes,
|
|
3239
|
+
d: `${path} Z`
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
];
|
|
3243
|
+
}
|
|
3173
3244
|
if (!center || typeof center.x !== "number" || typeof center.y !== "number" || typeof width !== "number" || typeof height !== "number") {
|
|
3174
3245
|
console.error("Invalid pcb_group data", { center, width, height });
|
|
3175
3246
|
return [];
|
|
3176
3247
|
}
|
|
3177
3248
|
const halfWidth = width / 2;
|
|
3178
3249
|
const halfHeight = height / 2;
|
|
3179
|
-
const [topLeftX, topLeftY] =
|
|
3250
|
+
const [topLeftX, topLeftY] = applyToPoint29(transform, [
|
|
3180
3251
|
center.x - halfWidth,
|
|
3181
3252
|
center.y + halfHeight
|
|
3182
3253
|
]);
|
|
3183
|
-
const [bottomRightX, bottomRightY] =
|
|
3254
|
+
const [bottomRightX, bottomRightY] = applyToPoint29(transform, [
|
|
3184
3255
|
center.x + halfWidth,
|
|
3185
3256
|
center.y - halfHeight
|
|
3186
3257
|
]);
|
|
@@ -3188,31 +3259,17 @@ function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
|
3188
3259
|
const rectY = Math.min(topLeftY, bottomRightY);
|
|
3189
3260
|
const rectWidth = Math.abs(bottomRightX - topLeftX);
|
|
3190
3261
|
const rectHeight = Math.abs(bottomRightY - topLeftY);
|
|
3191
|
-
const transformedStrokeWidth = DEFAULT_STROKE_WIDTH * Math.abs(transform.a);
|
|
3192
|
-
const dashLength = 0.3 * Math.abs(transform.a);
|
|
3193
|
-
const gapLength = 0.15 * Math.abs(transform.a);
|
|
3194
|
-
const attributes = {
|
|
3195
|
-
x: rectX.toString(),
|
|
3196
|
-
y: rectY.toString(),
|
|
3197
|
-
width: rectWidth.toString(),
|
|
3198
|
-
height: rectHeight.toString(),
|
|
3199
|
-
class: "pcb-group",
|
|
3200
|
-
fill: "none",
|
|
3201
|
-
stroke: DEFAULT_GROUP_COLOR,
|
|
3202
|
-
"stroke-width": transformedStrokeWidth.toString(),
|
|
3203
|
-
"stroke-dasharray": `${dashLength} ${gapLength}`,
|
|
3204
|
-
"data-type": "pcb_group",
|
|
3205
|
-
"data-pcb-group-id": pcbGroup.pcb_group_id,
|
|
3206
|
-
"data-pcb-layer": "overlay"
|
|
3207
|
-
};
|
|
3208
|
-
if (pcbGroup.name) {
|
|
3209
|
-
attributes["data-group-name"] = pcbGroup.name;
|
|
3210
|
-
}
|
|
3211
3262
|
const svgObject = {
|
|
3212
3263
|
name: "rect",
|
|
3213
3264
|
type: "element",
|
|
3214
3265
|
value: "",
|
|
3215
|
-
attributes
|
|
3266
|
+
attributes: {
|
|
3267
|
+
...baseAttributes,
|
|
3268
|
+
x: rectX.toString(),
|
|
3269
|
+
y: rectY.toString(),
|
|
3270
|
+
width: rectWidth.toString(),
|
|
3271
|
+
height: rectHeight.toString()
|
|
3272
|
+
},
|
|
3216
3273
|
children: []
|
|
3217
3274
|
};
|
|
3218
3275
|
return [svgObject];
|
|
@@ -3230,7 +3287,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
3230
3287
|
var package_default = {
|
|
3231
3288
|
name: "circuit-to-svg",
|
|
3232
3289
|
type: "module",
|
|
3233
|
-
version: "0.0.
|
|
3290
|
+
version: "0.0.246",
|
|
3234
3291
|
description: "Convert Circuit JSON to SVG",
|
|
3235
3292
|
main: "dist/index.js",
|
|
3236
3293
|
files: [
|
|
@@ -3254,7 +3311,7 @@ var package_default = {
|
|
|
3254
3311
|
"bun-match-svg": "^0.0.12",
|
|
3255
3312
|
esbuild: "^0.20.2",
|
|
3256
3313
|
"performance-now": "^2.1.0",
|
|
3257
|
-
"circuit-json": "^0.0.
|
|
3314
|
+
"circuit-json": "^0.0.284",
|
|
3258
3315
|
react: "19.1.0",
|
|
3259
3316
|
"react-cosmos": "7.0.0",
|
|
3260
3317
|
"react-cosmos-plugin-vite": "7.0.0",
|
|
@@ -3280,6 +3337,7 @@ var CIRCUIT_TO_SVG_VERSION = package_default.version;
|
|
|
3280
3337
|
var TYPE_PRIORITY = {
|
|
3281
3338
|
pcb_background: 0,
|
|
3282
3339
|
pcb_boundary: 1,
|
|
3340
|
+
pcb_panel: 5,
|
|
3283
3341
|
pcb_board: 10,
|
|
3284
3342
|
pcb_cutout: 15,
|
|
3285
3343
|
pcb_hole: 18,
|
|
@@ -3393,7 +3451,14 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
3393
3451
|
let boardMaxX = Number.NEGATIVE_INFINITY;
|
|
3394
3452
|
let boardMaxY = Number.NEGATIVE_INFINITY;
|
|
3395
3453
|
for (const circuitJsonElm of circuitJson) {
|
|
3396
|
-
if (circuitJsonElm.type === "
|
|
3454
|
+
if (circuitJsonElm.type === "pcb_panel") {
|
|
3455
|
+
const panel = circuitJsonElm;
|
|
3456
|
+
const width = Number(panel.width);
|
|
3457
|
+
const height = Number(panel.height);
|
|
3458
|
+
const center = { x: width / 2, y: height / 2 };
|
|
3459
|
+
updateBounds(center, width, height);
|
|
3460
|
+
updateBoardBounds(center, width, height);
|
|
3461
|
+
} else if (circuitJsonElm.type === "pcb_board") {
|
|
3397
3462
|
if (circuitJsonElm.outline && Array.isArray(circuitJsonElm.outline) && circuitJsonElm.outline.length >= 3) {
|
|
3398
3463
|
updateBoundsToIncludeOutline(circuitJsonElm.outline);
|
|
3399
3464
|
updateBoardBoundsToIncludeOutline(circuitJsonElm.outline);
|
|
@@ -3712,6 +3777,8 @@ function createSvgObjects({
|
|
|
3712
3777
|
return createSvgObjectsFromPcbNoteLine(elm, ctx);
|
|
3713
3778
|
case "pcb_silkscreen_path":
|
|
3714
3779
|
return createSvgObjectsFromPcbSilkscreenPath(elm, ctx);
|
|
3780
|
+
case "pcb_panel":
|
|
3781
|
+
return ctx.drawPaddingOutsideBoard ? createSvgObjectsFromPcbPanel(elm, ctx) : [];
|
|
3715
3782
|
case "pcb_board":
|
|
3716
3783
|
return ctx.drawPaddingOutsideBoard ? createSvgObjectsFromPcbBoard(elm, ctx) : [];
|
|
3717
3784
|
case "pcb_via":
|
|
@@ -3725,8 +3792,8 @@ function createSvgObjects({
|
|
|
3725
3792
|
}
|
|
3726
3793
|
}
|
|
3727
3794
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
3728
|
-
const [x1, y1] =
|
|
3729
|
-
const [x2, y2] =
|
|
3795
|
+
const [x1, y1] = applyToPoint30(transform, [minX, minY]);
|
|
3796
|
+
const [x2, y2] = applyToPoint30(transform, [maxX, maxY]);
|
|
3730
3797
|
const width = Math.abs(x2 - x1);
|
|
3731
3798
|
const height = Math.abs(y2 - y1);
|
|
3732
3799
|
const x = Math.min(x1, x2);
|
|
@@ -3756,14 +3823,14 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
3756
3823
|
import { stringify as stringify2 } from "svgson";
|
|
3757
3824
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
3758
3825
|
import {
|
|
3759
|
-
applyToPoint as
|
|
3826
|
+
applyToPoint as applyToPoint37,
|
|
3760
3827
|
compose as compose6,
|
|
3761
3828
|
scale as scale3,
|
|
3762
3829
|
translate as translate6
|
|
3763
3830
|
} from "transformation-matrix";
|
|
3764
3831
|
|
|
3765
3832
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
3766
|
-
import { applyToPoint as
|
|
3833
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
3767
3834
|
var DEFAULT_BOARD_STYLE = {
|
|
3768
3835
|
fill: "none",
|
|
3769
3836
|
stroke: "rgb(0,0,0)",
|
|
@@ -3775,25 +3842,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
3775
3842
|
let path;
|
|
3776
3843
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
3777
3844
|
path = outline.map((point, index) => {
|
|
3778
|
-
const [x, y] =
|
|
3845
|
+
const [x, y] = applyToPoint31(transform, [point.x, point.y]);
|
|
3779
3846
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
3780
3847
|
}).join(" ");
|
|
3781
3848
|
} else {
|
|
3782
3849
|
const halfWidth = width / 2;
|
|
3783
3850
|
const halfHeight = height / 2;
|
|
3784
|
-
const topLeft =
|
|
3851
|
+
const topLeft = applyToPoint31(transform, [
|
|
3785
3852
|
center.x - halfWidth,
|
|
3786
3853
|
center.y - halfHeight
|
|
3787
3854
|
]);
|
|
3788
|
-
const topRight =
|
|
3855
|
+
const topRight = applyToPoint31(transform, [
|
|
3789
3856
|
center.x + halfWidth,
|
|
3790
3857
|
center.y - halfHeight
|
|
3791
3858
|
]);
|
|
3792
|
-
const bottomRight =
|
|
3859
|
+
const bottomRight = applyToPoint31(transform, [
|
|
3793
3860
|
center.x + halfWidth,
|
|
3794
3861
|
center.y + halfHeight
|
|
3795
3862
|
]);
|
|
3796
|
-
const bottomLeft =
|
|
3863
|
+
const bottomLeft = applyToPoint31(transform, [
|
|
3797
3864
|
center.x - halfWidth,
|
|
3798
3865
|
center.y + halfHeight
|
|
3799
3866
|
]);
|
|
@@ -3819,7 +3886,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
3819
3886
|
}
|
|
3820
3887
|
|
|
3821
3888
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
3822
|
-
import { applyToPoint as
|
|
3889
|
+
import { applyToPoint as applyToPoint33 } from "transformation-matrix";
|
|
3823
3890
|
|
|
3824
3891
|
// lib/utils/get-sch-font-size.ts
|
|
3825
3892
|
import "transformation-matrix";
|
|
@@ -3845,8 +3912,8 @@ function createSvgObjectsFromAssemblyComponent(params, ctx) {
|
|
|
3845
3912
|
const { center, width, height, rotation = 0, layer = "top" } = elm;
|
|
3846
3913
|
if (!center || typeof width !== "number" || typeof height !== "number")
|
|
3847
3914
|
return null;
|
|
3848
|
-
const [x, y] =
|
|
3849
|
-
const [pinX, pinY] =
|
|
3915
|
+
const [x, y] = applyToPoint33(transform, [center.x, center.y]);
|
|
3916
|
+
const [pinX, pinY] = applyToPoint33(transform, [portPosition.x, portPosition.y]);
|
|
3850
3917
|
const scaledWidth = width * Math.abs(transform.a);
|
|
3851
3918
|
const scaledHeight = height * Math.abs(transform.d);
|
|
3852
3919
|
const isTopLayer = layer === "top";
|
|
@@ -4008,11 +4075,11 @@ function getRectPathData(w, h, rotation) {
|
|
|
4008
4075
|
}
|
|
4009
4076
|
|
|
4010
4077
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-hole.ts
|
|
4011
|
-
import { applyToPoint as
|
|
4078
|
+
import { applyToPoint as applyToPoint34 } from "transformation-matrix";
|
|
4012
4079
|
var HOLE_COLOR2 = "rgb(190, 190, 190)";
|
|
4013
4080
|
function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
4014
4081
|
const { transform } = ctx;
|
|
4015
|
-
const [x, y] =
|
|
4082
|
+
const [x, y] = applyToPoint34(transform, [hole.x, hole.y]);
|
|
4016
4083
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
4017
4084
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
4018
4085
|
const radius = scaledDiameter / 2;
|
|
@@ -4076,12 +4143,12 @@ function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
|
4076
4143
|
}
|
|
4077
4144
|
|
|
4078
4145
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-plated-hole.ts
|
|
4079
|
-
import { applyToPoint as
|
|
4146
|
+
import { applyToPoint as applyToPoint35 } from "transformation-matrix";
|
|
4080
4147
|
var PAD_COLOR = "rgb(210, 210, 210)";
|
|
4081
4148
|
var HOLE_COLOR3 = "rgb(190, 190, 190)";
|
|
4082
4149
|
function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
4083
4150
|
const { transform } = ctx;
|
|
4084
|
-
const [x, y] =
|
|
4151
|
+
const [x, y] = applyToPoint35(transform, [hole.x, hole.y]);
|
|
4085
4152
|
if (hole.shape === "pill") {
|
|
4086
4153
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
4087
4154
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -4176,7 +4243,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
4176
4243
|
const scaledRectPadHeight = circularHole.rect_pad_height * Math.abs(transform.a);
|
|
4177
4244
|
const scaledRectBorderRadius = (circularHole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
4178
4245
|
const holeRadius = scaledHoleDiameter / 2;
|
|
4179
|
-
const [holeCx, holeCy] =
|
|
4246
|
+
const [holeCx, holeCy] = applyToPoint35(transform, [
|
|
4180
4247
|
circularHole.x + circularHole.hole_offset_x,
|
|
4181
4248
|
circularHole.y + circularHole.hole_offset_y
|
|
4182
4249
|
]);
|
|
@@ -4234,7 +4301,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
4234
4301
|
const pillHoleWithOffsets = pillHole;
|
|
4235
4302
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
4236
4303
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
4237
|
-
const [holeCenterX, holeCenterY] =
|
|
4304
|
+
const [holeCenterX, holeCenterY] = applyToPoint35(transform, [
|
|
4238
4305
|
pillHole.x + holeOffsetX,
|
|
4239
4306
|
pillHole.y + holeOffsetY
|
|
4240
4307
|
]);
|
|
@@ -4296,7 +4363,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
4296
4363
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
4297
4364
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
4298
4365
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
4299
|
-
const [holeCenterX, holeCenterY] =
|
|
4366
|
+
const [holeCenterX, holeCenterY] = applyToPoint35(transform, [
|
|
4300
4367
|
rotatedHole.x + holeOffsetX,
|
|
4301
4368
|
rotatedHole.y + holeOffsetY
|
|
4302
4369
|
]);
|
|
@@ -4352,14 +4419,14 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
4352
4419
|
}
|
|
4353
4420
|
|
|
4354
4421
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-smt-pad.ts
|
|
4355
|
-
import { applyToPoint as
|
|
4422
|
+
import { applyToPoint as applyToPoint36 } from "transformation-matrix";
|
|
4356
4423
|
var PAD_COLOR2 = "rgb(210, 210, 210)";
|
|
4357
4424
|
function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
4358
4425
|
const { transform } = ctx;
|
|
4359
4426
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
4360
4427
|
const width = pad.width * Math.abs(transform.a);
|
|
4361
4428
|
const height = pad.height * Math.abs(transform.d);
|
|
4362
|
-
const [x, y] =
|
|
4429
|
+
const [x, y] = applyToPoint36(transform, [pad.x, pad.y]);
|
|
4363
4430
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
4364
4431
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
4365
4432
|
return [
|
|
@@ -4411,7 +4478,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
4411
4478
|
const width = pad.width * Math.abs(transform.a);
|
|
4412
4479
|
const height = pad.height * Math.abs(transform.d);
|
|
4413
4480
|
const radius = pad.radius * Math.abs(transform.a);
|
|
4414
|
-
const [x, y] =
|
|
4481
|
+
const [x, y] = applyToPoint36(transform, [pad.x, pad.y]);
|
|
4415
4482
|
return [
|
|
4416
4483
|
{
|
|
4417
4484
|
name: "rect",
|
|
@@ -4434,7 +4501,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
4434
4501
|
}
|
|
4435
4502
|
if (pad.shape === "circle") {
|
|
4436
4503
|
const radius = pad.radius * Math.abs(transform.a);
|
|
4437
|
-
const [x, y] =
|
|
4504
|
+
const [x, y] = applyToPoint36(transform, [pad.x, pad.y]);
|
|
4438
4505
|
return [
|
|
4439
4506
|
{
|
|
4440
4507
|
name: "circle",
|
|
@@ -4454,7 +4521,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
4454
4521
|
}
|
|
4455
4522
|
if (pad.shape === "polygon") {
|
|
4456
4523
|
const points = (pad.points ?? []).map(
|
|
4457
|
-
(point) =>
|
|
4524
|
+
(point) => applyToPoint36(transform, [point.x, point.y])
|
|
4458
4525
|
);
|
|
4459
4526
|
return [
|
|
4460
4527
|
{
|
|
@@ -4631,8 +4698,8 @@ function createSvgObjects2(elm, ctx, soup) {
|
|
|
4631
4698
|
}
|
|
4632
4699
|
}
|
|
4633
4700
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
4634
|
-
const [x1, y1] =
|
|
4635
|
-
const [x2, y2] =
|
|
4701
|
+
const [x1, y1] = applyToPoint37(transform, [minX, minY]);
|
|
4702
|
+
const [x2, y2] = applyToPoint37(transform, [maxX, maxY]);
|
|
4636
4703
|
const width = Math.abs(x2 - x1);
|
|
4637
4704
|
const height = Math.abs(y2 - y1);
|
|
4638
4705
|
const x = Math.min(x1, x2);
|
|
@@ -4661,7 +4728,7 @@ import {
|
|
|
4661
4728
|
} from "transformation-matrix";
|
|
4662
4729
|
|
|
4663
4730
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-board.ts
|
|
4664
|
-
import { applyToPoint as
|
|
4731
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
4665
4732
|
import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
4666
4733
|
var BOARD_FILL_COLOR = "rgb(26, 115, 143)";
|
|
4667
4734
|
var BOARD_STROKE_COLOR = "rgba(0,0,0,0.9)";
|
|
@@ -4675,25 +4742,25 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4675
4742
|
let path;
|
|
4676
4743
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
4677
4744
|
path = outline.map((point, index) => {
|
|
4678
|
-
const [x, y] =
|
|
4745
|
+
const [x, y] = applyToPoint38(transform, [point.x, point.y]);
|
|
4679
4746
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
4680
4747
|
}).join(" ");
|
|
4681
4748
|
} else {
|
|
4682
4749
|
const halfWidth = width / 2;
|
|
4683
4750
|
const halfHeight = height / 2;
|
|
4684
|
-
const topLeft =
|
|
4751
|
+
const topLeft = applyToPoint38(transform, [
|
|
4685
4752
|
center.x - halfWidth,
|
|
4686
4753
|
center.y - halfHeight
|
|
4687
4754
|
]);
|
|
4688
|
-
const topRight =
|
|
4755
|
+
const topRight = applyToPoint38(transform, [
|
|
4689
4756
|
center.x + halfWidth,
|
|
4690
4757
|
center.y - halfHeight
|
|
4691
4758
|
]);
|
|
4692
|
-
const bottomRight =
|
|
4759
|
+
const bottomRight = applyToPoint38(transform, [
|
|
4693
4760
|
center.x + halfWidth,
|
|
4694
4761
|
center.y + halfHeight
|
|
4695
4762
|
]);
|
|
4696
|
-
const bottomLeft =
|
|
4763
|
+
const bottomLeft = applyToPoint38(transform, [
|
|
4697
4764
|
center.x - halfWidth,
|
|
4698
4765
|
center.y + halfHeight
|
|
4699
4766
|
]);
|
|
@@ -4711,10 +4778,10 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4711
4778
|
const halfWidth = width2 / 2;
|
|
4712
4779
|
const halfHeight = height2 / 2;
|
|
4713
4780
|
const [tl, tr, br, bl] = [
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4781
|
+
applyToPoint38(transform, [x - halfWidth, y - halfHeight]),
|
|
4782
|
+
applyToPoint38(transform, [x + halfWidth, y - halfHeight]),
|
|
4783
|
+
applyToPoint38(transform, [x + halfWidth, y + halfHeight]),
|
|
4784
|
+
applyToPoint38(transform, [x - halfWidth, y + halfHeight])
|
|
4718
4785
|
];
|
|
4719
4786
|
path += ` M ${tl[0]} ${tl[1]} L ${tr[0]} ${tr[1]} L ${br[0]} ${br[1]} L ${bl[0]} ${bl[1]} Z`;
|
|
4720
4787
|
} else if (cutout.shape === "circle") {
|
|
@@ -4764,7 +4831,7 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
4764
4831
|
|
|
4765
4832
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-component.ts
|
|
4766
4833
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
4767
|
-
import { applyToPoint as
|
|
4834
|
+
import { applyToPoint as applyToPoint39 } from "transformation-matrix";
|
|
4768
4835
|
var COMPONENT_FILL_COLOR = "rgba(120, 120, 120, 0.6)";
|
|
4769
4836
|
var COMPONENT_LABEL_COLOR = "rgba(255, 255, 255, 0.9)";
|
|
4770
4837
|
function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
@@ -4774,7 +4841,7 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
4774
4841
|
if (!center || typeof width !== "number" || typeof height !== "number" || width === 0 || height === 0) {
|
|
4775
4842
|
return [];
|
|
4776
4843
|
}
|
|
4777
|
-
const [x, y] =
|
|
4844
|
+
const [x, y] = applyToPoint39(transform, [center.x, center.y]);
|
|
4778
4845
|
const scaledWidth = width * Math.abs(transform.a);
|
|
4779
4846
|
const scaledHeight = height * Math.abs(transform.d);
|
|
4780
4847
|
const transformStr = `translate(${x}, ${y})`;
|
|
@@ -4835,11 +4902,11 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
4835
4902
|
}
|
|
4836
4903
|
|
|
4837
4904
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-hole.ts
|
|
4838
|
-
import { applyToPoint as
|
|
4905
|
+
import { applyToPoint as applyToPoint40 } from "transformation-matrix";
|
|
4839
4906
|
var HOLE_COLOR4 = "rgb(50, 50, 50)";
|
|
4840
4907
|
function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
4841
4908
|
const { transform } = ctx;
|
|
4842
|
-
const [x, y] =
|
|
4909
|
+
const [x, y] = applyToPoint40(transform, [hole.x, hole.y]);
|
|
4843
4910
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
4844
4911
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
4845
4912
|
const radius = scaledDiameter / 2;
|
|
@@ -4903,12 +4970,12 @@ function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
|
4903
4970
|
}
|
|
4904
4971
|
|
|
4905
4972
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-plated-hole.ts
|
|
4906
|
-
import { applyToPoint as
|
|
4973
|
+
import { applyToPoint as applyToPoint41 } from "transformation-matrix";
|
|
4907
4974
|
var PAD_COLOR3 = "rgb(218, 165, 32)";
|
|
4908
4975
|
var HOLE_COLOR5 = "rgb(40, 40, 40)";
|
|
4909
4976
|
function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
4910
4977
|
const { transform } = ctx;
|
|
4911
|
-
const [x, y] =
|
|
4978
|
+
const [x, y] = applyToPoint41(transform, [hole.x, hole.y]);
|
|
4912
4979
|
if (hole.shape === "pill") {
|
|
4913
4980
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
4914
4981
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -5143,14 +5210,14 @@ function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
|
5143
5210
|
}
|
|
5144
5211
|
|
|
5145
5212
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-smt-pad.ts
|
|
5146
|
-
import { applyToPoint as
|
|
5213
|
+
import { applyToPoint as applyToPoint42 } from "transformation-matrix";
|
|
5147
5214
|
var PAD_COLOR4 = "rgb(218, 165, 32)";
|
|
5148
5215
|
function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
5149
5216
|
const { transform } = ctx;
|
|
5150
5217
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
5151
5218
|
const width = pad.width * Math.abs(transform.a);
|
|
5152
5219
|
const height = pad.height * Math.abs(transform.d);
|
|
5153
|
-
const [x, y] =
|
|
5220
|
+
const [x, y] = applyToPoint42(transform, [pad.x, pad.y]);
|
|
5154
5221
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
5155
5222
|
return [
|
|
5156
5223
|
{
|
|
@@ -5193,7 +5260,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
5193
5260
|
const width = pad.width * Math.abs(transform.a);
|
|
5194
5261
|
const height = pad.height * Math.abs(transform.d);
|
|
5195
5262
|
const radius = pad.radius * Math.abs(transform.a);
|
|
5196
|
-
const [x, y] =
|
|
5263
|
+
const [x, y] = applyToPoint42(transform, [pad.x, pad.y]);
|
|
5197
5264
|
return [
|
|
5198
5265
|
{
|
|
5199
5266
|
name: "rect",
|
|
@@ -5216,7 +5283,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
5216
5283
|
}
|
|
5217
5284
|
if (pad.shape === "circle") {
|
|
5218
5285
|
const radius = pad.radius * Math.abs(transform.a);
|
|
5219
|
-
const [x, y] =
|
|
5286
|
+
const [x, y] = applyToPoint42(transform, [pad.x, pad.y]);
|
|
5220
5287
|
return [
|
|
5221
5288
|
{
|
|
5222
5289
|
name: "circle",
|
|
@@ -5236,7 +5303,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
5236
5303
|
}
|
|
5237
5304
|
if (pad.shape === "polygon") {
|
|
5238
5305
|
const points = (pad.points ?? []).map(
|
|
5239
|
-
(point) =>
|
|
5306
|
+
(point) => applyToPoint42(transform, [point.x, point.y])
|
|
5240
5307
|
);
|
|
5241
5308
|
return [
|
|
5242
5309
|
{
|
|
@@ -5257,7 +5324,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
5257
5324
|
}
|
|
5258
5325
|
|
|
5259
5326
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-port.ts
|
|
5260
|
-
import { applyToPoint as
|
|
5327
|
+
import { applyToPoint as applyToPoint43 } from "transformation-matrix";
|
|
5261
5328
|
import { calculateElbow } from "calculate-elbow";
|
|
5262
5329
|
|
|
5263
5330
|
// lib/pinout/svg-object-fns/pinout-label-box.ts
|
|
@@ -5334,7 +5401,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
5334
5401
|
const label_info = ctx.label_positions.get(pcb_port.pcb_port_id);
|
|
5335
5402
|
if (!label_info) return [];
|
|
5336
5403
|
const { text: label, aliases, elbow_end, label_pos, edge } = label_info;
|
|
5337
|
-
const [port_x, port_y] =
|
|
5404
|
+
const [port_x, port_y] = applyToPoint43(ctx.transform, [pcb_port.x, pcb_port.y]);
|
|
5338
5405
|
const start_facing_direction = edge === "left" ? "x-" : edge === "right" ? "x+" : edge === "top" ? "y-" : "y+";
|
|
5339
5406
|
const end_facing_direction = edge === "left" ? "x+" : edge === "right" ? "x-" : edge === "top" ? "y+" : "y-";
|
|
5340
5407
|
const elbow_path = calculateElbow(
|
|
@@ -5475,7 +5542,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
5475
5542
|
}
|
|
5476
5543
|
|
|
5477
5544
|
// lib/pinout/calculate-label-positions.ts
|
|
5478
|
-
import { applyToPoint as
|
|
5545
|
+
import { applyToPoint as applyToPoint44 } from "transformation-matrix";
|
|
5479
5546
|
|
|
5480
5547
|
// lib/pinout/constants.ts
|
|
5481
5548
|
var LABEL_RECT_HEIGHT_BASE_MM = 1.6;
|
|
@@ -5513,7 +5580,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
5513
5580
|
);
|
|
5514
5581
|
const mapToEdgePort = (pinout_label) => ({
|
|
5515
5582
|
pcb_port: pinout_label.pcb_port,
|
|
5516
|
-
y:
|
|
5583
|
+
y: applyToPoint44(transform, [
|
|
5517
5584
|
pinout_label.pcb_port.x,
|
|
5518
5585
|
pinout_label.pcb_port.y
|
|
5519
5586
|
])[1],
|
|
@@ -5528,7 +5595,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
5528
5595
|
} else {
|
|
5529
5596
|
edge_ports = pinout_labels.map((pinout_label) => ({
|
|
5530
5597
|
pcb_port: pinout_label.pcb_port,
|
|
5531
|
-
y:
|
|
5598
|
+
y: applyToPoint44(transform, [
|
|
5532
5599
|
pinout_label.pcb_port.x,
|
|
5533
5600
|
pinout_label.pcb_port.y
|
|
5534
5601
|
])[1],
|
|
@@ -5536,7 +5603,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
5536
5603
|
})).sort((a, b) => a.y - b.y);
|
|
5537
5604
|
}
|
|
5538
5605
|
if (edge_ports.length === 0) return;
|
|
5539
|
-
const board_edge_x =
|
|
5606
|
+
const board_edge_x = applyToPoint44(transform, [
|
|
5540
5607
|
edge === "left" ? board_bounds.minX : board_bounds.maxX,
|
|
5541
5608
|
0
|
|
5542
5609
|
])[0];
|
|
@@ -5951,14 +6018,14 @@ import {
|
|
|
5951
6018
|
} from "transformation-matrix";
|
|
5952
6019
|
|
|
5953
6020
|
// lib/sch/draw-schematic-grid.ts
|
|
5954
|
-
import { applyToPoint as
|
|
6021
|
+
import { applyToPoint as applyToPoint45 } from "transformation-matrix";
|
|
5955
6022
|
function drawSchematicGrid(params) {
|
|
5956
6023
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
5957
6024
|
const cellSize = params.cellSize ?? 1;
|
|
5958
6025
|
const labelCells = params.labelCells ?? false;
|
|
5959
6026
|
const gridLines = [];
|
|
5960
6027
|
const transformPoint = (x, y) => {
|
|
5961
|
-
const [transformedX, transformedY] =
|
|
6028
|
+
const [transformedX, transformedY] = applyToPoint45(params.transform, [x, y]);
|
|
5962
6029
|
return { x: transformedX, y: transformedY };
|
|
5963
6030
|
};
|
|
5964
6031
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -6039,15 +6106,15 @@ function drawSchematicGrid(params) {
|
|
|
6039
6106
|
}
|
|
6040
6107
|
|
|
6041
6108
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
6042
|
-
import { applyToPoint as
|
|
6109
|
+
import { applyToPoint as applyToPoint46 } from "transformation-matrix";
|
|
6043
6110
|
function drawSchematicLabeledPoints(params) {
|
|
6044
6111
|
const { points, transform } = params;
|
|
6045
6112
|
const labeledPointsGroup = [];
|
|
6046
6113
|
for (const point of points) {
|
|
6047
|
-
const [x1, y1] =
|
|
6048
|
-
const [x2, y2] =
|
|
6049
|
-
const [x3, y3] =
|
|
6050
|
-
const [x4, y4] =
|
|
6114
|
+
const [x1, y1] = applyToPoint46(transform, [point.x - 0.1, point.y - 0.1]);
|
|
6115
|
+
const [x2, y2] = applyToPoint46(transform, [point.x + 0.1, point.y + 0.1]);
|
|
6116
|
+
const [x3, y3] = applyToPoint46(transform, [point.x - 0.1, point.y + 0.1]);
|
|
6117
|
+
const [x4, y4] = applyToPoint46(transform, [point.x + 0.1, point.y - 0.1]);
|
|
6051
6118
|
labeledPointsGroup.push({
|
|
6052
6119
|
name: "path",
|
|
6053
6120
|
type: "element",
|
|
@@ -6058,7 +6125,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
6058
6125
|
"stroke-opacity": "0.7"
|
|
6059
6126
|
}
|
|
6060
6127
|
});
|
|
6061
|
-
const [labelX, labelY] =
|
|
6128
|
+
const [labelX, labelY] = applyToPoint46(transform, [
|
|
6062
6129
|
point.x + 0.15,
|
|
6063
6130
|
point.y - 0.15
|
|
6064
6131
|
]);
|
|
@@ -7152,7 +7219,7 @@ import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
|
7152
7219
|
import { symbols } from "schematic-symbols";
|
|
7153
7220
|
import "svgson";
|
|
7154
7221
|
import {
|
|
7155
|
-
applyToPoint as
|
|
7222
|
+
applyToPoint as applyToPoint48,
|
|
7156
7223
|
compose as compose9
|
|
7157
7224
|
} from "transformation-matrix";
|
|
7158
7225
|
|
|
@@ -7236,13 +7303,13 @@ function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
|
7236
7303
|
}
|
|
7237
7304
|
|
|
7238
7305
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
7239
|
-
import { applyToPoint as
|
|
7306
|
+
import { applyToPoint as applyToPoint47 } from "transformation-matrix";
|
|
7240
7307
|
var createSvgSchErrorText = ({
|
|
7241
7308
|
text,
|
|
7242
7309
|
realCenter,
|
|
7243
7310
|
realToScreenTransform
|
|
7244
7311
|
}) => {
|
|
7245
|
-
const screenCenter =
|
|
7312
|
+
const screenCenter = applyToPoint47(realToScreenTransform, realCenter);
|
|
7246
7313
|
return {
|
|
7247
7314
|
type: "element",
|
|
7248
7315
|
name: "text",
|
|
@@ -7351,11 +7418,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7351
7418
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
7352
7419
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
7353
7420
|
};
|
|
7354
|
-
const [screenMinX, screenMinY] =
|
|
7421
|
+
const [screenMinX, screenMinY] = applyToPoint48(
|
|
7355
7422
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7356
7423
|
[bounds.minX, bounds.minY]
|
|
7357
7424
|
);
|
|
7358
|
-
const [screenMaxX, screenMaxY] =
|
|
7425
|
+
const [screenMaxX, screenMaxY] = applyToPoint48(
|
|
7359
7426
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7360
7427
|
[bounds.maxX, bounds.maxY]
|
|
7361
7428
|
);
|
|
@@ -7384,7 +7451,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7384
7451
|
name: "path",
|
|
7385
7452
|
attributes: {
|
|
7386
7453
|
d: points.map((p, i) => {
|
|
7387
|
-
const [x, y] =
|
|
7454
|
+
const [x, y] = applyToPoint48(
|
|
7388
7455
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7389
7456
|
[p.x, p.y]
|
|
7390
7457
|
);
|
|
@@ -7400,7 +7467,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7400
7467
|
});
|
|
7401
7468
|
}
|
|
7402
7469
|
for (const text of texts) {
|
|
7403
|
-
const screenTextPos =
|
|
7470
|
+
const screenTextPos = applyToPoint48(
|
|
7404
7471
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7405
7472
|
text
|
|
7406
7473
|
);
|
|
@@ -7452,7 +7519,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7452
7519
|
});
|
|
7453
7520
|
}
|
|
7454
7521
|
for (const box of boxes) {
|
|
7455
|
-
const screenBoxPos =
|
|
7522
|
+
const screenBoxPos = applyToPoint48(
|
|
7456
7523
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7457
7524
|
box
|
|
7458
7525
|
);
|
|
@@ -7476,7 +7543,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7476
7543
|
}
|
|
7477
7544
|
for (const port of symbol.ports) {
|
|
7478
7545
|
if (connectedSymbolPorts.has(port)) continue;
|
|
7479
|
-
const screenPortPos =
|
|
7546
|
+
const screenPortPos = applyToPoint48(
|
|
7480
7547
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7481
7548
|
port
|
|
7482
7549
|
);
|
|
@@ -7496,7 +7563,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7496
7563
|
});
|
|
7497
7564
|
}
|
|
7498
7565
|
for (const circle of circles) {
|
|
7499
|
-
const screenCirclePos =
|
|
7566
|
+
const screenCirclePos = applyToPoint48(
|
|
7500
7567
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7501
7568
|
circle
|
|
7502
7569
|
);
|
|
@@ -7523,14 +7590,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7523
7590
|
import { su as su10 } from "@tscircuit/circuit-json-util";
|
|
7524
7591
|
import "schematic-symbols";
|
|
7525
7592
|
import "svgson";
|
|
7526
|
-
import { applyToPoint as
|
|
7593
|
+
import { applyToPoint as applyToPoint54 } from "transformation-matrix";
|
|
7527
7594
|
|
|
7528
7595
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
7529
7596
|
import "transformation-matrix";
|
|
7530
7597
|
import "@tscircuit/circuit-json-util";
|
|
7531
7598
|
|
|
7532
7599
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
7533
|
-
import { applyToPoint as
|
|
7600
|
+
import { applyToPoint as applyToPoint49 } from "transformation-matrix";
|
|
7534
7601
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
7535
7602
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
7536
7603
|
var createArrow = (tip, angle, size, color, strokeWidth) => {
|
|
@@ -7583,8 +7650,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7583
7650
|
realEdgePos.y += realPinLineLength;
|
|
7584
7651
|
break;
|
|
7585
7652
|
}
|
|
7586
|
-
const screenSchPortPos =
|
|
7587
|
-
const screenRealEdgePos =
|
|
7653
|
+
const screenSchPortPos = applyToPoint49(transform, schPort.center);
|
|
7654
|
+
const screenRealEdgePos = applyToPoint49(transform, realEdgePos);
|
|
7588
7655
|
const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
|
|
7589
7656
|
const realLineEnd = { ...schPort.center };
|
|
7590
7657
|
if (!isConnected) {
|
|
@@ -7603,7 +7670,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7603
7670
|
break;
|
|
7604
7671
|
}
|
|
7605
7672
|
}
|
|
7606
|
-
const screenLineEnd =
|
|
7673
|
+
const screenLineEnd = applyToPoint49(transform, realLineEnd);
|
|
7607
7674
|
svgObjects.push({
|
|
7608
7675
|
name: "line",
|
|
7609
7676
|
type: "element",
|
|
@@ -7724,7 +7791,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7724
7791
|
};
|
|
7725
7792
|
|
|
7726
7793
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
7727
|
-
import { applyToPoint as
|
|
7794
|
+
import { applyToPoint as applyToPoint50 } from "transformation-matrix";
|
|
7728
7795
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
7729
7796
|
const svgObjects = [];
|
|
7730
7797
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -7742,7 +7809,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
7742
7809
|
} else {
|
|
7743
7810
|
realPinNumberPos.y += 0.02;
|
|
7744
7811
|
}
|
|
7745
|
-
const screenPinNumberTextPos =
|
|
7812
|
+
const screenPinNumberTextPos = applyToPoint50(transform, realPinNumberPos);
|
|
7746
7813
|
svgObjects.push({
|
|
7747
7814
|
name: "text",
|
|
7748
7815
|
type: "element",
|
|
@@ -7772,7 +7839,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
7772
7839
|
};
|
|
7773
7840
|
|
|
7774
7841
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
7775
|
-
import { applyToPoint as
|
|
7842
|
+
import { applyToPoint as applyToPoint51 } from "transformation-matrix";
|
|
7776
7843
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
7777
7844
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
7778
7845
|
const svgObjects = [];
|
|
@@ -7786,7 +7853,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
7786
7853
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
7787
7854
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
7788
7855
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
7789
|
-
const screenPinNumberTextPos =
|
|
7856
|
+
const screenPinNumberTextPos = applyToPoint51(transform, realPinNumberPos);
|
|
7790
7857
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
7791
7858
|
if (!label) return [];
|
|
7792
7859
|
const isNegated = label.startsWith("N_");
|
|
@@ -7834,13 +7901,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
7834
7901
|
};
|
|
7835
7902
|
|
|
7836
7903
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
7837
|
-
import { applyToPoint as
|
|
7904
|
+
import { applyToPoint as applyToPoint53 } from "transformation-matrix";
|
|
7838
7905
|
var createSvgSchText = ({
|
|
7839
7906
|
elm,
|
|
7840
7907
|
transform,
|
|
7841
7908
|
colorMap: colorMap2
|
|
7842
7909
|
}) => {
|
|
7843
|
-
const center =
|
|
7910
|
+
const center = applyToPoint53(transform, elm.position);
|
|
7844
7911
|
const textAnchorMap = {
|
|
7845
7912
|
center: "middle",
|
|
7846
7913
|
center_right: "end",
|
|
@@ -7924,11 +7991,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
7924
7991
|
colorMap: colorMap2
|
|
7925
7992
|
}) => {
|
|
7926
7993
|
const svgObjects = [];
|
|
7927
|
-
const componentScreenTopLeft =
|
|
7994
|
+
const componentScreenTopLeft = applyToPoint54(transform, {
|
|
7928
7995
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
7929
7996
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
7930
7997
|
});
|
|
7931
|
-
const componentScreenBottomRight =
|
|
7998
|
+
const componentScreenBottomRight = applyToPoint54(transform, {
|
|
7932
7999
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
7933
8000
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
7934
8001
|
});
|
|
@@ -8014,13 +8081,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
8014
8081
|
}
|
|
8015
8082
|
|
|
8016
8083
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
8017
|
-
import { applyToPoint as
|
|
8084
|
+
import { applyToPoint as applyToPoint55 } from "transformation-matrix";
|
|
8018
8085
|
function createSvgObjectsFromSchVoltageProbe({
|
|
8019
8086
|
probe,
|
|
8020
8087
|
transform,
|
|
8021
8088
|
colorMap: colorMap2
|
|
8022
8089
|
}) {
|
|
8023
|
-
const [screenX, screenY] =
|
|
8090
|
+
const [screenX, screenY] = applyToPoint55(transform, [
|
|
8024
8091
|
probe.position.x,
|
|
8025
8092
|
probe.position.y
|
|
8026
8093
|
]);
|
|
@@ -8080,17 +8147,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
8080
8147
|
}
|
|
8081
8148
|
|
|
8082
8149
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
8083
|
-
import { applyToPoint as
|
|
8150
|
+
import { applyToPoint as applyToPoint56 } from "transformation-matrix";
|
|
8084
8151
|
function createSvgObjectsFromSchDebugObject({
|
|
8085
8152
|
debugObject,
|
|
8086
8153
|
transform
|
|
8087
8154
|
}) {
|
|
8088
8155
|
if (debugObject.shape === "rect") {
|
|
8089
|
-
let [screenLeft, screenTop] =
|
|
8156
|
+
let [screenLeft, screenTop] = applyToPoint56(transform, [
|
|
8090
8157
|
debugObject.center.x - debugObject.size.width / 2,
|
|
8091
8158
|
debugObject.center.y - debugObject.size.height / 2
|
|
8092
8159
|
]);
|
|
8093
|
-
let [screenRight, screenBottom] =
|
|
8160
|
+
let [screenRight, screenBottom] = applyToPoint56(transform, [
|
|
8094
8161
|
debugObject.center.x + debugObject.size.width / 2,
|
|
8095
8162
|
debugObject.center.y + debugObject.size.height / 2
|
|
8096
8163
|
]);
|
|
@@ -8100,7 +8167,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
8100
8167
|
];
|
|
8101
8168
|
const width = Math.abs(screenRight - screenLeft);
|
|
8102
8169
|
const height = Math.abs(screenBottom - screenTop);
|
|
8103
|
-
const [screenCenterX, screenCenterY] =
|
|
8170
|
+
const [screenCenterX, screenCenterY] = applyToPoint56(transform, [
|
|
8104
8171
|
debugObject.center.x,
|
|
8105
8172
|
debugObject.center.y
|
|
8106
8173
|
]);
|
|
@@ -8146,11 +8213,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
8146
8213
|
];
|
|
8147
8214
|
}
|
|
8148
8215
|
if (debugObject.shape === "line") {
|
|
8149
|
-
const [screenStartX, screenStartY] =
|
|
8216
|
+
const [screenStartX, screenStartY] = applyToPoint56(transform, [
|
|
8150
8217
|
debugObject.start.x,
|
|
8151
8218
|
debugObject.start.y
|
|
8152
8219
|
]);
|
|
8153
|
-
const [screenEndX, screenEndY] =
|
|
8220
|
+
const [screenEndX, screenEndY] = applyToPoint56(transform, [
|
|
8154
8221
|
debugObject.end.x,
|
|
8155
8222
|
debugObject.end.y
|
|
8156
8223
|
]);
|
|
@@ -8200,7 +8267,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
8200
8267
|
}
|
|
8201
8268
|
|
|
8202
8269
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
8203
|
-
import { applyToPoint as
|
|
8270
|
+
import { applyToPoint as applyToPoint57 } from "transformation-matrix";
|
|
8204
8271
|
function createSchematicTrace({
|
|
8205
8272
|
trace,
|
|
8206
8273
|
transform,
|
|
@@ -8214,11 +8281,11 @@ function createSchematicTrace({
|
|
|
8214
8281
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
8215
8282
|
const edge = edges[edgeIndex];
|
|
8216
8283
|
if (edge.is_crossing) continue;
|
|
8217
|
-
const [screenFromX, screenFromY] =
|
|
8284
|
+
const [screenFromX, screenFromY] = applyToPoint57(transform, [
|
|
8218
8285
|
edge.from.x,
|
|
8219
8286
|
edge.from.y
|
|
8220
8287
|
]);
|
|
8221
|
-
const [screenToX, screenToY] =
|
|
8288
|
+
const [screenToX, screenToY] = applyToPoint57(transform, [
|
|
8222
8289
|
edge.to.x,
|
|
8223
8290
|
edge.to.y
|
|
8224
8291
|
]);
|
|
@@ -8262,11 +8329,11 @@ function createSchematicTrace({
|
|
|
8262
8329
|
}
|
|
8263
8330
|
for (const edge of edges) {
|
|
8264
8331
|
if (!edge.is_crossing) continue;
|
|
8265
|
-
const [screenFromX, screenFromY] =
|
|
8332
|
+
const [screenFromX, screenFromY] = applyToPoint57(transform, [
|
|
8266
8333
|
edge.from.x,
|
|
8267
8334
|
edge.from.y
|
|
8268
8335
|
]);
|
|
8269
|
-
const [screenToX, screenToY] =
|
|
8336
|
+
const [screenToX, screenToY] = applyToPoint57(transform, [
|
|
8270
8337
|
edge.to.x,
|
|
8271
8338
|
edge.to.y
|
|
8272
8339
|
]);
|
|
@@ -8310,7 +8377,7 @@ function createSchematicTrace({
|
|
|
8310
8377
|
}
|
|
8311
8378
|
if (trace.junctions) {
|
|
8312
8379
|
for (const junction of trace.junctions) {
|
|
8313
|
-
const [screenX, screenY] =
|
|
8380
|
+
const [screenX, screenY] = applyToPoint57(transform, [
|
|
8314
8381
|
junction.x,
|
|
8315
8382
|
junction.y
|
|
8316
8383
|
]);
|
|
@@ -8365,7 +8432,7 @@ function createSchematicTrace({
|
|
|
8365
8432
|
|
|
8366
8433
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
8367
8434
|
import {
|
|
8368
|
-
applyToPoint as
|
|
8435
|
+
applyToPoint as applyToPoint59,
|
|
8369
8436
|
compose as compose11,
|
|
8370
8437
|
rotate as rotate6,
|
|
8371
8438
|
scale as scale6,
|
|
@@ -8374,7 +8441,7 @@ import {
|
|
|
8374
8441
|
|
|
8375
8442
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
8376
8443
|
import {
|
|
8377
|
-
applyToPoint as
|
|
8444
|
+
applyToPoint as applyToPoint58,
|
|
8378
8445
|
compose as compose10,
|
|
8379
8446
|
rotate as rotate5,
|
|
8380
8447
|
scale as scale5,
|
|
@@ -8449,7 +8516,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8449
8516
|
x: symbolBounds.minX,
|
|
8450
8517
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
8451
8518
|
};
|
|
8452
|
-
const rotatedSymbolEnd =
|
|
8519
|
+
const rotatedSymbolEnd = applyToPoint58(rotationMatrix, symbolEndPoint);
|
|
8453
8520
|
const symbolToRealTransform = compose10(
|
|
8454
8521
|
translate10(
|
|
8455
8522
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
@@ -8459,11 +8526,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8459
8526
|
scale5(1)
|
|
8460
8527
|
// Use full symbol size
|
|
8461
8528
|
);
|
|
8462
|
-
const [screenMinX, screenMinY] =
|
|
8529
|
+
const [screenMinX, screenMinY] = applyToPoint58(
|
|
8463
8530
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8464
8531
|
[bounds.minX, bounds.minY]
|
|
8465
8532
|
);
|
|
8466
|
-
const [screenMaxX, screenMaxY] =
|
|
8533
|
+
const [screenMaxX, screenMaxY] = applyToPoint58(
|
|
8467
8534
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8468
8535
|
[bounds.maxX, bounds.maxY]
|
|
8469
8536
|
);
|
|
@@ -8487,7 +8554,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8487
8554
|
});
|
|
8488
8555
|
for (const path of symbolPaths) {
|
|
8489
8556
|
const symbolPath = path.points.map((p, i) => {
|
|
8490
|
-
const [x, y] =
|
|
8557
|
+
const [x, y] = applyToPoint58(
|
|
8491
8558
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8492
8559
|
[p.x, p.y]
|
|
8493
8560
|
);
|
|
@@ -8508,7 +8575,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8508
8575
|
});
|
|
8509
8576
|
}
|
|
8510
8577
|
for (const text of symbolTexts) {
|
|
8511
|
-
const screenTextPos =
|
|
8578
|
+
const screenTextPos = applyToPoint58(
|
|
8512
8579
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8513
8580
|
text
|
|
8514
8581
|
);
|
|
@@ -8550,7 +8617,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8550
8617
|
});
|
|
8551
8618
|
}
|
|
8552
8619
|
for (const box of symbolBoxes) {
|
|
8553
|
-
const screenBoxPos =
|
|
8620
|
+
const screenBoxPos = applyToPoint58(
|
|
8554
8621
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8555
8622
|
box
|
|
8556
8623
|
);
|
|
@@ -8573,7 +8640,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8573
8640
|
});
|
|
8574
8641
|
}
|
|
8575
8642
|
for (const circle of symbolCircles) {
|
|
8576
|
-
const screenCirclePos =
|
|
8643
|
+
const screenCirclePos = applyToPoint58(
|
|
8577
8644
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8578
8645
|
circle
|
|
8579
8646
|
);
|
|
@@ -8618,14 +8685,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
8618
8685
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
8619
8686
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
8620
8687
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
8621
|
-
const screenCenter =
|
|
8688
|
+
const screenCenter = applyToPoint59(realToScreenTransform, schNetLabel.center);
|
|
8622
8689
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
8623
8690
|
schNetLabel.anchor_side
|
|
8624
8691
|
);
|
|
8625
8692
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
8626
8693
|
screenTextGrowthVec.y *= -1;
|
|
8627
8694
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
8628
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
8695
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint59(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
8629
8696
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
8630
8697
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
8631
8698
|
};
|
|
@@ -8666,7 +8733,7 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
8666
8733
|
y: -0.6
|
|
8667
8734
|
}
|
|
8668
8735
|
].map(
|
|
8669
|
-
(fontRelativePoint) =>
|
|
8736
|
+
(fontRelativePoint) => applyToPoint59(
|
|
8670
8737
|
compose11(
|
|
8671
8738
|
realToScreenTransform,
|
|
8672
8739
|
translate11(realAnchorPosition.x, realAnchorPosition.y),
|
|
@@ -8743,17 +8810,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
8743
8810
|
};
|
|
8744
8811
|
|
|
8745
8812
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
8746
|
-
import { applyToPoint as
|
|
8813
|
+
import { applyToPoint as applyToPoint60 } from "transformation-matrix";
|
|
8747
8814
|
var createSvgObjectsFromSchematicBox = ({
|
|
8748
8815
|
schematicBox,
|
|
8749
8816
|
transform,
|
|
8750
8817
|
colorMap: colorMap2
|
|
8751
8818
|
}) => {
|
|
8752
|
-
const topLeft =
|
|
8819
|
+
const topLeft = applyToPoint60(transform, {
|
|
8753
8820
|
x: schematicBox.x,
|
|
8754
8821
|
y: schematicBox.y
|
|
8755
8822
|
});
|
|
8756
|
-
const bottomRight =
|
|
8823
|
+
const bottomRight = applyToPoint60(transform, {
|
|
8757
8824
|
x: schematicBox.x + schematicBox.width,
|
|
8758
8825
|
y: schematicBox.y + schematicBox.height
|
|
8759
8826
|
});
|
|
@@ -8789,7 +8856,7 @@ var createSvgObjectsFromSchematicBox = ({
|
|
|
8789
8856
|
};
|
|
8790
8857
|
|
|
8791
8858
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-table.ts
|
|
8792
|
-
import { applyToPoint as
|
|
8859
|
+
import { applyToPoint as applyToPoint61 } from "transformation-matrix";
|
|
8793
8860
|
var createSvgObjectsFromSchematicTable = ({
|
|
8794
8861
|
schematicTable,
|
|
8795
8862
|
transform,
|
|
@@ -8822,11 +8889,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8822
8889
|
const svgObjects = [];
|
|
8823
8890
|
const borderStrokeWidth = border_width * Math.abs(transform.a);
|
|
8824
8891
|
const gridStrokeWidth = getSchStrokeSize(transform);
|
|
8825
|
-
const [screenTopLeftX, screenTopLeftY] =
|
|
8892
|
+
const [screenTopLeftX, screenTopLeftY] = applyToPoint61(transform, [
|
|
8826
8893
|
topLeftX,
|
|
8827
8894
|
topLeftY
|
|
8828
8895
|
]);
|
|
8829
|
-
const [screenBottomRightX, screenBottomRightY] =
|
|
8896
|
+
const [screenBottomRightX, screenBottomRightY] = applyToPoint61(transform, [
|
|
8830
8897
|
topLeftX + totalWidth,
|
|
8831
8898
|
topLeftY - totalHeight
|
|
8832
8899
|
]);
|
|
@@ -8858,8 +8925,8 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8858
8925
|
(cell) => cell.start_column_index <= i && cell.end_column_index > i && cell.start_row_index <= j && cell.end_row_index >= j
|
|
8859
8926
|
);
|
|
8860
8927
|
if (!isMerged) {
|
|
8861
|
-
const start =
|
|
8862
|
-
const end =
|
|
8928
|
+
const start = applyToPoint61(transform, { x: currentX, y: segmentStartY });
|
|
8929
|
+
const end = applyToPoint61(transform, { x: currentX, y: segmentEndY });
|
|
8863
8930
|
svgObjects.push({
|
|
8864
8931
|
name: "line",
|
|
8865
8932
|
type: "element",
|
|
@@ -8888,11 +8955,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8888
8955
|
(cell) => cell.start_row_index <= i && cell.end_row_index > i && cell.start_column_index <= j && cell.end_column_index >= j
|
|
8889
8956
|
);
|
|
8890
8957
|
if (!isMerged) {
|
|
8891
|
-
const start =
|
|
8958
|
+
const start = applyToPoint61(transform, {
|
|
8892
8959
|
x: segmentStartX,
|
|
8893
8960
|
y: currentY
|
|
8894
8961
|
});
|
|
8895
|
-
const end =
|
|
8962
|
+
const end = applyToPoint61(transform, { x: segmentEndX, y: currentY });
|
|
8896
8963
|
svgObjects.push({
|
|
8897
8964
|
name: "line",
|
|
8898
8965
|
type: "element",
|
|
@@ -8934,7 +9001,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8934
9001
|
} else if (vertical_align === "bottom") {
|
|
8935
9002
|
realTextAnchorPos.y = cellTopLeftY - cellHeight + cell_padding;
|
|
8936
9003
|
}
|
|
8937
|
-
const screenTextAnchorPos =
|
|
9004
|
+
const screenTextAnchorPos = applyToPoint61(transform, realTextAnchorPos);
|
|
8938
9005
|
const fontSize = getSchScreenFontSize(
|
|
8939
9006
|
transform,
|
|
8940
9007
|
"reference_designator",
|
|
@@ -8990,13 +9057,13 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
8990
9057
|
|
|
8991
9058
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
|
|
8992
9059
|
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
8993
|
-
import { applyToPoint as
|
|
9060
|
+
import { applyToPoint as applyToPoint62 } from "transformation-matrix";
|
|
8994
9061
|
var PIN_CIRCLE_RADIUS_MM2 = 0.02;
|
|
8995
9062
|
var createSvgObjectsForSchPortHover = ({
|
|
8996
9063
|
schPort,
|
|
8997
9064
|
transform
|
|
8998
9065
|
}) => {
|
|
8999
|
-
const screenSchPortPos =
|
|
9066
|
+
const screenSchPortPos = applyToPoint62(transform, schPort.center);
|
|
9000
9067
|
const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
|
|
9001
9068
|
return [
|
|
9002
9069
|
{
|
|
@@ -9041,14 +9108,14 @@ var createSvgObjectsForSchComponentPortHovers = ({
|
|
|
9041
9108
|
};
|
|
9042
9109
|
|
|
9043
9110
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-line.ts
|
|
9044
|
-
import { applyToPoint as
|
|
9111
|
+
import { applyToPoint as applyToPoint63 } from "transformation-matrix";
|
|
9045
9112
|
function createSvgObjectsFromSchematicLine({
|
|
9046
9113
|
schLine,
|
|
9047
9114
|
transform,
|
|
9048
9115
|
colorMap: colorMap2
|
|
9049
9116
|
}) {
|
|
9050
|
-
const p1 =
|
|
9051
|
-
const p2 =
|
|
9117
|
+
const p1 = applyToPoint63(transform, { x: schLine.x1, y: schLine.y1 });
|
|
9118
|
+
const p2 = applyToPoint63(transform, { x: schLine.x2, y: schLine.y2 });
|
|
9052
9119
|
const strokeWidth = schLine.stroke_width ?? 0.02;
|
|
9053
9120
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
9054
9121
|
return [
|
|
@@ -9077,13 +9144,13 @@ function createSvgObjectsFromSchematicLine({
|
|
|
9077
9144
|
}
|
|
9078
9145
|
|
|
9079
9146
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-circle.ts
|
|
9080
|
-
import { applyToPoint as
|
|
9147
|
+
import { applyToPoint as applyToPoint64 } from "transformation-matrix";
|
|
9081
9148
|
function createSvgObjectsFromSchematicCircle({
|
|
9082
9149
|
schCircle,
|
|
9083
9150
|
transform,
|
|
9084
9151
|
colorMap: colorMap2
|
|
9085
9152
|
}) {
|
|
9086
|
-
const center =
|
|
9153
|
+
const center = applyToPoint64(transform, schCircle.center);
|
|
9087
9154
|
const transformedRadius = Math.abs(transform.a) * schCircle.radius;
|
|
9088
9155
|
const strokeWidth = schCircle.stroke_width ?? 0.02;
|
|
9089
9156
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -9113,13 +9180,13 @@ function createSvgObjectsFromSchematicCircle({
|
|
|
9113
9180
|
}
|
|
9114
9181
|
|
|
9115
9182
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-rect.ts
|
|
9116
|
-
import { applyToPoint as
|
|
9183
|
+
import { applyToPoint as applyToPoint65 } from "transformation-matrix";
|
|
9117
9184
|
function createSvgObjectsFromSchematicRect({
|
|
9118
9185
|
schRect,
|
|
9119
9186
|
transform,
|
|
9120
9187
|
colorMap: colorMap2
|
|
9121
9188
|
}) {
|
|
9122
|
-
const center =
|
|
9189
|
+
const center = applyToPoint65(transform, schRect.center);
|
|
9123
9190
|
const transformedWidth = Math.abs(transform.a) * schRect.width;
|
|
9124
9191
|
const transformedHeight = Math.abs(transform.d) * schRect.height;
|
|
9125
9192
|
const strokeWidth = schRect.stroke_width ?? 0.02;
|
|
@@ -9155,13 +9222,13 @@ function createSvgObjectsFromSchematicRect({
|
|
|
9155
9222
|
}
|
|
9156
9223
|
|
|
9157
9224
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-arc.ts
|
|
9158
|
-
import { applyToPoint as
|
|
9225
|
+
import { applyToPoint as applyToPoint66 } from "transformation-matrix";
|
|
9159
9226
|
function createSvgObjectsFromSchematicArc({
|
|
9160
9227
|
schArc,
|
|
9161
9228
|
transform,
|
|
9162
9229
|
colorMap: colorMap2
|
|
9163
9230
|
}) {
|
|
9164
|
-
const center =
|
|
9231
|
+
const center = applyToPoint66(transform, schArc.center);
|
|
9165
9232
|
const transformedRadius = Math.abs(transform.a) * schArc.radius;
|
|
9166
9233
|
const strokeWidth = schArc.stroke_width ?? 0.02;
|
|
9167
9234
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -10196,18 +10263,18 @@ function formatNumber2(value) {
|
|
|
10196
10263
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
10197
10264
|
import { stringify as stringify7 } from "svgson";
|
|
10198
10265
|
import {
|
|
10199
|
-
applyToPoint as
|
|
10266
|
+
applyToPoint as applyToPoint69,
|
|
10200
10267
|
compose as compose14,
|
|
10201
10268
|
scale as scale8,
|
|
10202
10269
|
translate as translate14
|
|
10203
10270
|
} from "transformation-matrix";
|
|
10204
10271
|
|
|
10205
10272
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
10206
|
-
import { applyToPoint as
|
|
10273
|
+
import { applyToPoint as applyToPoint68 } from "transformation-matrix";
|
|
10207
10274
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
10208
10275
|
const { transform, layer: layerFilter } = ctx;
|
|
10209
10276
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
10210
|
-
const [x, y] =
|
|
10277
|
+
const [x, y] = applyToPoint68(transform, [solderPaste.x, solderPaste.y]);
|
|
10211
10278
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
10212
10279
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
10213
10280
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -10418,8 +10485,8 @@ function createSvgObjects4({ elm, ctx }) {
|
|
|
10418
10485
|
}
|
|
10419
10486
|
}
|
|
10420
10487
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
10421
|
-
const [x1, y1] =
|
|
10422
|
-
const [x2, y2] =
|
|
10488
|
+
const [x1, y1] = applyToPoint69(transform, [minX, minY]);
|
|
10489
|
+
const [x2, y2] = applyToPoint69(transform, [maxX, maxY]);
|
|
10423
10490
|
const width = Math.abs(x2 - x1);
|
|
10424
10491
|
const height = Math.abs(y2 - y1);
|
|
10425
10492
|
const x = Math.min(x1, x2);
|