circuit-to-svg 0.0.301 → 0.0.303
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 +2 -0
- package/dist/index.js +404 -235
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { distance as distance2 } from "circuit-json";
|
|
3
3
|
import { stringify } from "svgson";
|
|
4
4
|
import {
|
|
5
|
-
applyToPoint as
|
|
6
|
-
compose as
|
|
5
|
+
applyToPoint as applyToPoint36,
|
|
6
|
+
compose as compose7,
|
|
7
7
|
scale as scale3,
|
|
8
|
-
translate as
|
|
8
|
+
translate as translate7
|
|
9
9
|
} from "transformation-matrix";
|
|
10
10
|
|
|
11
11
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace-error.ts
|
|
@@ -2751,6 +2751,8 @@ var DEFAULT_PCB_COLOR_MAP = {
|
|
|
2751
2751
|
},
|
|
2752
2752
|
boardOutline: "rgba(255, 255, 255, 0.5)",
|
|
2753
2753
|
courtyard: "#FF00FF",
|
|
2754
|
+
keepout: "#FF6B6B",
|
|
2755
|
+
// Red color for keepout zones
|
|
2754
2756
|
debugComponent: {
|
|
2755
2757
|
fill: null,
|
|
2756
2758
|
stroke: null
|
|
@@ -3161,8 +3163,61 @@ function createSvgObjectsFromPcbSilkscreenPill(pcbSilkscreenPill, ctx) {
|
|
|
3161
3163
|
return [svgObject];
|
|
3162
3164
|
}
|
|
3163
3165
|
|
|
3164
|
-
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-
|
|
3166
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-oval.ts
|
|
3165
3167
|
import { applyToPoint as applyToPoint20 } from "transformation-matrix";
|
|
3168
|
+
function createSvgObjectsFromPcbSilkscreenOval(pcbSilkscreenOval, ctx) {
|
|
3169
|
+
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
3170
|
+
const {
|
|
3171
|
+
center,
|
|
3172
|
+
radius_x,
|
|
3173
|
+
radius_y,
|
|
3174
|
+
layer = "top",
|
|
3175
|
+
pcb_silkscreen_oval_id,
|
|
3176
|
+
ccw_rotation = 0
|
|
3177
|
+
} = pcbSilkscreenOval;
|
|
3178
|
+
if (layerFilter && layer !== layerFilter) return [];
|
|
3179
|
+
if (!center || typeof center.x !== "number" || typeof center.y !== "number" || typeof radius_x !== "number" || typeof radius_y !== "number") {
|
|
3180
|
+
console.error("Invalid PCB Silkscreen Oval data:", {
|
|
3181
|
+
center,
|
|
3182
|
+
radius_x,
|
|
3183
|
+
radius_y
|
|
3184
|
+
});
|
|
3185
|
+
return [];
|
|
3186
|
+
}
|
|
3187
|
+
const [transformedX, transformedY] = applyToPoint20(transform, [
|
|
3188
|
+
center.x,
|
|
3189
|
+
center.y
|
|
3190
|
+
]);
|
|
3191
|
+
const transformedRadiusX = radius_x * Math.abs(transform.a);
|
|
3192
|
+
const transformedRadiusY = radius_y * Math.abs(transform.d);
|
|
3193
|
+
const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
|
|
3194
|
+
const svgObject = {
|
|
3195
|
+
name: "ellipse",
|
|
3196
|
+
type: "element",
|
|
3197
|
+
attributes: {
|
|
3198
|
+
cx: transformedX.toString(),
|
|
3199
|
+
cy: transformedY.toString(),
|
|
3200
|
+
rx: transformedRadiusX.toString(),
|
|
3201
|
+
ry: transformedRadiusY.toString(),
|
|
3202
|
+
fill: "none",
|
|
3203
|
+
stroke: color,
|
|
3204
|
+
"stroke-width": (0.1 * Math.abs(transform.a)).toString(),
|
|
3205
|
+
class: `pcb-silkscreen-oval pcb-silkscreen-${layer}`,
|
|
3206
|
+
"data-pcb-silkscreen-oval-id": pcb_silkscreen_oval_id,
|
|
3207
|
+
"data-type": "pcb_silkscreen_oval",
|
|
3208
|
+
"data-pcb-layer": layer,
|
|
3209
|
+
...ccw_rotation !== 0 && {
|
|
3210
|
+
transform: `rotate(${-ccw_rotation} ${transformedX} ${transformedY})`
|
|
3211
|
+
}
|
|
3212
|
+
},
|
|
3213
|
+
value: "",
|
|
3214
|
+
children: []
|
|
3215
|
+
};
|
|
3216
|
+
return [svgObject];
|
|
3217
|
+
}
|
|
3218
|
+
|
|
3219
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-courtyard-rect.ts
|
|
3220
|
+
import { applyToPoint as applyToPoint21 } from "transformation-matrix";
|
|
3166
3221
|
function createSvgObjectsFromPcbCourtyardRect(pcbCourtyardRect, ctx) {
|
|
3167
3222
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
3168
3223
|
const {
|
|
@@ -3181,7 +3236,7 @@ function createSvgObjectsFromPcbCourtyardRect(pcbCourtyardRect, ctx) {
|
|
|
3181
3236
|
});
|
|
3182
3237
|
return [];
|
|
3183
3238
|
}
|
|
3184
|
-
const [transformedX, transformedY] =
|
|
3239
|
+
const [transformedX, transformedY] = applyToPoint21(transform, [
|
|
3185
3240
|
center.x,
|
|
3186
3241
|
center.y
|
|
3187
3242
|
]);
|
|
@@ -3222,7 +3277,7 @@ function pairs(arr) {
|
|
|
3222
3277
|
}
|
|
3223
3278
|
|
|
3224
3279
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace.ts
|
|
3225
|
-
import { applyToPoint as
|
|
3280
|
+
import { applyToPoint as applyToPoint22 } from "transformation-matrix";
|
|
3226
3281
|
function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
3227
3282
|
const { transform, layer: layerFilter, colorMap: colorMap2, showSolderMask } = ctx;
|
|
3228
3283
|
if (!trace.route || !Array.isArray(trace.route) || trace.route.length < 2)
|
|
@@ -3230,8 +3285,8 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
|
3230
3285
|
const segments = pairs(trace.route);
|
|
3231
3286
|
const svgObjects = [];
|
|
3232
3287
|
for (const [start, end] of segments) {
|
|
3233
|
-
const startPoint =
|
|
3234
|
-
const endPoint =
|
|
3288
|
+
const startPoint = applyToPoint22(transform, [start.x, start.y]);
|
|
3289
|
+
const endPoint = applyToPoint22(transform, [end.x, end.y]);
|
|
3235
3290
|
const layer = "layer" in start ? start.layer : "layer" in end ? end.layer : null;
|
|
3236
3291
|
if (!layer) continue;
|
|
3237
3292
|
if (layerFilter && layer !== layerFilter) continue;
|
|
@@ -3286,7 +3341,7 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
|
3286
3341
|
}
|
|
3287
3342
|
|
|
3288
3343
|
// lib/pcb/svg-object-fns/create-svg-objects-from-smt-pads.ts
|
|
3289
|
-
import { applyToPoint as
|
|
3344
|
+
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
3290
3345
|
function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
3291
3346
|
const { transform, layer: layerFilter, colorMap: colorMap2, showSolderMask } = ctx;
|
|
3292
3347
|
if (layerFilter && pad.layer !== layerFilter) return [];
|
|
@@ -3297,7 +3352,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
3297
3352
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
3298
3353
|
const width = pad.width * Math.abs(transform.a);
|
|
3299
3354
|
const height = pad.height * Math.abs(transform.d);
|
|
3300
|
-
const [x, y] =
|
|
3355
|
+
const [x, y] = applyToPoint23(transform, [pad.x, pad.y]);
|
|
3301
3356
|
const cornerRadiusValue = pad.corner_radius ?? pad.rect_border_radius ?? 0;
|
|
3302
3357
|
const scaledBorderRadius = cornerRadiusValue * Math.abs(transform.a);
|
|
3303
3358
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
@@ -3539,7 +3594,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
3539
3594
|
const width = pad.width * Math.abs(transform.a);
|
|
3540
3595
|
const height = pad.height * Math.abs(transform.d);
|
|
3541
3596
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3542
|
-
const [x, y] =
|
|
3597
|
+
const [x, y] = applyToPoint23(transform, [pad.x, pad.y]);
|
|
3543
3598
|
const rotationTransformAttributes = isRotated ? {
|
|
3544
3599
|
transform: `translate(${x} ${y}) rotate(${-(pad.ccw_rotation ?? 0)})`
|
|
3545
3600
|
} : void 0;
|
|
@@ -3657,7 +3712,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
3657
3712
|
}
|
|
3658
3713
|
if (pad.shape === "circle") {
|
|
3659
3714
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3660
|
-
const [x, y] =
|
|
3715
|
+
const [x, y] = applyToPoint23(transform, [pad.x, pad.y]);
|
|
3661
3716
|
const padElement = {
|
|
3662
3717
|
name: "circle",
|
|
3663
3718
|
type: "element",
|
|
@@ -3747,7 +3802,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
3747
3802
|
}
|
|
3748
3803
|
if (pad.shape === "polygon") {
|
|
3749
3804
|
const points = (pad.points ?? []).map(
|
|
3750
|
-
(point) =>
|
|
3805
|
+
(point) => applyToPoint23(transform, [point.x, point.y])
|
|
3751
3806
|
);
|
|
3752
3807
|
const padElement = {
|
|
3753
3808
|
name: "polygon",
|
|
@@ -3846,10 +3901,10 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
3846
3901
|
}
|
|
3847
3902
|
|
|
3848
3903
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-board.ts
|
|
3849
|
-
import { applyToPoint as
|
|
3904
|
+
import { applyToPoint as applyToPoint25 } from "transformation-matrix";
|
|
3850
3905
|
|
|
3851
3906
|
// lib/utils/create-pcb-component-anchor-offset-indicators.ts
|
|
3852
|
-
import { applyToPoint as
|
|
3907
|
+
import { applyToPoint as applyToPoint24 } from "transformation-matrix";
|
|
3853
3908
|
var OFFSET_THRESHOLD_MM = 0.05;
|
|
3854
3909
|
var TICK_SIZE_PX = 4;
|
|
3855
3910
|
var LABEL_GAP_PX = 8;
|
|
@@ -3876,11 +3931,11 @@ function createAnchorOffsetIndicators(params) {
|
|
|
3876
3931
|
displayYOffset
|
|
3877
3932
|
} = params;
|
|
3878
3933
|
const objects = [];
|
|
3879
|
-
const [screenGroupAnchorX, screenGroupAnchorY] =
|
|
3934
|
+
const [screenGroupAnchorX, screenGroupAnchorY] = applyToPoint24(transform, [
|
|
3880
3935
|
groupAnchorPosition.x,
|
|
3881
3936
|
groupAnchorPosition.y
|
|
3882
3937
|
]);
|
|
3883
|
-
const [screenComponentX, screenComponentY] =
|
|
3938
|
+
const [screenComponentX, screenComponentY] = applyToPoint24(transform, [
|
|
3884
3939
|
componentPosition.x,
|
|
3885
3940
|
componentPosition.y
|
|
3886
3941
|
]);
|
|
@@ -4231,25 +4286,25 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
|
4231
4286
|
let path;
|
|
4232
4287
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
4233
4288
|
path = outline.map((point, index) => {
|
|
4234
|
-
const [x, y] =
|
|
4289
|
+
const [x, y] = applyToPoint25(transform, [point.x, point.y]);
|
|
4235
4290
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
4236
4291
|
}).join(" ");
|
|
4237
4292
|
} else {
|
|
4238
4293
|
const halfWidth = width / 2;
|
|
4239
4294
|
const halfHeight = height / 2;
|
|
4240
|
-
const topLeft =
|
|
4295
|
+
const topLeft = applyToPoint25(transform, [
|
|
4241
4296
|
center.x - halfWidth,
|
|
4242
4297
|
center.y - halfHeight
|
|
4243
4298
|
]);
|
|
4244
|
-
const topRight =
|
|
4299
|
+
const topRight = applyToPoint25(transform, [
|
|
4245
4300
|
center.x + halfWidth,
|
|
4246
4301
|
center.y - halfHeight
|
|
4247
4302
|
]);
|
|
4248
|
-
const bottomRight =
|
|
4303
|
+
const bottomRight = applyToPoint25(transform, [
|
|
4249
4304
|
center.x + halfWidth,
|
|
4250
4305
|
center.y + halfHeight
|
|
4251
4306
|
]);
|
|
4252
|
-
const bottomLeft =
|
|
4307
|
+
const bottomLeft = applyToPoint25(transform, [
|
|
4253
4308
|
center.x - halfWidth,
|
|
4254
4309
|
center.y + halfHeight
|
|
4255
4310
|
]);
|
|
@@ -4316,7 +4371,7 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
|
4316
4371
|
}
|
|
4317
4372
|
|
|
4318
4373
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-panel.ts
|
|
4319
|
-
import { applyToPoint as
|
|
4374
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
4320
4375
|
function createSvgObjectsFromPcbPanel(pcbPanel, ctx) {
|
|
4321
4376
|
const { transform, colorMap: colorMap2, showSolderMask } = ctx;
|
|
4322
4377
|
const width = Number(pcbPanel.width);
|
|
@@ -4324,19 +4379,19 @@ function createSvgObjectsFromPcbPanel(pcbPanel, ctx) {
|
|
|
4324
4379
|
const center = pcbPanel.center ?? { x: width / 2, y: height / 2 };
|
|
4325
4380
|
const halfWidth = width / 2;
|
|
4326
4381
|
const halfHeight = height / 2;
|
|
4327
|
-
const topLeft =
|
|
4382
|
+
const topLeft = applyToPoint26(transform, [
|
|
4328
4383
|
center.x - halfWidth,
|
|
4329
4384
|
center.y - halfHeight
|
|
4330
4385
|
]);
|
|
4331
|
-
const topRight =
|
|
4386
|
+
const topRight = applyToPoint26(transform, [
|
|
4332
4387
|
center.x + halfWidth,
|
|
4333
4388
|
center.y - halfHeight
|
|
4334
4389
|
]);
|
|
4335
|
-
const bottomRight =
|
|
4390
|
+
const bottomRight = applyToPoint26(transform, [
|
|
4336
4391
|
center.x + halfWidth,
|
|
4337
4392
|
center.y + halfHeight
|
|
4338
4393
|
]);
|
|
4339
|
-
const bottomLeft =
|
|
4394
|
+
const bottomLeft = applyToPoint26(transform, [
|
|
4340
4395
|
center.x - halfWidth,
|
|
4341
4396
|
center.y + halfHeight
|
|
4342
4397
|
]);
|
|
@@ -4365,10 +4420,10 @@ function createSvgObjectsFromPcbPanel(pcbPanel, ctx) {
|
|
|
4365
4420
|
}
|
|
4366
4421
|
|
|
4367
4422
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-via.ts
|
|
4368
|
-
import { applyToPoint as
|
|
4423
|
+
import { applyToPoint as applyToPoint27 } from "transformation-matrix";
|
|
4369
4424
|
function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
4370
4425
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
4371
|
-
const [x, y] =
|
|
4426
|
+
const [x, y] = applyToPoint27(transform, [hole.x, hole.y]);
|
|
4372
4427
|
const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a);
|
|
4373
4428
|
const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a);
|
|
4374
4429
|
const scaledHoleWidth = hole.hole_diameter * Math.abs(transform.a);
|
|
@@ -4414,11 +4469,11 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
|
4414
4469
|
}
|
|
4415
4470
|
|
|
4416
4471
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-hole.ts
|
|
4417
|
-
import { applyToPoint as
|
|
4472
|
+
import { applyToPoint as applyToPoint28 } from "transformation-matrix";
|
|
4418
4473
|
function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
4419
4474
|
const { transform, colorMap: colorMap2, showSolderMask } = ctx;
|
|
4420
4475
|
const layer = ctx.layer ?? "top";
|
|
4421
|
-
const [x, y] =
|
|
4476
|
+
const [x, y] = applyToPoint28(transform, [hole.x, hole.y]);
|
|
4422
4477
|
const isCoveredWithSolderMask = Boolean(hole.is_covered_with_solder_mask);
|
|
4423
4478
|
const soldermaskMargin = (hole.soldermask_margin ?? 0) * Math.abs(transform.a);
|
|
4424
4479
|
const shouldShowSolderMask = showSolderMask && isCoveredWithSolderMask && soldermaskMargin !== 0;
|
|
@@ -4915,7 +4970,7 @@ import {
|
|
|
4915
4970
|
getFullConnectivityMapFromCircuitJson
|
|
4916
4971
|
} from "circuit-json-to-connectivity-map";
|
|
4917
4972
|
import "svgson";
|
|
4918
|
-
import { applyToPoint as
|
|
4973
|
+
import { applyToPoint as applyToPoint29 } from "transformation-matrix";
|
|
4919
4974
|
|
|
4920
4975
|
// lib/pcb/create-svg-objects-from-pcb-rats-nest/get-element-position.ts
|
|
4921
4976
|
import { su } from "@tscircuit/circuit-json-util";
|
|
@@ -4995,11 +5050,11 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
4995
5050
|
});
|
|
4996
5051
|
const svgObjects = [];
|
|
4997
5052
|
for (const line of ratsNestLines) {
|
|
4998
|
-
const transformedStart =
|
|
5053
|
+
const transformedStart = applyToPoint29(transform, [
|
|
4999
5054
|
line.startPoint.x,
|
|
5000
5055
|
line.startPoint.y
|
|
5001
5056
|
]);
|
|
5002
|
-
const transformedEnd =
|
|
5057
|
+
const transformedEnd = applyToPoint29(transform, [
|
|
5003
5058
|
line.endPoint.x,
|
|
5004
5059
|
line.endPoint.y
|
|
5005
5060
|
]);
|
|
@@ -5027,7 +5082,7 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
5027
5082
|
|
|
5028
5083
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-cutout.ts
|
|
5029
5084
|
import {
|
|
5030
|
-
applyToPoint as
|
|
5085
|
+
applyToPoint as applyToPoint30,
|
|
5031
5086
|
compose as compose4,
|
|
5032
5087
|
rotate as rotate4,
|
|
5033
5088
|
translate as translate4,
|
|
@@ -5037,7 +5092,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
5037
5092
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
5038
5093
|
if (cutout.shape === "rect") {
|
|
5039
5094
|
const rectCutout = cutout;
|
|
5040
|
-
const [cx, cy] =
|
|
5095
|
+
const [cx, cy] = applyToPoint30(transform, [
|
|
5041
5096
|
rectCutout.center.x,
|
|
5042
5097
|
rectCutout.center.y
|
|
5043
5098
|
]);
|
|
@@ -5079,7 +5134,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
5079
5134
|
}
|
|
5080
5135
|
if (cutout.shape === "circle") {
|
|
5081
5136
|
const circleCutout = cutout;
|
|
5082
|
-
const [cx, cy] =
|
|
5137
|
+
const [cx, cy] = applyToPoint30(transform, [
|
|
5083
5138
|
circleCutout.center.x,
|
|
5084
5139
|
circleCutout.center.y
|
|
5085
5140
|
]);
|
|
@@ -5106,7 +5161,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
5106
5161
|
const polygonCutout = cutout;
|
|
5107
5162
|
if (!polygonCutout.points || polygonCutout.points.length === 0) return [];
|
|
5108
5163
|
const transformedPoints = polygonCutout.points.map(
|
|
5109
|
-
(p) =>
|
|
5164
|
+
(p) => applyToPoint30(transform, [p.x, p.y])
|
|
5110
5165
|
);
|
|
5111
5166
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
5112
5167
|
return [
|
|
@@ -5128,21 +5183,108 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
5128
5183
|
return [];
|
|
5129
5184
|
}
|
|
5130
5185
|
|
|
5131
|
-
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-
|
|
5186
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-keepout.ts
|
|
5132
5187
|
import {
|
|
5133
5188
|
applyToPoint as applyToPoint31,
|
|
5134
5189
|
compose as compose5,
|
|
5190
|
+
translate as translate5,
|
|
5191
|
+
toString as matrixToString8
|
|
5192
|
+
} from "transformation-matrix";
|
|
5193
|
+
function createSvgObjectsFromPcbKeepout(keepout, ctx) {
|
|
5194
|
+
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
5195
|
+
if (layerFilter && !keepout.layers.includes(layerFilter)) {
|
|
5196
|
+
return [];
|
|
5197
|
+
}
|
|
5198
|
+
const svgObjects = [];
|
|
5199
|
+
for (const layer of keepout.layers) {
|
|
5200
|
+
if (layerFilter && layer !== layerFilter) {
|
|
5201
|
+
continue;
|
|
5202
|
+
}
|
|
5203
|
+
if (keepout.shape === "rect") {
|
|
5204
|
+
const rectKeepout = keepout;
|
|
5205
|
+
const [cx, cy] = applyToPoint31(transform, [
|
|
5206
|
+
rectKeepout.center.x,
|
|
5207
|
+
rectKeepout.center.y
|
|
5208
|
+
]);
|
|
5209
|
+
const scaledWidth = rectKeepout.width * Math.abs(transform.a);
|
|
5210
|
+
const scaledHeight = rectKeepout.height * Math.abs(transform.d);
|
|
5211
|
+
const transformedStrokeWidth = 0.1 * Math.abs(transform.a);
|
|
5212
|
+
const attributes = {
|
|
5213
|
+
class: "pcb-keepout pcb-keepout-rect",
|
|
5214
|
+
x: (-scaledWidth / 2).toString(),
|
|
5215
|
+
y: (-scaledHeight / 2).toString(),
|
|
5216
|
+
width: scaledWidth.toString(),
|
|
5217
|
+
height: scaledHeight.toString(),
|
|
5218
|
+
fill: "none",
|
|
5219
|
+
stroke: colorMap2.keepout ?? "#FF6B6B",
|
|
5220
|
+
"stroke-width": transformedStrokeWidth.toString(),
|
|
5221
|
+
"stroke-dasharray": `${transformedStrokeWidth * 3} ${transformedStrokeWidth * 2}`,
|
|
5222
|
+
transform: matrixToString8(compose5(translate5(cx, cy))),
|
|
5223
|
+
"data-type": "pcb_keepout",
|
|
5224
|
+
"data-pcb-layer": layer,
|
|
5225
|
+
"data-pcb-keepout-id": rectKeepout.pcb_keepout_id
|
|
5226
|
+
};
|
|
5227
|
+
if (rectKeepout.description) {
|
|
5228
|
+
attributes["data-description"] = rectKeepout.description;
|
|
5229
|
+
}
|
|
5230
|
+
svgObjects.push({
|
|
5231
|
+
name: "rect",
|
|
5232
|
+
type: "element",
|
|
5233
|
+
attributes,
|
|
5234
|
+
children: [],
|
|
5235
|
+
value: ""
|
|
5236
|
+
});
|
|
5237
|
+
} else if (keepout.shape === "circle") {
|
|
5238
|
+
const circleKeepout = keepout;
|
|
5239
|
+
const [cx, cy] = applyToPoint31(transform, [
|
|
5240
|
+
circleKeepout.center.x,
|
|
5241
|
+
circleKeepout.center.y
|
|
5242
|
+
]);
|
|
5243
|
+
const scaledRadius = circleKeepout.radius * Math.abs(transform.a);
|
|
5244
|
+
const transformedStrokeWidth = 0.1 * Math.abs(transform.a);
|
|
5245
|
+
const attributes = {
|
|
5246
|
+
class: "pcb-keepout pcb-keepout-circle",
|
|
5247
|
+
cx: cx.toString(),
|
|
5248
|
+
cy: cy.toString(),
|
|
5249
|
+
r: scaledRadius.toString(),
|
|
5250
|
+
fill: "none",
|
|
5251
|
+
stroke: colorMap2.keepout ?? "#FF6B6B",
|
|
5252
|
+
"stroke-width": transformedStrokeWidth.toString(),
|
|
5253
|
+
"stroke-dasharray": `${transformedStrokeWidth * 3} ${transformedStrokeWidth * 2}`,
|
|
5254
|
+
"data-type": "pcb_keepout",
|
|
5255
|
+
"data-pcb-layer": layer,
|
|
5256
|
+
"data-pcb-keepout-id": circleKeepout.pcb_keepout_id
|
|
5257
|
+
};
|
|
5258
|
+
if (circleKeepout.description) {
|
|
5259
|
+
attributes["data-description"] = circleKeepout.description;
|
|
5260
|
+
}
|
|
5261
|
+
svgObjects.push({
|
|
5262
|
+
name: "circle",
|
|
5263
|
+
type: "element",
|
|
5264
|
+
attributes,
|
|
5265
|
+
children: [],
|
|
5266
|
+
value: ""
|
|
5267
|
+
});
|
|
5268
|
+
}
|
|
5269
|
+
}
|
|
5270
|
+
return svgObjects;
|
|
5271
|
+
}
|
|
5272
|
+
|
|
5273
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-copper-pour.ts
|
|
5274
|
+
import {
|
|
5275
|
+
applyToPoint as applyToPoint33,
|
|
5276
|
+
compose as compose6,
|
|
5135
5277
|
rotate as rotate5,
|
|
5136
|
-
toString as
|
|
5137
|
-
translate as
|
|
5278
|
+
toString as matrixToString9,
|
|
5279
|
+
translate as translate6
|
|
5138
5280
|
} from "transformation-matrix";
|
|
5139
5281
|
|
|
5140
5282
|
// lib/utils/ring-to-path-d.ts
|
|
5141
|
-
import { applyToPoint as
|
|
5283
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
5142
5284
|
function ringToPathD(vertices, transform) {
|
|
5143
5285
|
if (vertices.length === 0) return "";
|
|
5144
5286
|
const transformedVertices = vertices.map((v) => {
|
|
5145
|
-
const [x, y] =
|
|
5287
|
+
const [x, y] = applyToPoint32(transform, [v.x, v.y]);
|
|
5146
5288
|
return { ...v, x, y };
|
|
5147
5289
|
});
|
|
5148
5290
|
let d = `M ${transformedVertices[0].x} ${transformedVertices[0].y}`;
|
|
@@ -5231,7 +5373,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
5231
5373
|
const maskOverlayColor = layer === "bottom" ? colorMap2.soldermaskOverCopper.bottom : colorMap2.soldermaskOverCopper.top;
|
|
5232
5374
|
const maskOverlayOpacity = "0.9";
|
|
5233
5375
|
if (pour.shape === "rect") {
|
|
5234
|
-
const [cx, cy] =
|
|
5376
|
+
const [cx, cy] = applyToPoint33(transform, [pour.center.x, pour.center.y]);
|
|
5235
5377
|
const scaledWidth = pour.width * Math.abs(transform.a);
|
|
5236
5378
|
const scaledHeight = pour.height * Math.abs(transform.d);
|
|
5237
5379
|
const svgRotation = -(pour.rotation ?? 0);
|
|
@@ -5240,8 +5382,8 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
5240
5382
|
y: (-scaledHeight / 2).toString(),
|
|
5241
5383
|
width: scaledWidth.toString(),
|
|
5242
5384
|
height: scaledHeight.toString(),
|
|
5243
|
-
transform:
|
|
5244
|
-
|
|
5385
|
+
transform: matrixToString9(
|
|
5386
|
+
compose6(translate6(cx, cy), rotate5(svgRotation * Math.PI / 180))
|
|
5245
5387
|
)
|
|
5246
5388
|
};
|
|
5247
5389
|
const copperRect = {
|
|
@@ -5283,7 +5425,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
5283
5425
|
if (pour.shape === "polygon") {
|
|
5284
5426
|
if (!pour.points || pour.points.length === 0) return [];
|
|
5285
5427
|
const transformedPoints = pour.points.map(
|
|
5286
|
-
(p) =>
|
|
5428
|
+
(p) => applyToPoint33(transform, [p.x, p.y])
|
|
5287
5429
|
);
|
|
5288
5430
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
5289
5431
|
const copperPolygon = {
|
|
@@ -5506,11 +5648,11 @@ function createMajorGridPatternChildren(cellSize, majorCellSize, lineColor, majo
|
|
|
5506
5648
|
}
|
|
5507
5649
|
|
|
5508
5650
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-component.ts
|
|
5509
|
-
import { applyToPoint as
|
|
5651
|
+
import { applyToPoint as applyToPoint34 } from "transformation-matrix";
|
|
5510
5652
|
function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
5511
5653
|
const { transform, circuitJson } = ctx;
|
|
5512
5654
|
const { center, width, height, rotation = 0 } = component;
|
|
5513
|
-
const [x, y] =
|
|
5655
|
+
const [x, y] = applyToPoint34(transform, [center.x, center.y]);
|
|
5514
5656
|
const scaledWidth = width * Math.abs(transform.a);
|
|
5515
5657
|
const scaledHeight = height * Math.abs(transform.d);
|
|
5516
5658
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
@@ -5582,7 +5724,7 @@ function getParentAnchorPosition(component, circuitJson) {
|
|
|
5582
5724
|
}
|
|
5583
5725
|
|
|
5584
5726
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-group.ts
|
|
5585
|
-
import { applyToPoint as
|
|
5727
|
+
import { applyToPoint as applyToPoint35 } from "transformation-matrix";
|
|
5586
5728
|
var DEFAULT_GROUP_COLOR = "rgba(100, 200, 255, 0.6)";
|
|
5587
5729
|
var DEFAULT_STROKE_WIDTH = 0.1;
|
|
5588
5730
|
function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
@@ -5626,7 +5768,7 @@ function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
|
5626
5768
|
(point) => point && typeof point.x === "number" && typeof point.y === "number"
|
|
5627
5769
|
)) {
|
|
5628
5770
|
const path = outline.map((point, index) => {
|
|
5629
|
-
const [x, y] =
|
|
5771
|
+
const [x, y] = applyToPoint35(transform, [point.x, point.y]);
|
|
5630
5772
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
5631
5773
|
}).join(" ");
|
|
5632
5774
|
svgObjects.push({
|
|
@@ -5647,11 +5789,11 @@ function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
|
5647
5789
|
}
|
|
5648
5790
|
const halfWidth = width / 2;
|
|
5649
5791
|
const halfHeight = height / 2;
|
|
5650
|
-
const [topLeftX, topLeftY] =
|
|
5792
|
+
const [topLeftX, topLeftY] = applyToPoint35(transform, [
|
|
5651
5793
|
center.x - halfWidth,
|
|
5652
5794
|
center.y + halfHeight
|
|
5653
5795
|
]);
|
|
5654
|
-
const [bottomRightX, bottomRightY] =
|
|
5796
|
+
const [bottomRightX, bottomRightY] = applyToPoint35(transform, [
|
|
5655
5797
|
center.x + halfWidth,
|
|
5656
5798
|
center.y - halfHeight
|
|
5657
5799
|
]);
|
|
@@ -5705,7 +5847,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
5705
5847
|
var package_default = {
|
|
5706
5848
|
name: "circuit-to-svg",
|
|
5707
5849
|
type: "module",
|
|
5708
|
-
version: "0.0.
|
|
5850
|
+
version: "0.0.302",
|
|
5709
5851
|
description: "Convert Circuit JSON to SVG",
|
|
5710
5852
|
main: "dist/index.js",
|
|
5711
5853
|
files: [
|
|
@@ -5728,7 +5870,7 @@ var package_default = {
|
|
|
5728
5870
|
"@vitejs/plugin-react": "5.0.0",
|
|
5729
5871
|
biome: "^0.3.3",
|
|
5730
5872
|
"bun-match-svg": "^0.0.12",
|
|
5731
|
-
"circuit-json": "^0.0.
|
|
5873
|
+
"circuit-json": "^0.0.348",
|
|
5732
5874
|
esbuild: "^0.20.2",
|
|
5733
5875
|
"performance-now": "^2.1.0",
|
|
5734
5876
|
react: "19.1.0",
|
|
@@ -5762,6 +5904,7 @@ var TYPE_PRIORITY = {
|
|
|
5762
5904
|
pcb_panel: 5,
|
|
5763
5905
|
pcb_board: 10,
|
|
5764
5906
|
pcb_cutout: 15,
|
|
5907
|
+
pcb_keepout: 16,
|
|
5765
5908
|
pcb_hole: 18,
|
|
5766
5909
|
pcb_plated_hole_drill: 19,
|
|
5767
5910
|
pcb_plated_hole: 20,
|
|
@@ -5778,6 +5921,8 @@ var TYPE_PRIORITY = {
|
|
|
5778
5921
|
pcb_silkscreen_rect: 50,
|
|
5779
5922
|
pcb_silkscreen_circle: 50,
|
|
5780
5923
|
pcb_silkscreen_line: 50,
|
|
5924
|
+
pcb_silkscreen_oval: 50,
|
|
5925
|
+
pcb_silkscreen_pill: 50,
|
|
5781
5926
|
pcb_component: 60,
|
|
5782
5927
|
pcb_fabrication_note_text: 70,
|
|
5783
5928
|
pcb_fabrication_note_path: 70,
|
|
@@ -5920,6 +6065,7 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5920
6065
|
},
|
|
5921
6066
|
substrate: colorOverrides?.substrate ?? DEFAULT_PCB_COLOR_MAP.substrate,
|
|
5922
6067
|
courtyard: colorOverrides?.courtyard ?? DEFAULT_PCB_COLOR_MAP.courtyard,
|
|
6068
|
+
keepout: colorOverrides?.keepout ?? DEFAULT_PCB_COLOR_MAP.keepout,
|
|
5923
6069
|
debugComponent: {
|
|
5924
6070
|
fill: colorOverrides?.debugComponent?.fill ?? DEFAULT_PCB_COLOR_MAP.debugComponent.fill,
|
|
5925
6071
|
stroke: colorOverrides?.debugComponent?.stroke ?? DEFAULT_PCB_COLOR_MAP.debugComponent.stroke
|
|
@@ -5995,7 +6141,17 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
5995
6141
|
} else if (cutout.shape === "polygon") {
|
|
5996
6142
|
updateTraceBounds(cutout.points);
|
|
5997
6143
|
}
|
|
5998
|
-
} else if (circuitJsonElm.type === "
|
|
6144
|
+
} else if (circuitJsonElm.type === "pcb_keepout") {
|
|
6145
|
+
const keepout = circuitJsonElm;
|
|
6146
|
+
if (keepout.shape === "rect") {
|
|
6147
|
+
updateBounds(keepout.center, keepout.width, keepout.height);
|
|
6148
|
+
} else if (keepout.shape === "circle") {
|
|
6149
|
+
const radius = typeof keepout.radius === "number" ? keepout.radius : distance2.parse(keepout.radius) ?? 0;
|
|
6150
|
+
if (radius > 0) {
|
|
6151
|
+
updateBounds(keepout.center, radius * 2, radius * 2);
|
|
6152
|
+
}
|
|
6153
|
+
}
|
|
6154
|
+
} else if (circuitJsonElm.type === "pcb_silkscreen_text" || circuitJsonElm.type === "pcb_silkscreen_rect" || circuitJsonElm.type === "pcb_silkscreen_circle" || circuitJsonElm.type === "pcb_silkscreen_line" || circuitJsonElm.type === "pcb_silkscreen_oval") {
|
|
5999
6155
|
updateSilkscreenBounds(circuitJsonElm);
|
|
6000
6156
|
} else if (circuitJsonElm.type === "pcb_copper_text") {
|
|
6001
6157
|
updateBounds(circuitJsonElm.anchor_position, 0, 0);
|
|
@@ -6045,8 +6201,8 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
6045
6201
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
6046
6202
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
6047
6203
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
6048
|
-
const transform =
|
|
6049
|
-
|
|
6204
|
+
const transform = compose7(
|
|
6205
|
+
translate7(
|
|
6050
6206
|
offsetX - boundsMinX * scaleFactor + padding * scaleFactor,
|
|
6051
6207
|
svgHeight - offsetY + boundsMinY * scaleFactor - padding * scaleFactor
|
|
6052
6208
|
),
|
|
@@ -6259,6 +6415,12 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
6259
6415
|
} else if (item.type === "pcb_silkscreen_line") {
|
|
6260
6416
|
updateBounds({ x: item.x1, y: item.y1 }, 0, 0);
|
|
6261
6417
|
updateBounds({ x: item.x2, y: item.y2 }, 0, 0);
|
|
6418
|
+
} else if (item.type === "pcb_silkscreen_oval") {
|
|
6419
|
+
const radiusX = distance2.parse(item.radius_x);
|
|
6420
|
+
const radiusY = distance2.parse(item.radius_y);
|
|
6421
|
+
if (radiusX !== void 0 && radiusY !== void 0) {
|
|
6422
|
+
updateBounds(item.center, radiusX * 2, radiusY * 2);
|
|
6423
|
+
}
|
|
6262
6424
|
} else if (item.type === "pcb_cutout") {
|
|
6263
6425
|
const cutout = item;
|
|
6264
6426
|
if (cutout.shape === "rect") {
|
|
@@ -6312,6 +6474,8 @@ function createSvgObjects({
|
|
|
6312
6474
|
return createSvgObjectsFromPcbSilkscreenLine(elm, ctx);
|
|
6313
6475
|
case "pcb_silkscreen_pill":
|
|
6314
6476
|
return createSvgObjectsFromPcbSilkscreenPill(elm, ctx);
|
|
6477
|
+
case "pcb_silkscreen_oval":
|
|
6478
|
+
return createSvgObjectsFromPcbSilkscreenOval(elm, ctx);
|
|
6315
6479
|
case "pcb_copper_text":
|
|
6316
6480
|
return createSvgObjectsFromPcbCopperText(elm, ctx);
|
|
6317
6481
|
case "pcb_courtyard_rect":
|
|
@@ -6345,6 +6509,11 @@ function createSvgObjects({
|
|
|
6345
6509
|
return createSvgObjectsFromPcbVia(elm, ctx);
|
|
6346
6510
|
case "pcb_cutout":
|
|
6347
6511
|
return createSvgObjectsFromPcbCutout(elm, ctx);
|
|
6512
|
+
case "pcb_keepout":
|
|
6513
|
+
return createSvgObjectsFromPcbKeepout(
|
|
6514
|
+
elm,
|
|
6515
|
+
ctx
|
|
6516
|
+
);
|
|
6348
6517
|
case "pcb_group":
|
|
6349
6518
|
return ctx.showPcbGroups ? createSvgObjectsFromPcbGroup(elm, ctx) : [];
|
|
6350
6519
|
default:
|
|
@@ -6352,8 +6521,8 @@ function createSvgObjects({
|
|
|
6352
6521
|
}
|
|
6353
6522
|
}
|
|
6354
6523
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
6355
|
-
const [x1, y1] =
|
|
6356
|
-
const [x2, y2] =
|
|
6524
|
+
const [x1, y1] = applyToPoint36(transform, [minX, minY]);
|
|
6525
|
+
const [x2, y2] = applyToPoint36(transform, [maxX, maxY]);
|
|
6357
6526
|
const width = Math.abs(x2 - x1);
|
|
6358
6527
|
const height = Math.abs(y2 - y1);
|
|
6359
6528
|
const x = Math.min(x1, x2);
|
|
@@ -6383,14 +6552,14 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
6383
6552
|
import { stringify as stringify2 } from "svgson";
|
|
6384
6553
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
6385
6554
|
import {
|
|
6386
|
-
applyToPoint as
|
|
6387
|
-
compose as
|
|
6555
|
+
applyToPoint as applyToPoint43,
|
|
6556
|
+
compose as compose8,
|
|
6388
6557
|
scale as scale4,
|
|
6389
|
-
translate as
|
|
6558
|
+
translate as translate8
|
|
6390
6559
|
} from "transformation-matrix";
|
|
6391
6560
|
|
|
6392
6561
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
6393
|
-
import { applyToPoint as
|
|
6562
|
+
import { applyToPoint as applyToPoint37 } from "transformation-matrix";
|
|
6394
6563
|
var DEFAULT_BOARD_STYLE = {
|
|
6395
6564
|
fill: "none",
|
|
6396
6565
|
stroke: "rgb(0,0,0)",
|
|
@@ -6402,25 +6571,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
6402
6571
|
let path;
|
|
6403
6572
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
6404
6573
|
path = outline.map((point, index) => {
|
|
6405
|
-
const [x, y] =
|
|
6574
|
+
const [x, y] = applyToPoint37(transform, [point.x, point.y]);
|
|
6406
6575
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
6407
6576
|
}).join(" ");
|
|
6408
6577
|
} else {
|
|
6409
6578
|
const halfWidth = width / 2;
|
|
6410
6579
|
const halfHeight = height / 2;
|
|
6411
|
-
const topLeft =
|
|
6580
|
+
const topLeft = applyToPoint37(transform, [
|
|
6412
6581
|
center.x - halfWidth,
|
|
6413
6582
|
center.y - halfHeight
|
|
6414
6583
|
]);
|
|
6415
|
-
const topRight =
|
|
6584
|
+
const topRight = applyToPoint37(transform, [
|
|
6416
6585
|
center.x + halfWidth,
|
|
6417
6586
|
center.y - halfHeight
|
|
6418
6587
|
]);
|
|
6419
|
-
const bottomRight =
|
|
6588
|
+
const bottomRight = applyToPoint37(transform, [
|
|
6420
6589
|
center.x + halfWidth,
|
|
6421
6590
|
center.y + halfHeight
|
|
6422
6591
|
]);
|
|
6423
|
-
const bottomLeft =
|
|
6592
|
+
const bottomLeft = applyToPoint37(transform, [
|
|
6424
6593
|
center.x - halfWidth,
|
|
6425
6594
|
center.y + halfHeight
|
|
6426
6595
|
]);
|
|
@@ -6446,7 +6615,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
6446
6615
|
}
|
|
6447
6616
|
|
|
6448
6617
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
6449
|
-
import { applyToPoint as
|
|
6618
|
+
import { applyToPoint as applyToPoint39 } from "transformation-matrix";
|
|
6450
6619
|
|
|
6451
6620
|
// lib/utils/get-sch-font-size.ts
|
|
6452
6621
|
import "transformation-matrix";
|
|
@@ -6472,8 +6641,8 @@ function createSvgObjectsFromAssemblyComponent(params, ctx) {
|
|
|
6472
6641
|
const { center, width, height, rotation = 0, layer = "top" } = elm;
|
|
6473
6642
|
if (!center || typeof width !== "number" || typeof height !== "number")
|
|
6474
6643
|
return null;
|
|
6475
|
-
const [x, y] =
|
|
6476
|
-
const [pinX, pinY] =
|
|
6644
|
+
const [x, y] = applyToPoint39(transform, [center.x, center.y]);
|
|
6645
|
+
const [pinX, pinY] = applyToPoint39(transform, [portPosition.x, portPosition.y]);
|
|
6477
6646
|
const scaledWidth = width * Math.abs(transform.a);
|
|
6478
6647
|
const scaledHeight = height * Math.abs(transform.d);
|
|
6479
6648
|
const isTopLayer = layer === "top";
|
|
@@ -6635,11 +6804,11 @@ function getRectPathData(w, h, rotation) {
|
|
|
6635
6804
|
}
|
|
6636
6805
|
|
|
6637
6806
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-hole.ts
|
|
6638
|
-
import { applyToPoint as
|
|
6807
|
+
import { applyToPoint as applyToPoint40 } from "transformation-matrix";
|
|
6639
6808
|
var HOLE_COLOR2 = "rgb(190, 190, 190)";
|
|
6640
6809
|
function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
6641
6810
|
const { transform } = ctx;
|
|
6642
|
-
const [x, y] =
|
|
6811
|
+
const [x, y] = applyToPoint40(transform, [hole.x, hole.y]);
|
|
6643
6812
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
6644
6813
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
6645
6814
|
const radius = scaledDiameter / 2;
|
|
@@ -6703,12 +6872,12 @@ function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
|
6703
6872
|
}
|
|
6704
6873
|
|
|
6705
6874
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-plated-hole.ts
|
|
6706
|
-
import { applyToPoint as
|
|
6875
|
+
import { applyToPoint as applyToPoint41 } from "transformation-matrix";
|
|
6707
6876
|
var PAD_COLOR = "rgb(210, 210, 210)";
|
|
6708
6877
|
var HOLE_COLOR3 = "rgb(190, 190, 190)";
|
|
6709
6878
|
function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
6710
6879
|
const { transform } = ctx;
|
|
6711
|
-
const [x, y] =
|
|
6880
|
+
const [x, y] = applyToPoint41(transform, [hole.x, hole.y]);
|
|
6712
6881
|
if (hole.shape === "pill") {
|
|
6713
6882
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
6714
6883
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -6803,7 +6972,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
6803
6972
|
const scaledRectPadHeight = circularHole.rect_pad_height * Math.abs(transform.a);
|
|
6804
6973
|
const scaledRectBorderRadius = (circularHole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
6805
6974
|
const holeRadius = scaledHoleDiameter / 2;
|
|
6806
|
-
const [holeCx, holeCy] =
|
|
6975
|
+
const [holeCx, holeCy] = applyToPoint41(transform, [
|
|
6807
6976
|
circularHole.x + circularHole.hole_offset_x,
|
|
6808
6977
|
circularHole.y + circularHole.hole_offset_y
|
|
6809
6978
|
]);
|
|
@@ -6861,7 +7030,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
6861
7030
|
const pillHoleWithOffsets = pillHole;
|
|
6862
7031
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
6863
7032
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
6864
|
-
const [holeCenterX, holeCenterY] =
|
|
7033
|
+
const [holeCenterX, holeCenterY] = applyToPoint41(transform, [
|
|
6865
7034
|
pillHole.x + holeOffsetX,
|
|
6866
7035
|
pillHole.y + holeOffsetY
|
|
6867
7036
|
]);
|
|
@@ -6923,7 +7092,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
6923
7092
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
6924
7093
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
6925
7094
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
6926
|
-
const [holeCenterX, holeCenterY] =
|
|
7095
|
+
const [holeCenterX, holeCenterY] = applyToPoint41(transform, [
|
|
6927
7096
|
rotatedHole.x + holeOffsetX,
|
|
6928
7097
|
rotatedHole.y + holeOffsetY
|
|
6929
7098
|
]);
|
|
@@ -6979,14 +7148,14 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
6979
7148
|
}
|
|
6980
7149
|
|
|
6981
7150
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-smt-pad.ts
|
|
6982
|
-
import { applyToPoint as
|
|
7151
|
+
import { applyToPoint as applyToPoint42 } from "transformation-matrix";
|
|
6983
7152
|
var PAD_COLOR2 = "rgb(210, 210, 210)";
|
|
6984
7153
|
function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
6985
7154
|
const { transform } = ctx;
|
|
6986
7155
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
6987
7156
|
const width = pad.width * Math.abs(transform.a);
|
|
6988
7157
|
const height = pad.height * Math.abs(transform.d);
|
|
6989
|
-
const [x, y] =
|
|
7158
|
+
const [x, y] = applyToPoint42(transform, [pad.x, pad.y]);
|
|
6990
7159
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
6991
7160
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
6992
7161
|
return [
|
|
@@ -7038,7 +7207,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
7038
7207
|
const width = pad.width * Math.abs(transform.a);
|
|
7039
7208
|
const height = pad.height * Math.abs(transform.d);
|
|
7040
7209
|
const radius = pad.radius * Math.abs(transform.a);
|
|
7041
|
-
const [x, y] =
|
|
7210
|
+
const [x, y] = applyToPoint42(transform, [pad.x, pad.y]);
|
|
7042
7211
|
return [
|
|
7043
7212
|
{
|
|
7044
7213
|
name: "rect",
|
|
@@ -7061,7 +7230,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
7061
7230
|
}
|
|
7062
7231
|
if (pad.shape === "circle") {
|
|
7063
7232
|
const radius = pad.radius * Math.abs(transform.a);
|
|
7064
|
-
const [x, y] =
|
|
7233
|
+
const [x, y] = applyToPoint42(transform, [pad.x, pad.y]);
|
|
7065
7234
|
return [
|
|
7066
7235
|
{
|
|
7067
7236
|
name: "circle",
|
|
@@ -7081,7 +7250,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
7081
7250
|
}
|
|
7082
7251
|
if (pad.shape === "polygon") {
|
|
7083
7252
|
const points = (pad.points ?? []).map(
|
|
7084
|
-
(point) =>
|
|
7253
|
+
(point) => applyToPoint42(transform, [point.x, point.y])
|
|
7085
7254
|
);
|
|
7086
7255
|
return [
|
|
7087
7256
|
{
|
|
@@ -7135,8 +7304,8 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
7135
7304
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
7136
7305
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
7137
7306
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
7138
|
-
const transform =
|
|
7139
|
-
|
|
7307
|
+
const transform = compose8(
|
|
7308
|
+
translate8(
|
|
7140
7309
|
offsetX - minX * scaleFactor + padding * scaleFactor,
|
|
7141
7310
|
svgHeight - offsetY + minY * scaleFactor - padding * scaleFactor
|
|
7142
7311
|
),
|
|
@@ -7265,8 +7434,8 @@ function createSvgObjects2(elm, ctx, soup) {
|
|
|
7265
7434
|
}
|
|
7266
7435
|
}
|
|
7267
7436
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
7268
|
-
const [x1, y1] =
|
|
7269
|
-
const [x2, y2] =
|
|
7437
|
+
const [x1, y1] = applyToPoint43(transform, [minX, minY]);
|
|
7438
|
+
const [x2, y2] = applyToPoint43(transform, [maxX, maxY]);
|
|
7270
7439
|
const width = Math.abs(x2 - x1);
|
|
7271
7440
|
const height = Math.abs(y2 - y1);
|
|
7272
7441
|
const x = Math.min(x1, x2);
|
|
@@ -7289,13 +7458,13 @@ function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY)
|
|
|
7289
7458
|
// lib/pinout/convert-circuit-json-to-pinout-svg.ts
|
|
7290
7459
|
import { stringify as stringify3 } from "svgson";
|
|
7291
7460
|
import {
|
|
7292
|
-
compose as
|
|
7461
|
+
compose as compose9,
|
|
7293
7462
|
scale as matrixScale,
|
|
7294
|
-
translate as
|
|
7463
|
+
translate as translate9
|
|
7295
7464
|
} from "transformation-matrix";
|
|
7296
7465
|
|
|
7297
7466
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-board.ts
|
|
7298
|
-
import { applyToPoint as
|
|
7467
|
+
import { applyToPoint as applyToPoint44 } from "transformation-matrix";
|
|
7299
7468
|
import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
7300
7469
|
var BOARD_FILL_COLOR = "rgb(26, 115, 143)";
|
|
7301
7470
|
var BOARD_STROKE_COLOR = "rgba(0,0,0,0.9)";
|
|
@@ -7309,25 +7478,25 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
7309
7478
|
let path;
|
|
7310
7479
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
7311
7480
|
path = outline.map((point, index) => {
|
|
7312
|
-
const [x, y] =
|
|
7481
|
+
const [x, y] = applyToPoint44(transform, [point.x, point.y]);
|
|
7313
7482
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
7314
7483
|
}).join(" ");
|
|
7315
7484
|
} else {
|
|
7316
7485
|
const halfWidth = width / 2;
|
|
7317
7486
|
const halfHeight = height / 2;
|
|
7318
|
-
const topLeft =
|
|
7487
|
+
const topLeft = applyToPoint44(transform, [
|
|
7319
7488
|
center.x - halfWidth,
|
|
7320
7489
|
center.y - halfHeight
|
|
7321
7490
|
]);
|
|
7322
|
-
const topRight =
|
|
7491
|
+
const topRight = applyToPoint44(transform, [
|
|
7323
7492
|
center.x + halfWidth,
|
|
7324
7493
|
center.y - halfHeight
|
|
7325
7494
|
]);
|
|
7326
|
-
const bottomRight =
|
|
7495
|
+
const bottomRight = applyToPoint44(transform, [
|
|
7327
7496
|
center.x + halfWidth,
|
|
7328
7497
|
center.y + halfHeight
|
|
7329
7498
|
]);
|
|
7330
|
-
const bottomLeft =
|
|
7499
|
+
const bottomLeft = applyToPoint44(transform, [
|
|
7331
7500
|
center.x - halfWidth,
|
|
7332
7501
|
center.y + halfHeight
|
|
7333
7502
|
]);
|
|
@@ -7345,10 +7514,10 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
7345
7514
|
const halfWidth = width2 / 2;
|
|
7346
7515
|
const halfHeight = height2 / 2;
|
|
7347
7516
|
const [tl, tr, br, bl] = [
|
|
7348
|
-
|
|
7349
|
-
|
|
7350
|
-
|
|
7351
|
-
|
|
7517
|
+
applyToPoint44(transform, [x - halfWidth, y - halfHeight]),
|
|
7518
|
+
applyToPoint44(transform, [x + halfWidth, y - halfHeight]),
|
|
7519
|
+
applyToPoint44(transform, [x + halfWidth, y + halfHeight]),
|
|
7520
|
+
applyToPoint44(transform, [x - halfWidth, y + halfHeight])
|
|
7352
7521
|
];
|
|
7353
7522
|
path += ` M ${tl[0]} ${tl[1]} L ${tr[0]} ${tr[1]} L ${br[0]} ${br[1]} L ${bl[0]} ${bl[1]} Z`;
|
|
7354
7523
|
} else if (cutout.shape === "circle") {
|
|
@@ -7398,7 +7567,7 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
7398
7567
|
|
|
7399
7568
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-component.ts
|
|
7400
7569
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
7401
|
-
import { applyToPoint as
|
|
7570
|
+
import { applyToPoint as applyToPoint45 } from "transformation-matrix";
|
|
7402
7571
|
var COMPONENT_FILL_COLOR = "rgba(120, 120, 120, 0.6)";
|
|
7403
7572
|
var COMPONENT_LABEL_COLOR = "rgba(255, 255, 255, 0.9)";
|
|
7404
7573
|
function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
@@ -7408,7 +7577,7 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
7408
7577
|
if (!center || typeof width !== "number" || typeof height !== "number" || width === 0 || height === 0) {
|
|
7409
7578
|
return [];
|
|
7410
7579
|
}
|
|
7411
|
-
const [x, y] =
|
|
7580
|
+
const [x, y] = applyToPoint45(transform, [center.x, center.y]);
|
|
7412
7581
|
const scaledWidth = width * Math.abs(transform.a);
|
|
7413
7582
|
const scaledHeight = height * Math.abs(transform.d);
|
|
7414
7583
|
const transformStr = `translate(${x}, ${y})`;
|
|
@@ -7469,11 +7638,11 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
7469
7638
|
}
|
|
7470
7639
|
|
|
7471
7640
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-hole.ts
|
|
7472
|
-
import { applyToPoint as
|
|
7641
|
+
import { applyToPoint as applyToPoint46 } from "transformation-matrix";
|
|
7473
7642
|
var HOLE_COLOR4 = "rgb(50, 50, 50)";
|
|
7474
7643
|
function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
7475
7644
|
const { transform } = ctx;
|
|
7476
|
-
const [x, y] =
|
|
7645
|
+
const [x, y] = applyToPoint46(transform, [hole.x, hole.y]);
|
|
7477
7646
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
7478
7647
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
7479
7648
|
const radius = scaledDiameter / 2;
|
|
@@ -7537,12 +7706,12 @@ function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
|
7537
7706
|
}
|
|
7538
7707
|
|
|
7539
7708
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-plated-hole.ts
|
|
7540
|
-
import { applyToPoint as
|
|
7709
|
+
import { applyToPoint as applyToPoint47 } from "transformation-matrix";
|
|
7541
7710
|
var PAD_COLOR3 = "rgb(218, 165, 32)";
|
|
7542
7711
|
var HOLE_COLOR5 = "rgb(40, 40, 40)";
|
|
7543
7712
|
function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
7544
7713
|
const { transform } = ctx;
|
|
7545
|
-
const [x, y] =
|
|
7714
|
+
const [x, y] = applyToPoint47(transform, [hole.x, hole.y]);
|
|
7546
7715
|
if (hole.shape === "pill") {
|
|
7547
7716
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
7548
7717
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -7777,14 +7946,14 @@ function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
|
7777
7946
|
}
|
|
7778
7947
|
|
|
7779
7948
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-smt-pad.ts
|
|
7780
|
-
import { applyToPoint as
|
|
7949
|
+
import { applyToPoint as applyToPoint48 } from "transformation-matrix";
|
|
7781
7950
|
var PAD_COLOR4 = "rgb(218, 165, 32)";
|
|
7782
7951
|
function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
7783
7952
|
const { transform } = ctx;
|
|
7784
7953
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
7785
7954
|
const width = pad.width * Math.abs(transform.a);
|
|
7786
7955
|
const height = pad.height * Math.abs(transform.d);
|
|
7787
|
-
const [x, y] =
|
|
7956
|
+
const [x, y] = applyToPoint48(transform, [pad.x, pad.y]);
|
|
7788
7957
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
7789
7958
|
return [
|
|
7790
7959
|
{
|
|
@@ -7827,7 +7996,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
7827
7996
|
const width = pad.width * Math.abs(transform.a);
|
|
7828
7997
|
const height = pad.height * Math.abs(transform.d);
|
|
7829
7998
|
const radius = pad.radius * Math.abs(transform.a);
|
|
7830
|
-
const [x, y] =
|
|
7999
|
+
const [x, y] = applyToPoint48(transform, [pad.x, pad.y]);
|
|
7831
8000
|
return [
|
|
7832
8001
|
{
|
|
7833
8002
|
name: "rect",
|
|
@@ -7850,7 +8019,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
7850
8019
|
}
|
|
7851
8020
|
if (pad.shape === "circle") {
|
|
7852
8021
|
const radius = pad.radius * Math.abs(transform.a);
|
|
7853
|
-
const [x, y] =
|
|
8022
|
+
const [x, y] = applyToPoint48(transform, [pad.x, pad.y]);
|
|
7854
8023
|
return [
|
|
7855
8024
|
{
|
|
7856
8025
|
name: "circle",
|
|
@@ -7870,7 +8039,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
7870
8039
|
}
|
|
7871
8040
|
if (pad.shape === "polygon") {
|
|
7872
8041
|
const points = (pad.points ?? []).map(
|
|
7873
|
-
(point) =>
|
|
8042
|
+
(point) => applyToPoint48(transform, [point.x, point.y])
|
|
7874
8043
|
);
|
|
7875
8044
|
return [
|
|
7876
8045
|
{
|
|
@@ -7891,7 +8060,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
7891
8060
|
}
|
|
7892
8061
|
|
|
7893
8062
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-port.ts
|
|
7894
|
-
import { applyToPoint as
|
|
8063
|
+
import { applyToPoint as applyToPoint49 } from "transformation-matrix";
|
|
7895
8064
|
import { calculateElbow } from "calculate-elbow";
|
|
7896
8065
|
|
|
7897
8066
|
// lib/pinout/svg-object-fns/pinout-label-box.ts
|
|
@@ -7968,7 +8137,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
7968
8137
|
const label_info = ctx.label_positions.get(pcb_port.pcb_port_id);
|
|
7969
8138
|
if (!label_info) return [];
|
|
7970
8139
|
const { text: label, aliases, elbow_end, label_pos, edge } = label_info;
|
|
7971
|
-
const [port_x, port_y] =
|
|
8140
|
+
const [port_x, port_y] = applyToPoint49(ctx.transform, [pcb_port.x, pcb_port.y]);
|
|
7972
8141
|
const start_facing_direction = edge === "left" ? "x-" : edge === "right" ? "x+" : edge === "top" ? "y-" : "y+";
|
|
7973
8142
|
const end_facing_direction = edge === "left" ? "x+" : edge === "right" ? "x-" : edge === "top" ? "y+" : "y-";
|
|
7974
8143
|
const elbow_path = calculateElbow(
|
|
@@ -8109,7 +8278,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
8109
8278
|
}
|
|
8110
8279
|
|
|
8111
8280
|
// lib/pinout/calculate-label-positions.ts
|
|
8112
|
-
import { applyToPoint as
|
|
8281
|
+
import { applyToPoint as applyToPoint50 } from "transformation-matrix";
|
|
8113
8282
|
|
|
8114
8283
|
// lib/pinout/constants.ts
|
|
8115
8284
|
var LABEL_RECT_HEIGHT_BASE_MM = 1.6;
|
|
@@ -8147,7 +8316,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
8147
8316
|
);
|
|
8148
8317
|
const mapToEdgePort = (pinout_label) => ({
|
|
8149
8318
|
pcb_port: pinout_label.pcb_port,
|
|
8150
|
-
y:
|
|
8319
|
+
y: applyToPoint50(transform, [
|
|
8151
8320
|
pinout_label.pcb_port.x,
|
|
8152
8321
|
pinout_label.pcb_port.y
|
|
8153
8322
|
])[1],
|
|
@@ -8162,7 +8331,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
8162
8331
|
} else {
|
|
8163
8332
|
edge_ports = pinout_labels.map((pinout_label) => ({
|
|
8164
8333
|
pcb_port: pinout_label.pcb_port,
|
|
8165
|
-
y:
|
|
8334
|
+
y: applyToPoint50(transform, [
|
|
8166
8335
|
pinout_label.pcb_port.x,
|
|
8167
8336
|
pinout_label.pcb_port.y
|
|
8168
8337
|
])[1],
|
|
@@ -8170,7 +8339,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
8170
8339
|
})).sort((a, b) => a.y - b.y);
|
|
8171
8340
|
}
|
|
8172
8341
|
if (edge_ports.length === 0) return;
|
|
8173
|
-
const board_edge_x =
|
|
8342
|
+
const board_edge_x = applyToPoint50(transform, [
|
|
8174
8343
|
edge === "left" ? board_bounds.minX : board_bounds.maxX,
|
|
8175
8344
|
0
|
|
8176
8345
|
])[0];
|
|
@@ -8490,8 +8659,8 @@ function convertCircuitJsonToPinoutSvg(soup, options) {
|
|
|
8490
8659
|
const pxPerMm = Math.min(pxPerMmX, pxPerMmY);
|
|
8491
8660
|
const offsetX = (svgWidth - circuitWidth * pxPerMm) / 2;
|
|
8492
8661
|
const offsetY = (svgHeight - circuitHeight * pxPerMm) / 2;
|
|
8493
|
-
const transform =
|
|
8494
|
-
|
|
8662
|
+
const transform = compose9(
|
|
8663
|
+
translate9(
|
|
8495
8664
|
offsetX - expandedMinX * pxPerMm + paddingMm * pxPerMm,
|
|
8496
8665
|
svgHeight - offsetY + minY * pxPerMm - paddingMm * pxPerMm
|
|
8497
8666
|
),
|
|
@@ -8592,14 +8761,14 @@ import {
|
|
|
8592
8761
|
} from "transformation-matrix";
|
|
8593
8762
|
|
|
8594
8763
|
// lib/sch/draw-schematic-grid.ts
|
|
8595
|
-
import { applyToPoint as
|
|
8764
|
+
import { applyToPoint as applyToPoint51 } from "transformation-matrix";
|
|
8596
8765
|
function drawSchematicGrid(params) {
|
|
8597
8766
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
8598
8767
|
const cellSize = params.cellSize ?? 1;
|
|
8599
8768
|
const labelCells = params.labelCells ?? false;
|
|
8600
8769
|
const gridLines = [];
|
|
8601
8770
|
const transformPoint = (x, y) => {
|
|
8602
|
-
const [transformedX, transformedY] =
|
|
8771
|
+
const [transformedX, transformedY] = applyToPoint51(params.transform, [x, y]);
|
|
8603
8772
|
return { x: transformedX, y: transformedY };
|
|
8604
8773
|
};
|
|
8605
8774
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -8680,15 +8849,15 @@ function drawSchematicGrid(params) {
|
|
|
8680
8849
|
}
|
|
8681
8850
|
|
|
8682
8851
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
8683
|
-
import { applyToPoint as
|
|
8852
|
+
import { applyToPoint as applyToPoint52 } from "transformation-matrix";
|
|
8684
8853
|
function drawSchematicLabeledPoints(params) {
|
|
8685
8854
|
const { points, transform } = params;
|
|
8686
8855
|
const labeledPointsGroup = [];
|
|
8687
8856
|
for (const point of points) {
|
|
8688
|
-
const [x1, y1] =
|
|
8689
|
-
const [x2, y2] =
|
|
8690
|
-
const [x3, y3] =
|
|
8691
|
-
const [x4, y4] =
|
|
8857
|
+
const [x1, y1] = applyToPoint52(transform, [point.x - 0.1, point.y - 0.1]);
|
|
8858
|
+
const [x2, y2] = applyToPoint52(transform, [point.x + 0.1, point.y + 0.1]);
|
|
8859
|
+
const [x3, y3] = applyToPoint52(transform, [point.x - 0.1, point.y + 0.1]);
|
|
8860
|
+
const [x4, y4] = applyToPoint52(transform, [point.x + 0.1, point.y - 0.1]);
|
|
8692
8861
|
labeledPointsGroup.push({
|
|
8693
8862
|
name: "path",
|
|
8694
8863
|
type: "element",
|
|
@@ -8699,7 +8868,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
8699
8868
|
"stroke-opacity": "0.7"
|
|
8700
8869
|
}
|
|
8701
8870
|
});
|
|
8702
|
-
const [labelX, labelY] =
|
|
8871
|
+
const [labelX, labelY] = applyToPoint52(transform, [
|
|
8703
8872
|
point.x + 0.15,
|
|
8704
8873
|
point.y - 0.15
|
|
8705
8874
|
]);
|
|
@@ -9817,8 +9986,8 @@ import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
|
9817
9986
|
import { symbols } from "schematic-symbols";
|
|
9818
9987
|
import "svgson";
|
|
9819
9988
|
import {
|
|
9820
|
-
applyToPoint as
|
|
9821
|
-
compose as
|
|
9989
|
+
applyToPoint as applyToPoint54,
|
|
9990
|
+
compose as compose11
|
|
9822
9991
|
} from "transformation-matrix";
|
|
9823
9992
|
|
|
9824
9993
|
// lib/utils/get-sch-stroke-size.ts
|
|
@@ -9888,26 +10057,26 @@ var matchSchPortsToSymbolPorts = ({
|
|
|
9888
10057
|
};
|
|
9889
10058
|
|
|
9890
10059
|
// lib/utils/point-pairs-to-matrix.ts
|
|
9891
|
-
import { compose as
|
|
10060
|
+
import { compose as compose10, scale as scale5, translate as translate10 } from "transformation-matrix";
|
|
9892
10061
|
function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
9893
10062
|
const tx = a2.x - a1.x;
|
|
9894
10063
|
const ty = a2.y - a1.y;
|
|
9895
10064
|
const originalDistance = Math.sqrt((b1.x - a1.x) ** 2 + (b1.y - a1.y) ** 2);
|
|
9896
10065
|
const transformedDistance = Math.sqrt((b2.x - a2.x) ** 2 + (b2.y - a2.y) ** 2);
|
|
9897
10066
|
const a = transformedDistance / originalDistance;
|
|
9898
|
-
const translateMatrix =
|
|
10067
|
+
const translateMatrix = translate10(tx, ty);
|
|
9899
10068
|
const scaleMatrix = scale5(a, a);
|
|
9900
|
-
return
|
|
10069
|
+
return compose10(translateMatrix, scaleMatrix);
|
|
9901
10070
|
}
|
|
9902
10071
|
|
|
9903
10072
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
9904
|
-
import { applyToPoint as
|
|
10073
|
+
import { applyToPoint as applyToPoint53 } from "transformation-matrix";
|
|
9905
10074
|
var createSvgSchErrorText = ({
|
|
9906
10075
|
text,
|
|
9907
10076
|
realCenter,
|
|
9908
10077
|
realToScreenTransform
|
|
9909
10078
|
}) => {
|
|
9910
|
-
const screenCenter =
|
|
10079
|
+
const screenCenter = applyToPoint53(realToScreenTransform, realCenter);
|
|
9911
10080
|
return {
|
|
9912
10081
|
type: "element",
|
|
9913
10082
|
name: "text",
|
|
@@ -10016,12 +10185,12 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10016
10185
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
10017
10186
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
10018
10187
|
};
|
|
10019
|
-
const [screenMinX, screenMinY] =
|
|
10020
|
-
|
|
10188
|
+
const [screenMinX, screenMinY] = applyToPoint54(
|
|
10189
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10021
10190
|
[bounds.minX, bounds.minY]
|
|
10022
10191
|
);
|
|
10023
|
-
const [screenMaxX, screenMaxY] =
|
|
10024
|
-
|
|
10192
|
+
const [screenMaxX, screenMaxY] = applyToPoint54(
|
|
10193
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10025
10194
|
[bounds.maxX, bounds.maxY]
|
|
10026
10195
|
);
|
|
10027
10196
|
const rectHeight = Math.abs(screenMaxY - screenMinY);
|
|
@@ -10049,8 +10218,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10049
10218
|
name: "path",
|
|
10050
10219
|
attributes: {
|
|
10051
10220
|
d: points.map((p, i) => {
|
|
10052
|
-
const [x, y] =
|
|
10053
|
-
|
|
10221
|
+
const [x, y] = applyToPoint54(
|
|
10222
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10054
10223
|
[p.x, p.y]
|
|
10055
10224
|
);
|
|
10056
10225
|
return `${i === 0 ? "M" : "L"} ${x} ${y}`;
|
|
@@ -10065,8 +10234,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10065
10234
|
});
|
|
10066
10235
|
}
|
|
10067
10236
|
for (const text of texts) {
|
|
10068
|
-
const screenTextPos =
|
|
10069
|
-
|
|
10237
|
+
const screenTextPos = applyToPoint54(
|
|
10238
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10070
10239
|
text
|
|
10071
10240
|
);
|
|
10072
10241
|
let textValue = "";
|
|
@@ -10117,11 +10286,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10117
10286
|
});
|
|
10118
10287
|
}
|
|
10119
10288
|
for (const box of boxes) {
|
|
10120
|
-
const screenBoxPos =
|
|
10121
|
-
|
|
10289
|
+
const screenBoxPos = applyToPoint54(
|
|
10290
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10122
10291
|
box
|
|
10123
10292
|
);
|
|
10124
|
-
const symbolToScreenScale =
|
|
10293
|
+
const symbolToScreenScale = compose11(
|
|
10125
10294
|
realToScreenTransform,
|
|
10126
10295
|
transformFromSymbolToReal
|
|
10127
10296
|
).a;
|
|
@@ -10141,8 +10310,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10141
10310
|
}
|
|
10142
10311
|
for (const port of symbol.ports) {
|
|
10143
10312
|
if (connectedSymbolPorts.has(port)) continue;
|
|
10144
|
-
const screenPortPos =
|
|
10145
|
-
|
|
10313
|
+
const screenPortPos = applyToPoint54(
|
|
10314
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10146
10315
|
port
|
|
10147
10316
|
);
|
|
10148
10317
|
svgObjects.push({
|
|
@@ -10161,8 +10330,8 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10161
10330
|
});
|
|
10162
10331
|
}
|
|
10163
10332
|
for (const circle of circles) {
|
|
10164
|
-
const screenCirclePos =
|
|
10165
|
-
|
|
10333
|
+
const screenCirclePos = applyToPoint54(
|
|
10334
|
+
compose11(realToScreenTransform, transformFromSymbolToReal),
|
|
10166
10335
|
circle
|
|
10167
10336
|
);
|
|
10168
10337
|
const screenRadius = Math.abs(circle.radius * realToScreenTransform.a);
|
|
@@ -10188,14 +10357,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
10188
10357
|
import { su as su10 } from "@tscircuit/circuit-json-util";
|
|
10189
10358
|
import "schematic-symbols";
|
|
10190
10359
|
import "svgson";
|
|
10191
|
-
import { applyToPoint as
|
|
10360
|
+
import { applyToPoint as applyToPoint60 } from "transformation-matrix";
|
|
10192
10361
|
|
|
10193
10362
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
10194
10363
|
import "transformation-matrix";
|
|
10195
10364
|
import "@tscircuit/circuit-json-util";
|
|
10196
10365
|
|
|
10197
10366
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
10198
|
-
import { applyToPoint as
|
|
10367
|
+
import { applyToPoint as applyToPoint55 } from "transformation-matrix";
|
|
10199
10368
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
10200
10369
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
10201
10370
|
var createArrow = (tip, angle, size, color, strokeWidth) => {
|
|
@@ -10248,8 +10417,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
10248
10417
|
realEdgePos.y += realPinLineLength;
|
|
10249
10418
|
break;
|
|
10250
10419
|
}
|
|
10251
|
-
const screenSchPortPos =
|
|
10252
|
-
const screenRealEdgePos =
|
|
10420
|
+
const screenSchPortPos = applyToPoint55(transform, schPort.center);
|
|
10421
|
+
const screenRealEdgePos = applyToPoint55(transform, realEdgePos);
|
|
10253
10422
|
const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
|
|
10254
10423
|
const realLineEnd = { ...schPort.center };
|
|
10255
10424
|
if (!isConnected) {
|
|
@@ -10268,7 +10437,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
10268
10437
|
break;
|
|
10269
10438
|
}
|
|
10270
10439
|
}
|
|
10271
|
-
const screenLineEnd =
|
|
10440
|
+
const screenLineEnd = applyToPoint55(transform, realLineEnd);
|
|
10272
10441
|
svgObjects.push({
|
|
10273
10442
|
name: "line",
|
|
10274
10443
|
type: "element",
|
|
@@ -10389,7 +10558,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
10389
10558
|
};
|
|
10390
10559
|
|
|
10391
10560
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
10392
|
-
import { applyToPoint as
|
|
10561
|
+
import { applyToPoint as applyToPoint56 } from "transformation-matrix";
|
|
10393
10562
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
10394
10563
|
const svgObjects = [];
|
|
10395
10564
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -10407,7 +10576,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
10407
10576
|
} else {
|
|
10408
10577
|
realPinNumberPos.y += 0.02;
|
|
10409
10578
|
}
|
|
10410
|
-
const screenPinNumberTextPos =
|
|
10579
|
+
const screenPinNumberTextPos = applyToPoint56(transform, realPinNumberPos);
|
|
10411
10580
|
svgObjects.push({
|
|
10412
10581
|
name: "text",
|
|
10413
10582
|
type: "element",
|
|
@@ -10437,7 +10606,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
10437
10606
|
};
|
|
10438
10607
|
|
|
10439
10608
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
10440
|
-
import { applyToPoint as
|
|
10609
|
+
import { applyToPoint as applyToPoint57 } from "transformation-matrix";
|
|
10441
10610
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
10442
10611
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
10443
10612
|
const svgObjects = [];
|
|
@@ -10451,7 +10620,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
10451
10620
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
10452
10621
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
10453
10622
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
10454
|
-
const screenPinNumberTextPos =
|
|
10623
|
+
const screenPinNumberTextPos = applyToPoint57(transform, realPinNumberPos);
|
|
10455
10624
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
10456
10625
|
if (!label) return [];
|
|
10457
10626
|
const isNegated = label.startsWith("N_");
|
|
@@ -10499,13 +10668,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
10499
10668
|
};
|
|
10500
10669
|
|
|
10501
10670
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
10502
|
-
import { applyToPoint as
|
|
10671
|
+
import { applyToPoint as applyToPoint59 } from "transformation-matrix";
|
|
10503
10672
|
var createSvgSchText = ({
|
|
10504
10673
|
elm,
|
|
10505
10674
|
transform,
|
|
10506
10675
|
colorMap: colorMap2
|
|
10507
10676
|
}) => {
|
|
10508
|
-
const center =
|
|
10677
|
+
const center = applyToPoint59(transform, elm.position);
|
|
10509
10678
|
const textAnchorMap = {
|
|
10510
10679
|
center: "middle",
|
|
10511
10680
|
center_right: "end",
|
|
@@ -10589,11 +10758,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
10589
10758
|
colorMap: colorMap2
|
|
10590
10759
|
}) => {
|
|
10591
10760
|
const svgObjects = [];
|
|
10592
|
-
const componentScreenTopLeft =
|
|
10761
|
+
const componentScreenTopLeft = applyToPoint60(transform, {
|
|
10593
10762
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
10594
10763
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
10595
10764
|
});
|
|
10596
|
-
const componentScreenBottomRight =
|
|
10765
|
+
const componentScreenBottomRight = applyToPoint60(transform, {
|
|
10597
10766
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
10598
10767
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
10599
10768
|
});
|
|
@@ -10679,13 +10848,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
10679
10848
|
}
|
|
10680
10849
|
|
|
10681
10850
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
10682
|
-
import { applyToPoint as
|
|
10851
|
+
import { applyToPoint as applyToPoint61 } from "transformation-matrix";
|
|
10683
10852
|
function createSvgObjectsFromSchVoltageProbe({
|
|
10684
10853
|
probe,
|
|
10685
10854
|
transform,
|
|
10686
10855
|
colorMap: colorMap2
|
|
10687
10856
|
}) {
|
|
10688
|
-
const [screenX, screenY] =
|
|
10857
|
+
const [screenX, screenY] = applyToPoint61(transform, [
|
|
10689
10858
|
probe.position.x,
|
|
10690
10859
|
probe.position.y
|
|
10691
10860
|
]);
|
|
@@ -10859,17 +11028,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
10859
11028
|
}
|
|
10860
11029
|
|
|
10861
11030
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
10862
|
-
import { applyToPoint as
|
|
11031
|
+
import { applyToPoint as applyToPoint62 } from "transformation-matrix";
|
|
10863
11032
|
function createSvgObjectsFromSchDebugObject({
|
|
10864
11033
|
debugObject,
|
|
10865
11034
|
transform
|
|
10866
11035
|
}) {
|
|
10867
11036
|
if (debugObject.shape === "rect") {
|
|
10868
|
-
let [screenLeft, screenTop] =
|
|
11037
|
+
let [screenLeft, screenTop] = applyToPoint62(transform, [
|
|
10869
11038
|
debugObject.center.x - debugObject.size.width / 2,
|
|
10870
11039
|
debugObject.center.y - debugObject.size.height / 2
|
|
10871
11040
|
]);
|
|
10872
|
-
let [screenRight, screenBottom] =
|
|
11041
|
+
let [screenRight, screenBottom] = applyToPoint62(transform, [
|
|
10873
11042
|
debugObject.center.x + debugObject.size.width / 2,
|
|
10874
11043
|
debugObject.center.y + debugObject.size.height / 2
|
|
10875
11044
|
]);
|
|
@@ -10879,7 +11048,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
10879
11048
|
];
|
|
10880
11049
|
const width = Math.abs(screenRight - screenLeft);
|
|
10881
11050
|
const height = Math.abs(screenBottom - screenTop);
|
|
10882
|
-
const [screenCenterX, screenCenterY] =
|
|
11051
|
+
const [screenCenterX, screenCenterY] = applyToPoint62(transform, [
|
|
10883
11052
|
debugObject.center.x,
|
|
10884
11053
|
debugObject.center.y
|
|
10885
11054
|
]);
|
|
@@ -10925,11 +11094,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
10925
11094
|
];
|
|
10926
11095
|
}
|
|
10927
11096
|
if (debugObject.shape === "line") {
|
|
10928
|
-
const [screenStartX, screenStartY] =
|
|
11097
|
+
const [screenStartX, screenStartY] = applyToPoint62(transform, [
|
|
10929
11098
|
debugObject.start.x,
|
|
10930
11099
|
debugObject.start.y
|
|
10931
11100
|
]);
|
|
10932
|
-
const [screenEndX, screenEndY] =
|
|
11101
|
+
const [screenEndX, screenEndY] = applyToPoint62(transform, [
|
|
10933
11102
|
debugObject.end.x,
|
|
10934
11103
|
debugObject.end.y
|
|
10935
11104
|
]);
|
|
@@ -10979,7 +11148,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
10979
11148
|
}
|
|
10980
11149
|
|
|
10981
11150
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
10982
|
-
import { applyToPoint as
|
|
11151
|
+
import { applyToPoint as applyToPoint63 } from "transformation-matrix";
|
|
10983
11152
|
function createSchematicTrace({
|
|
10984
11153
|
trace,
|
|
10985
11154
|
transform,
|
|
@@ -10993,11 +11162,11 @@ function createSchematicTrace({
|
|
|
10993
11162
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
10994
11163
|
const edge = edges[edgeIndex];
|
|
10995
11164
|
if (edge.is_crossing) continue;
|
|
10996
|
-
const [screenFromX, screenFromY] =
|
|
11165
|
+
const [screenFromX, screenFromY] = applyToPoint63(transform, [
|
|
10997
11166
|
edge.from.x,
|
|
10998
11167
|
edge.from.y
|
|
10999
11168
|
]);
|
|
11000
|
-
const [screenToX, screenToY] =
|
|
11169
|
+
const [screenToX, screenToY] = applyToPoint63(transform, [
|
|
11001
11170
|
edge.to.x,
|
|
11002
11171
|
edge.to.y
|
|
11003
11172
|
]);
|
|
@@ -11041,11 +11210,11 @@ function createSchematicTrace({
|
|
|
11041
11210
|
}
|
|
11042
11211
|
for (const edge of edges) {
|
|
11043
11212
|
if (!edge.is_crossing) continue;
|
|
11044
|
-
const [screenFromX, screenFromY] =
|
|
11213
|
+
const [screenFromX, screenFromY] = applyToPoint63(transform, [
|
|
11045
11214
|
edge.from.x,
|
|
11046
11215
|
edge.from.y
|
|
11047
11216
|
]);
|
|
11048
|
-
const [screenToX, screenToY] =
|
|
11217
|
+
const [screenToX, screenToY] = applyToPoint63(transform, [
|
|
11049
11218
|
edge.to.x,
|
|
11050
11219
|
edge.to.y
|
|
11051
11220
|
]);
|
|
@@ -11089,7 +11258,7 @@ function createSchematicTrace({
|
|
|
11089
11258
|
}
|
|
11090
11259
|
if (trace.junctions) {
|
|
11091
11260
|
for (const junction of trace.junctions) {
|
|
11092
|
-
const [screenX, screenY] =
|
|
11261
|
+
const [screenX, screenY] = applyToPoint63(transform, [
|
|
11093
11262
|
junction.x,
|
|
11094
11263
|
junction.y
|
|
11095
11264
|
]);
|
|
@@ -11144,20 +11313,20 @@ function createSchematicTrace({
|
|
|
11144
11313
|
|
|
11145
11314
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
11146
11315
|
import {
|
|
11147
|
-
applyToPoint as
|
|
11148
|
-
compose as
|
|
11316
|
+
applyToPoint as applyToPoint65,
|
|
11317
|
+
compose as compose13,
|
|
11149
11318
|
rotate as rotate7,
|
|
11150
11319
|
scale as scale7,
|
|
11151
|
-
translate as
|
|
11320
|
+
translate as translate13
|
|
11152
11321
|
} from "transformation-matrix";
|
|
11153
11322
|
|
|
11154
11323
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
11155
11324
|
import {
|
|
11156
|
-
applyToPoint as
|
|
11157
|
-
compose as
|
|
11325
|
+
applyToPoint as applyToPoint64,
|
|
11326
|
+
compose as compose12,
|
|
11158
11327
|
rotate as rotate6,
|
|
11159
11328
|
scale as scale6,
|
|
11160
|
-
translate as
|
|
11329
|
+
translate as translate12
|
|
11161
11330
|
} from "transformation-matrix";
|
|
11162
11331
|
import { symbols as symbols3 } from "schematic-symbols";
|
|
11163
11332
|
var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
@@ -11228,9 +11397,9 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
11228
11397
|
x: symbolBounds.minX,
|
|
11229
11398
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
11230
11399
|
};
|
|
11231
|
-
const rotatedSymbolEnd =
|
|
11232
|
-
const symbolToRealTransform =
|
|
11233
|
-
|
|
11400
|
+
const rotatedSymbolEnd = applyToPoint64(rotationMatrix, symbolEndPoint);
|
|
11401
|
+
const symbolToRealTransform = compose12(
|
|
11402
|
+
translate12(
|
|
11234
11403
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
11235
11404
|
realAnchorPosition.y - rotatedSymbolEnd.y
|
|
11236
11405
|
),
|
|
@@ -11238,12 +11407,12 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
11238
11407
|
scale6(1)
|
|
11239
11408
|
// Use full symbol size
|
|
11240
11409
|
);
|
|
11241
|
-
const [screenMinX, screenMinY] =
|
|
11242
|
-
|
|
11410
|
+
const [screenMinX, screenMinY] = applyToPoint64(
|
|
11411
|
+
compose12(realToScreenTransform, symbolToRealTransform),
|
|
11243
11412
|
[bounds.minX, bounds.minY]
|
|
11244
11413
|
);
|
|
11245
|
-
const [screenMaxX, screenMaxY] =
|
|
11246
|
-
|
|
11414
|
+
const [screenMaxX, screenMaxY] = applyToPoint64(
|
|
11415
|
+
compose12(realToScreenTransform, symbolToRealTransform),
|
|
11247
11416
|
[bounds.maxX, bounds.maxY]
|
|
11248
11417
|
);
|
|
11249
11418
|
const rectHeight = Math.abs(screenMaxY - screenMinY);
|
|
@@ -11266,8 +11435,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
11266
11435
|
});
|
|
11267
11436
|
for (const path of symbolPaths) {
|
|
11268
11437
|
const symbolPath = path.points.map((p, i) => {
|
|
11269
|
-
const [x, y] =
|
|
11270
|
-
|
|
11438
|
+
const [x, y] = applyToPoint64(
|
|
11439
|
+
compose12(realToScreenTransform, symbolToRealTransform),
|
|
11271
11440
|
[p.x, p.y]
|
|
11272
11441
|
);
|
|
11273
11442
|
return `${i === 0 ? "M" : "L"} ${x} ${y}`;
|
|
@@ -11287,8 +11456,8 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
11287
11456
|
});
|
|
11288
11457
|
}
|
|
11289
11458
|
for (const text of symbolTexts) {
|
|
11290
|
-
const screenTextPos =
|
|
11291
|
-
|
|
11459
|
+
const screenTextPos = applyToPoint64(
|
|
11460
|
+
compose12(realToScreenTransform, symbolToRealTransform),
|
|
11292
11461
|
text
|
|
11293
11462
|
);
|
|
11294
11463
|
let textValue = text.text;
|
|
@@ -11329,11 +11498,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
11329
11498
|
});
|
|
11330
11499
|
}
|
|
11331
11500
|
for (const box of symbolBoxes) {
|
|
11332
|
-
const screenBoxPos =
|
|
11333
|
-
|
|
11501
|
+
const screenBoxPos = applyToPoint64(
|
|
11502
|
+
compose12(realToScreenTransform, symbolToRealTransform),
|
|
11334
11503
|
box
|
|
11335
11504
|
);
|
|
11336
|
-
const symbolToScreenScale =
|
|
11505
|
+
const symbolToScreenScale = compose12(
|
|
11337
11506
|
realToScreenTransform,
|
|
11338
11507
|
symbolToRealTransform
|
|
11339
11508
|
).a;
|
|
@@ -11352,11 +11521,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
11352
11521
|
});
|
|
11353
11522
|
}
|
|
11354
11523
|
for (const circle of symbolCircles) {
|
|
11355
|
-
const screenCirclePos =
|
|
11356
|
-
|
|
11524
|
+
const screenCirclePos = applyToPoint64(
|
|
11525
|
+
compose12(realToScreenTransform, symbolToRealTransform),
|
|
11357
11526
|
circle
|
|
11358
11527
|
);
|
|
11359
|
-
const symbolToScreenScale =
|
|
11528
|
+
const symbolToScreenScale = compose12(
|
|
11360
11529
|
realToScreenTransform,
|
|
11361
11530
|
symbolToRealTransform
|
|
11362
11531
|
).a;
|
|
@@ -11397,14 +11566,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
11397
11566
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
11398
11567
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
11399
11568
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
11400
|
-
const screenCenter =
|
|
11569
|
+
const screenCenter = applyToPoint65(realToScreenTransform, schNetLabel.center);
|
|
11401
11570
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
11402
11571
|
schNetLabel.anchor_side
|
|
11403
11572
|
);
|
|
11404
11573
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
11405
11574
|
screenTextGrowthVec.y *= -1;
|
|
11406
11575
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
11407
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
11576
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint65(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
11408
11577
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
11409
11578
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
11410
11579
|
};
|
|
@@ -11445,10 +11614,10 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
11445
11614
|
y: -0.6
|
|
11446
11615
|
}
|
|
11447
11616
|
].map(
|
|
11448
|
-
(fontRelativePoint) =>
|
|
11449
|
-
|
|
11617
|
+
(fontRelativePoint) => applyToPoint65(
|
|
11618
|
+
compose13(
|
|
11450
11619
|
realToScreenTransform,
|
|
11451
|
-
|
|
11620
|
+
translate13(realAnchorPosition.x, realAnchorPosition.y),
|
|
11452
11621
|
scale7(fontSizeMm),
|
|
11453
11622
|
rotate7(pathRotation / 180 * Math.PI)
|
|
11454
11623
|
),
|
|
@@ -11522,17 +11691,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
11522
11691
|
};
|
|
11523
11692
|
|
|
11524
11693
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
11525
|
-
import { applyToPoint as
|
|
11694
|
+
import { applyToPoint as applyToPoint66 } from "transformation-matrix";
|
|
11526
11695
|
var createSvgObjectsFromSchematicBox = ({
|
|
11527
11696
|
schematicBox,
|
|
11528
11697
|
transform,
|
|
11529
11698
|
colorMap: colorMap2
|
|
11530
11699
|
}) => {
|
|
11531
|
-
const topLeft =
|
|
11700
|
+
const topLeft = applyToPoint66(transform, {
|
|
11532
11701
|
x: schematicBox.x,
|
|
11533
11702
|
y: schematicBox.y
|
|
11534
11703
|
});
|
|
11535
|
-
const bottomRight =
|
|
11704
|
+
const bottomRight = applyToPoint66(transform, {
|
|
11536
11705
|
x: schematicBox.x + schematicBox.width,
|
|
11537
11706
|
y: schematicBox.y + schematicBox.height
|
|
11538
11707
|
});
|
|
@@ -11568,7 +11737,7 @@ var createSvgObjectsFromSchematicBox = ({
|
|
|
11568
11737
|
};
|
|
11569
11738
|
|
|
11570
11739
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-table.ts
|
|
11571
|
-
import { applyToPoint as
|
|
11740
|
+
import { applyToPoint as applyToPoint67 } from "transformation-matrix";
|
|
11572
11741
|
var createSvgObjectsFromSchematicTable = ({
|
|
11573
11742
|
schematicTable,
|
|
11574
11743
|
transform,
|
|
@@ -11601,11 +11770,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11601
11770
|
const svgObjects = [];
|
|
11602
11771
|
const borderStrokeWidth = border_width * Math.abs(transform.a);
|
|
11603
11772
|
const gridStrokeWidth = getSchStrokeSize(transform);
|
|
11604
|
-
const [screenTopLeftX, screenTopLeftY] =
|
|
11773
|
+
const [screenTopLeftX, screenTopLeftY] = applyToPoint67(transform, [
|
|
11605
11774
|
topLeftX,
|
|
11606
11775
|
topLeftY
|
|
11607
11776
|
]);
|
|
11608
|
-
const [screenBottomRightX, screenBottomRightY] =
|
|
11777
|
+
const [screenBottomRightX, screenBottomRightY] = applyToPoint67(transform, [
|
|
11609
11778
|
topLeftX + totalWidth,
|
|
11610
11779
|
topLeftY - totalHeight
|
|
11611
11780
|
]);
|
|
@@ -11637,8 +11806,8 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11637
11806
|
(cell) => cell.start_column_index <= i && cell.end_column_index > i && cell.start_row_index <= j && cell.end_row_index >= j
|
|
11638
11807
|
);
|
|
11639
11808
|
if (!isMerged) {
|
|
11640
|
-
const start =
|
|
11641
|
-
const end =
|
|
11809
|
+
const start = applyToPoint67(transform, { x: currentX, y: segmentStartY });
|
|
11810
|
+
const end = applyToPoint67(transform, { x: currentX, y: segmentEndY });
|
|
11642
11811
|
svgObjects.push({
|
|
11643
11812
|
name: "line",
|
|
11644
11813
|
type: "element",
|
|
@@ -11667,11 +11836,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11667
11836
|
(cell) => cell.start_row_index <= i && cell.end_row_index > i && cell.start_column_index <= j && cell.end_column_index >= j
|
|
11668
11837
|
);
|
|
11669
11838
|
if (!isMerged) {
|
|
11670
|
-
const start =
|
|
11839
|
+
const start = applyToPoint67(transform, {
|
|
11671
11840
|
x: segmentStartX,
|
|
11672
11841
|
y: currentY
|
|
11673
11842
|
});
|
|
11674
|
-
const end =
|
|
11843
|
+
const end = applyToPoint67(transform, { x: segmentEndX, y: currentY });
|
|
11675
11844
|
svgObjects.push({
|
|
11676
11845
|
name: "line",
|
|
11677
11846
|
type: "element",
|
|
@@ -11713,7 +11882,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11713
11882
|
} else if (vertical_align === "bottom") {
|
|
11714
11883
|
realTextAnchorPos.y = cellTopLeftY - cellHeight + cell_padding;
|
|
11715
11884
|
}
|
|
11716
|
-
const screenTextAnchorPos =
|
|
11885
|
+
const screenTextAnchorPos = applyToPoint67(transform, realTextAnchorPos);
|
|
11717
11886
|
const fontSize = getSchScreenFontSize(
|
|
11718
11887
|
transform,
|
|
11719
11888
|
"reference_designator",
|
|
@@ -11769,13 +11938,13 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
11769
11938
|
|
|
11770
11939
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
|
|
11771
11940
|
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
11772
|
-
import { applyToPoint as
|
|
11941
|
+
import { applyToPoint as applyToPoint68 } from "transformation-matrix";
|
|
11773
11942
|
var PIN_CIRCLE_RADIUS_MM2 = 0.02;
|
|
11774
11943
|
var createSvgObjectsForSchPortHover = ({
|
|
11775
11944
|
schPort,
|
|
11776
11945
|
transform
|
|
11777
11946
|
}) => {
|
|
11778
|
-
const screenSchPortPos =
|
|
11947
|
+
const screenSchPortPos = applyToPoint68(transform, schPort.center);
|
|
11779
11948
|
const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
|
|
11780
11949
|
return [
|
|
11781
11950
|
{
|
|
@@ -11820,14 +11989,14 @@ var createSvgObjectsForSchComponentPortHovers = ({
|
|
|
11820
11989
|
};
|
|
11821
11990
|
|
|
11822
11991
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-line.ts
|
|
11823
|
-
import { applyToPoint as
|
|
11992
|
+
import { applyToPoint as applyToPoint69 } from "transformation-matrix";
|
|
11824
11993
|
function createSvgObjectsFromSchematicLine({
|
|
11825
11994
|
schLine,
|
|
11826
11995
|
transform,
|
|
11827
11996
|
colorMap: colorMap2
|
|
11828
11997
|
}) {
|
|
11829
|
-
const p1 =
|
|
11830
|
-
const p2 =
|
|
11998
|
+
const p1 = applyToPoint69(transform, { x: schLine.x1, y: schLine.y1 });
|
|
11999
|
+
const p2 = applyToPoint69(transform, { x: schLine.x2, y: schLine.y2 });
|
|
11831
12000
|
const strokeWidth = schLine.stroke_width ?? 0.02;
|
|
11832
12001
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
11833
12002
|
return [
|
|
@@ -11856,13 +12025,13 @@ function createSvgObjectsFromSchematicLine({
|
|
|
11856
12025
|
}
|
|
11857
12026
|
|
|
11858
12027
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-circle.ts
|
|
11859
|
-
import { applyToPoint as
|
|
12028
|
+
import { applyToPoint as applyToPoint70 } from "transformation-matrix";
|
|
11860
12029
|
function createSvgObjectsFromSchematicCircle({
|
|
11861
12030
|
schCircle,
|
|
11862
12031
|
transform,
|
|
11863
12032
|
colorMap: colorMap2
|
|
11864
12033
|
}) {
|
|
11865
|
-
const center =
|
|
12034
|
+
const center = applyToPoint70(transform, schCircle.center);
|
|
11866
12035
|
const transformedRadius = Math.abs(transform.a) * schCircle.radius;
|
|
11867
12036
|
const strokeWidth = schCircle.stroke_width ?? 0.02;
|
|
11868
12037
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -11892,13 +12061,13 @@ function createSvgObjectsFromSchematicCircle({
|
|
|
11892
12061
|
}
|
|
11893
12062
|
|
|
11894
12063
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-rect.ts
|
|
11895
|
-
import { applyToPoint as
|
|
12064
|
+
import { applyToPoint as applyToPoint71 } from "transformation-matrix";
|
|
11896
12065
|
function createSvgObjectsFromSchematicRect({
|
|
11897
12066
|
schRect,
|
|
11898
12067
|
transform,
|
|
11899
12068
|
colorMap: colorMap2
|
|
11900
12069
|
}) {
|
|
11901
|
-
const center =
|
|
12070
|
+
const center = applyToPoint71(transform, schRect.center);
|
|
11902
12071
|
const transformedWidth = Math.abs(transform.a) * schRect.width;
|
|
11903
12072
|
const transformedHeight = Math.abs(transform.d) * schRect.height;
|
|
11904
12073
|
const strokeWidth = schRect.stroke_width ?? 0.02;
|
|
@@ -11934,13 +12103,13 @@ function createSvgObjectsFromSchematicRect({
|
|
|
11934
12103
|
}
|
|
11935
12104
|
|
|
11936
12105
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-arc.ts
|
|
11937
|
-
import { applyToPoint as
|
|
12106
|
+
import { applyToPoint as applyToPoint72 } from "transformation-matrix";
|
|
11938
12107
|
function createSvgObjectsFromSchematicArc({
|
|
11939
12108
|
schArc,
|
|
11940
12109
|
transform,
|
|
11941
12110
|
colorMap: colorMap2
|
|
11942
12111
|
}) {
|
|
11943
|
-
const center =
|
|
12112
|
+
const center = applyToPoint72(transform, schArc.center);
|
|
11944
12113
|
const transformedRadius = Math.abs(transform.a) * schArc.radius;
|
|
11945
12114
|
const strokeWidth = schArc.stroke_width ?? 0.02;
|
|
11946
12115
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -13060,18 +13229,18 @@ function formatNumber2(value) {
|
|
|
13060
13229
|
import { distance as distance3 } from "circuit-json";
|
|
13061
13230
|
import { stringify as stringify7 } from "svgson";
|
|
13062
13231
|
import {
|
|
13063
|
-
applyToPoint as
|
|
13064
|
-
compose as
|
|
13232
|
+
applyToPoint as applyToPoint75,
|
|
13233
|
+
compose as compose16,
|
|
13065
13234
|
scale as scale9,
|
|
13066
|
-
translate as
|
|
13235
|
+
translate as translate16
|
|
13067
13236
|
} from "transformation-matrix";
|
|
13068
13237
|
|
|
13069
13238
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
13070
|
-
import { applyToPoint as
|
|
13239
|
+
import { applyToPoint as applyToPoint74 } from "transformation-matrix";
|
|
13071
13240
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
13072
13241
|
const { transform, layer: layerFilter } = ctx;
|
|
13073
13242
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
13074
|
-
const [x, y] =
|
|
13243
|
+
const [x, y] = applyToPoint74(transform, [solderPaste.x, solderPaste.y]);
|
|
13075
13244
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
13076
13245
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
13077
13246
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -13195,8 +13364,8 @@ function convertCircuitJsonToSolderPasteMask(circuitJson, options) {
|
|
|
13195
13364
|
const scaleFactor = Math.min(scaleX, scaleY);
|
|
13196
13365
|
const offsetX = (svgWidth - circuitWidth * scaleFactor) / 2;
|
|
13197
13366
|
const offsetY = (svgHeight - circuitHeight * scaleFactor) / 2;
|
|
13198
|
-
const transform =
|
|
13199
|
-
|
|
13367
|
+
const transform = compose16(
|
|
13368
|
+
translate16(
|
|
13200
13369
|
offsetX - minX * scaleFactor + padding * scaleFactor,
|
|
13201
13370
|
svgHeight - offsetY + minY * scaleFactor - padding * scaleFactor
|
|
13202
13371
|
),
|
|
@@ -13297,8 +13466,8 @@ function createSvgObjects4({ elm, ctx }) {
|
|
|
13297
13466
|
}
|
|
13298
13467
|
}
|
|
13299
13468
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
13300
|
-
const [x1, y1] =
|
|
13301
|
-
const [x2, y2] =
|
|
13469
|
+
const [x1, y1] = applyToPoint75(transform, [minX, minY]);
|
|
13470
|
+
const [x2, y2] = applyToPoint75(transform, [maxX, maxY]);
|
|
13302
13471
|
const width = Math.abs(x2 - x1);
|
|
13303
13472
|
const height = Math.abs(y2 - y1);
|
|
13304
13473
|
const x = Math.min(x1, x2);
|