circuit-to-svg 0.0.228 → 0.0.230
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/README.md +5 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +524 -207
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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 applyToPoint21,
|
|
5
5
|
compose as compose5,
|
|
6
6
|
scale as scale2,
|
|
7
7
|
translate as translate5
|
|
@@ -265,8 +265,171 @@ function annotateTraceErrorSvgObjects(objects) {
|
|
|
265
265
|
}));
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-
|
|
268
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-footprint-overlap-error.ts
|
|
269
269
|
import { applyToPoint as applyToPoint2 } from "transformation-matrix";
|
|
270
|
+
function annotateFootprintErrorSvgObjects(objects) {
|
|
271
|
+
return objects.map((object) => ({
|
|
272
|
+
...object,
|
|
273
|
+
attributes: {
|
|
274
|
+
...object.attributes ?? {},
|
|
275
|
+
"data-type": object.attributes?.["data-type"] ?? "pcb_footprint_overlap_error",
|
|
276
|
+
"data-pcb-layer": object.attributes?.["data-pcb-layer"] ?? "overlay"
|
|
277
|
+
},
|
|
278
|
+
children: (object.children ?? []).map((child) => {
|
|
279
|
+
if (child?.type === "element") {
|
|
280
|
+
return {
|
|
281
|
+
...child,
|
|
282
|
+
attributes: {
|
|
283
|
+
...child.attributes ?? {},
|
|
284
|
+
"data-type": child.attributes?.["data-type"] ?? "pcb_footprint_overlap_error",
|
|
285
|
+
"data-pcb-layer": child.attributes?.["data-pcb-layer"] ?? "overlay"
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
return child;
|
|
290
|
+
})
|
|
291
|
+
}));
|
|
292
|
+
}
|
|
293
|
+
function createSvgObjectsFromPcbFootprintOverlapError(error, circuitJson, ctx) {
|
|
294
|
+
const { transform, shouldDrawErrors } = ctx;
|
|
295
|
+
if (!shouldDrawErrors) return [];
|
|
296
|
+
const svgObjects = [];
|
|
297
|
+
const referencedElements = [];
|
|
298
|
+
let padPortIds = [];
|
|
299
|
+
if (error.pcb_smtpad_ids) {
|
|
300
|
+
for (const padId of error.pcb_smtpad_ids) {
|
|
301
|
+
const pad = circuitJson.find(
|
|
302
|
+
(el) => el.type === "pcb_smtpad" && el.pcb_smtpad_id === padId
|
|
303
|
+
);
|
|
304
|
+
if (pad) {
|
|
305
|
+
referencedElements.push({
|
|
306
|
+
x: pad.x,
|
|
307
|
+
y: pad.y,
|
|
308
|
+
type: "pcb_smtpad",
|
|
309
|
+
id: padId,
|
|
310
|
+
pcb_port_id: pad.pcb_port_id
|
|
311
|
+
});
|
|
312
|
+
if (pad.pcb_port_id) padPortIds.push(pad.pcb_port_id);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const allPadsSamePort = padPortIds.length > 1 && padPortIds.every((id) => id === padPortIds[0]);
|
|
317
|
+
let filteredReferencedElements = referencedElements;
|
|
318
|
+
if (allPadsSamePort) {
|
|
319
|
+
filteredReferencedElements = referencedElements.filter(
|
|
320
|
+
(e) => e.type !== "pcb_smtpad"
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
if (error.pcb_plated_hole_ids) {
|
|
324
|
+
for (const holeId of error.pcb_plated_hole_ids) {
|
|
325
|
+
const hole = circuitJson.find(
|
|
326
|
+
(el) => el.type === "pcb_plated_hole" && el.pcb_plated_hole_id === holeId
|
|
327
|
+
);
|
|
328
|
+
if (hole) {
|
|
329
|
+
filteredReferencedElements.push({
|
|
330
|
+
x: hole.x,
|
|
331
|
+
y: hole.y,
|
|
332
|
+
type: "pcb_plated_hole",
|
|
333
|
+
id: holeId
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
if (error.pcb_hole_ids) {
|
|
339
|
+
for (const holeId of error.pcb_hole_ids) {
|
|
340
|
+
const hole = circuitJson.find(
|
|
341
|
+
(el) => el.type === "pcb_hole" && el.pcb_hole_id === holeId
|
|
342
|
+
);
|
|
343
|
+
if (hole) {
|
|
344
|
+
filteredReferencedElements.push({
|
|
345
|
+
x: hole.x,
|
|
346
|
+
y: hole.y,
|
|
347
|
+
type: "pcb_hole",
|
|
348
|
+
id: holeId
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
if (filteredReferencedElements.length > 0) {
|
|
354
|
+
const centerX = filteredReferencedElements.reduce((sum, el) => sum + el.x, 0) / filteredReferencedElements.length;
|
|
355
|
+
const centerY = filteredReferencedElements.reduce((sum, el) => sum + el.y, 0) / filteredReferencedElements.length;
|
|
356
|
+
const screenCenter = applyToPoint2(transform, { x: centerX, y: centerY });
|
|
357
|
+
svgObjects.push({
|
|
358
|
+
name: "rect",
|
|
359
|
+
type: "element",
|
|
360
|
+
attributes: {
|
|
361
|
+
x: (screenCenter.x - 5).toString(),
|
|
362
|
+
y: (screenCenter.y - 5).toString(),
|
|
363
|
+
width: "10",
|
|
364
|
+
height: "10",
|
|
365
|
+
fill: "red",
|
|
366
|
+
transform: `rotate(45 ${screenCenter.x} ${screenCenter.y})`
|
|
367
|
+
},
|
|
368
|
+
children: [],
|
|
369
|
+
value: ""
|
|
370
|
+
});
|
|
371
|
+
svgObjects.push({
|
|
372
|
+
name: "text",
|
|
373
|
+
type: "element",
|
|
374
|
+
attributes: {
|
|
375
|
+
x: screenCenter.x.toString(),
|
|
376
|
+
y: (screenCenter.y - 15).toString(),
|
|
377
|
+
fill: "red",
|
|
378
|
+
"font-family": "sans-serif",
|
|
379
|
+
"font-size": "12",
|
|
380
|
+
"text-anchor": "middle"
|
|
381
|
+
},
|
|
382
|
+
children: [
|
|
383
|
+
{
|
|
384
|
+
type: "text",
|
|
385
|
+
value: error.message || "PCB Footprint Overlap Error",
|
|
386
|
+
name: "",
|
|
387
|
+
attributes: {},
|
|
388
|
+
children: []
|
|
389
|
+
}
|
|
390
|
+
],
|
|
391
|
+
value: ""
|
|
392
|
+
});
|
|
393
|
+
for (const element of filteredReferencedElements) {
|
|
394
|
+
const screenPos = applyToPoint2(transform, { x: element.x, y: element.y });
|
|
395
|
+
svgObjects.push({
|
|
396
|
+
name: "rect",
|
|
397
|
+
type: "element",
|
|
398
|
+
attributes: {
|
|
399
|
+
x: (screenPos.x - 5).toString(),
|
|
400
|
+
y: (screenPos.y - 5).toString(),
|
|
401
|
+
width: "10",
|
|
402
|
+
height: "10",
|
|
403
|
+
fill: "red",
|
|
404
|
+
transform: `rotate(45 ${screenPos.x} ${screenPos.y})`
|
|
405
|
+
},
|
|
406
|
+
children: [],
|
|
407
|
+
value: ""
|
|
408
|
+
});
|
|
409
|
+
if (filteredReferencedElements.length > 1) {
|
|
410
|
+
svgObjects.push({
|
|
411
|
+
name: "line",
|
|
412
|
+
type: "element",
|
|
413
|
+
attributes: {
|
|
414
|
+
x1: screenCenter.x.toString(),
|
|
415
|
+
y1: screenCenter.y.toString(),
|
|
416
|
+
x2: screenPos.x.toString(),
|
|
417
|
+
y2: screenPos.y.toString(),
|
|
418
|
+
stroke: "red",
|
|
419
|
+
"stroke-width": "1.5",
|
|
420
|
+
"stroke-dasharray": "2,2"
|
|
421
|
+
},
|
|
422
|
+
children: [],
|
|
423
|
+
value: ""
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return annotateFootprintErrorSvgObjects(svgObjects);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-fabrication-note-path.ts
|
|
432
|
+
import { applyToPoint as applyToPoint3 } from "transformation-matrix";
|
|
270
433
|
function createSvgObjectsFromPcbFabricationNotePath(fabNotePath, ctx) {
|
|
271
434
|
const { transform, layer: layerFilter } = ctx;
|
|
272
435
|
if (!fabNotePath.route || !Array.isArray(fabNotePath.route)) return [];
|
|
@@ -274,7 +437,7 @@ function createSvgObjectsFromPcbFabricationNotePath(fabNotePath, ctx) {
|
|
|
274
437
|
const lastPoint = fabNotePath.route[fabNotePath.route.length - 1];
|
|
275
438
|
const isClosed = firstPoint.x === lastPoint.x && firstPoint.y === lastPoint.y;
|
|
276
439
|
const path = fabNotePath.route.slice(0, isClosed ? -1 : void 0).map((point, index) => {
|
|
277
|
-
const [x, y] =
|
|
440
|
+
const [x, y] = applyToPoint3(transform, [point.x, point.y]);
|
|
278
441
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
279
442
|
}).join(" ") + (isClosed ? " Z" : "");
|
|
280
443
|
return [
|
|
@@ -300,7 +463,7 @@ function createSvgObjectsFromPcbFabricationNotePath(fabNotePath, ctx) {
|
|
|
300
463
|
|
|
301
464
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-fabrication-note-text.ts
|
|
302
465
|
import { toString as matrixToString } from "transformation-matrix";
|
|
303
|
-
import { applyToPoint as
|
|
466
|
+
import { applyToPoint as applyToPoint4, compose, rotate, translate } from "transformation-matrix";
|
|
304
467
|
function createSvgObjectsFromPcbFabricationNoteText(pcbFabNoteText, ctx) {
|
|
305
468
|
const { transform, layer: layerFilter } = ctx;
|
|
306
469
|
const {
|
|
@@ -316,7 +479,7 @@ function createSvgObjectsFromPcbFabricationNoteText(pcbFabNoteText, ctx) {
|
|
|
316
479
|
console.error("Invalid anchor_position:", anchor_position);
|
|
317
480
|
return [];
|
|
318
481
|
}
|
|
319
|
-
const [transformedX, transformedY] =
|
|
482
|
+
const [transformedX, transformedY] = applyToPoint4(transform, [
|
|
320
483
|
anchor_position.x,
|
|
321
484
|
anchor_position.y
|
|
322
485
|
]);
|
|
@@ -358,10 +521,10 @@ function createSvgObjectsFromPcbFabricationNoteText(pcbFabNoteText, ctx) {
|
|
|
358
521
|
}
|
|
359
522
|
|
|
360
523
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-plated-hole.ts
|
|
361
|
-
import { applyToPoint as
|
|
524
|
+
import { applyToPoint as applyToPoint5 } from "transformation-matrix";
|
|
362
525
|
function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
363
526
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
364
|
-
const [x, y] =
|
|
527
|
+
const [x, y] = applyToPoint5(transform, [hole.x, hole.y]);
|
|
365
528
|
const copperLayer = Array.isArray(hole.layers) && hole.layers[0] || hole.layer || "top";
|
|
366
529
|
if (hole.shape === "pill") {
|
|
367
530
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
@@ -478,7 +641,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
478
641
|
const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
|
|
479
642
|
const scaledRectBorderRadius = (hole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
480
643
|
const holeRadius = scaledHoleDiameter / 2;
|
|
481
|
-
const [holeCx, holeCy] =
|
|
644
|
+
const [holeCx, holeCy] = applyToPoint5(transform, [
|
|
482
645
|
h.x + (h.hole_offset_x ?? 0),
|
|
483
646
|
h.y + (h.hole_offset_y ?? 0)
|
|
484
647
|
]);
|
|
@@ -543,7 +706,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
543
706
|
const pillHoleWithOffsets = pillHole;
|
|
544
707
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
545
708
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
546
|
-
const [holeCenterX, holeCenterY] =
|
|
709
|
+
const [holeCenterX, holeCenterY] = applyToPoint5(transform, [
|
|
547
710
|
pillHole.x + holeOffsetX,
|
|
548
711
|
pillHole.y + holeOffsetY
|
|
549
712
|
]);
|
|
@@ -612,7 +775,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
612
775
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
613
776
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
614
777
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
615
|
-
const [holeCenterX, holeCenterY] =
|
|
778
|
+
const [holeCenterX, holeCenterY] = applyToPoint5(transform, [
|
|
616
779
|
rotatedHole.x + holeOffsetX,
|
|
617
780
|
rotatedHole.y + holeOffsetY
|
|
618
781
|
]);
|
|
@@ -675,12 +838,12 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
|
|
|
675
838
|
}
|
|
676
839
|
|
|
677
840
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-path.ts
|
|
678
|
-
import { applyToPoint as
|
|
841
|
+
import { applyToPoint as applyToPoint6 } from "transformation-matrix";
|
|
679
842
|
function createSvgObjectsFromPcbSilkscreenPath(silkscreenPath, ctx) {
|
|
680
843
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
681
844
|
if (!silkscreenPath.route || !Array.isArray(silkscreenPath.route)) return [];
|
|
682
845
|
let path = silkscreenPath.route.map((point, index) => {
|
|
683
|
-
const [x, y] =
|
|
846
|
+
const [x, y] = applyToPoint6(transform, [point.x, point.y]);
|
|
684
847
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
685
848
|
}).join(" ");
|
|
686
849
|
const firstPoint = silkscreenPath.route[0];
|
|
@@ -716,7 +879,7 @@ function createSvgObjectsFromPcbSilkscreenPath(silkscreenPath, ctx) {
|
|
|
716
879
|
|
|
717
880
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-text.ts
|
|
718
881
|
import {
|
|
719
|
-
applyToPoint as
|
|
882
|
+
applyToPoint as applyToPoint7,
|
|
720
883
|
compose as compose2,
|
|
721
884
|
rotate as rotate2,
|
|
722
885
|
translate as translate2,
|
|
@@ -738,7 +901,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
738
901
|
console.error("Invalid anchor_position:", anchor_position);
|
|
739
902
|
return [];
|
|
740
903
|
}
|
|
741
|
-
const [transformedX, transformedY] =
|
|
904
|
+
const [transformedX, transformedY] = applyToPoint7(transform, [
|
|
742
905
|
anchor_position.x,
|
|
743
906
|
anchor_position.y
|
|
744
907
|
]);
|
|
@@ -846,7 +1009,7 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
|
846
1009
|
}
|
|
847
1010
|
|
|
848
1011
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-rect.ts
|
|
849
|
-
import { applyToPoint as
|
|
1012
|
+
import { applyToPoint as applyToPoint8 } from "transformation-matrix";
|
|
850
1013
|
function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
|
|
851
1014
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
852
1015
|
const {
|
|
@@ -865,7 +1028,7 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
|
|
|
865
1028
|
console.error("Invalid rectangle data:", { center, width, height });
|
|
866
1029
|
return [];
|
|
867
1030
|
}
|
|
868
|
-
const [transformedX, transformedY] =
|
|
1031
|
+
const [transformedX, transformedY] = applyToPoint8(transform, [
|
|
869
1032
|
center.x,
|
|
870
1033
|
center.y
|
|
871
1034
|
]);
|
|
@@ -912,7 +1075,7 @@ function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, ctx) {
|
|
|
912
1075
|
}
|
|
913
1076
|
|
|
914
1077
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-circle.ts
|
|
915
|
-
import { applyToPoint as
|
|
1078
|
+
import { applyToPoint as applyToPoint9 } from "transformation-matrix";
|
|
916
1079
|
function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
917
1080
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
918
1081
|
const {
|
|
@@ -927,7 +1090,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
|
927
1090
|
console.error("Invalid PCB Silkscreen Circle data:", { center, radius });
|
|
928
1091
|
return [];
|
|
929
1092
|
}
|
|
930
|
-
const [transformedX, transformedY] =
|
|
1093
|
+
const [transformedX, transformedY] = applyToPoint9(transform, [
|
|
931
1094
|
center.x,
|
|
932
1095
|
center.y
|
|
933
1096
|
]);
|
|
@@ -955,7 +1118,7 @@ function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, ctx) {
|
|
|
955
1118
|
}
|
|
956
1119
|
|
|
957
1120
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-line.ts
|
|
958
|
-
import { applyToPoint as
|
|
1121
|
+
import { applyToPoint as applyToPoint10 } from "transformation-matrix";
|
|
959
1122
|
function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
|
|
960
1123
|
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
961
1124
|
const {
|
|
@@ -972,8 +1135,8 @@ function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, ctx) {
|
|
|
972
1135
|
console.error("Invalid coordinates:", { x1, y1, x2, y2 });
|
|
973
1136
|
return [];
|
|
974
1137
|
}
|
|
975
|
-
const [transformedX1, transformedY1] =
|
|
976
|
-
const [transformedX2, transformedY2] =
|
|
1138
|
+
const [transformedX1, transformedY1] = applyToPoint10(transform, [x1, y1]);
|
|
1139
|
+
const [transformedX2, transformedY2] = applyToPoint10(transform, [x2, y2]);
|
|
977
1140
|
const transformedStrokeWidth = stroke_width * Math.abs(transform.a);
|
|
978
1141
|
const color = layer === "bottom" ? colorMap2.silkscreen.bottom : colorMap2.silkscreen.top;
|
|
979
1142
|
return [
|
|
@@ -1008,7 +1171,7 @@ function pairs(arr) {
|
|
|
1008
1171
|
}
|
|
1009
1172
|
|
|
1010
1173
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace.ts
|
|
1011
|
-
import { applyToPoint as
|
|
1174
|
+
import { applyToPoint as applyToPoint11 } from "transformation-matrix";
|
|
1012
1175
|
|
|
1013
1176
|
// lib/pcb/colors.ts
|
|
1014
1177
|
var DEFAULT_PCB_COLOR_MAP = {
|
|
@@ -1064,8 +1227,8 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
|
1064
1227
|
const segments = pairs(trace.route);
|
|
1065
1228
|
const svgObjects = [];
|
|
1066
1229
|
for (const [start, end] of segments) {
|
|
1067
|
-
const startPoint =
|
|
1068
|
-
const endPoint =
|
|
1230
|
+
const startPoint = applyToPoint11(transform, [start.x, start.y]);
|
|
1231
|
+
const endPoint = applyToPoint11(transform, [end.x, end.y]);
|
|
1069
1232
|
const layer = "layer" in start ? start.layer : "layer" in end ? end.layer : null;
|
|
1070
1233
|
if (!layer) continue;
|
|
1071
1234
|
if (layerFilter && layer !== layerFilter) continue;
|
|
@@ -1137,7 +1300,7 @@ function createSvgObjectsFromPcbTrace(trace, ctx) {
|
|
|
1137
1300
|
}
|
|
1138
1301
|
|
|
1139
1302
|
// lib/pcb/svg-object-fns/create-svg-objects-from-smt-pads.ts
|
|
1140
|
-
import { applyToPoint as
|
|
1303
|
+
import { applyToPoint as applyToPoint12 } from "transformation-matrix";
|
|
1141
1304
|
function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
1142
1305
|
const { transform, layer: layerFilter, colorMap: colorMap2, renderSolderMask } = ctx;
|
|
1143
1306
|
if (layerFilter && pad.layer !== layerFilter) return [];
|
|
@@ -1147,7 +1310,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1147
1310
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
1148
1311
|
const width = pad.width * Math.abs(transform.a);
|
|
1149
1312
|
const height = pad.height * Math.abs(transform.d);
|
|
1150
|
-
const [x, y] =
|
|
1313
|
+
const [x, y] = applyToPoint12(transform, [pad.x, pad.y]);
|
|
1151
1314
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
1152
1315
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
1153
1316
|
const padElement2 = {
|
|
@@ -1229,7 +1392,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1229
1392
|
const width = pad.width * Math.abs(transform.a);
|
|
1230
1393
|
const height = pad.height * Math.abs(transform.d);
|
|
1231
1394
|
const radius = pad.radius * Math.abs(transform.a);
|
|
1232
|
-
const [x, y] =
|
|
1395
|
+
const [x, y] = applyToPoint12(transform, [pad.x, pad.y]);
|
|
1233
1396
|
const padElement = {
|
|
1234
1397
|
name: "rect",
|
|
1235
1398
|
type: "element",
|
|
@@ -1267,7 +1430,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1267
1430
|
}
|
|
1268
1431
|
if (pad.shape === "circle") {
|
|
1269
1432
|
const radius = pad.radius * Math.abs(transform.a);
|
|
1270
|
-
const [x, y] =
|
|
1433
|
+
const [x, y] = applyToPoint12(transform, [pad.x, pad.y]);
|
|
1271
1434
|
const padElement = {
|
|
1272
1435
|
name: "circle",
|
|
1273
1436
|
type: "element",
|
|
@@ -1302,7 +1465,7 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1302
1465
|
}
|
|
1303
1466
|
if (pad.shape === "polygon") {
|
|
1304
1467
|
const points = (pad.points ?? []).map(
|
|
1305
|
-
(point) =>
|
|
1468
|
+
(point) => applyToPoint12(transform, [point.x, point.y])
|
|
1306
1469
|
);
|
|
1307
1470
|
const padElement = {
|
|
1308
1471
|
name: "polygon",
|
|
@@ -1338,32 +1501,32 @@ function createSvgObjectsFromSmtPad(pad, ctx) {
|
|
|
1338
1501
|
}
|
|
1339
1502
|
|
|
1340
1503
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-board.ts
|
|
1341
|
-
import { applyToPoint as
|
|
1504
|
+
import { applyToPoint as applyToPoint13 } from "transformation-matrix";
|
|
1342
1505
|
function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
1343
1506
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
1344
1507
|
const { width, height, center, outline } = pcbBoard;
|
|
1345
1508
|
let path;
|
|
1346
1509
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
1347
1510
|
path = outline.map((point, index) => {
|
|
1348
|
-
const [x, y] =
|
|
1511
|
+
const [x, y] = applyToPoint13(transform, [point.x, point.y]);
|
|
1349
1512
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
1350
1513
|
}).join(" ");
|
|
1351
1514
|
} else {
|
|
1352
1515
|
const halfWidth = width / 2;
|
|
1353
1516
|
const halfHeight = height / 2;
|
|
1354
|
-
const topLeft =
|
|
1517
|
+
const topLeft = applyToPoint13(transform, [
|
|
1355
1518
|
center.x - halfWidth,
|
|
1356
1519
|
center.y - halfHeight
|
|
1357
1520
|
]);
|
|
1358
|
-
const topRight =
|
|
1521
|
+
const topRight = applyToPoint13(transform, [
|
|
1359
1522
|
center.x + halfWidth,
|
|
1360
1523
|
center.y - halfHeight
|
|
1361
1524
|
]);
|
|
1362
|
-
const bottomRight =
|
|
1525
|
+
const bottomRight = applyToPoint13(transform, [
|
|
1363
1526
|
center.x + halfWidth,
|
|
1364
1527
|
center.y + halfHeight
|
|
1365
1528
|
]);
|
|
1366
|
-
const bottomLeft =
|
|
1529
|
+
const bottomLeft = applyToPoint13(transform, [
|
|
1367
1530
|
center.x - halfWidth,
|
|
1368
1531
|
center.y + halfHeight
|
|
1369
1532
|
]);
|
|
@@ -1390,10 +1553,10 @@ function createSvgObjectsFromPcbBoard(pcbBoard, ctx) {
|
|
|
1390
1553
|
}
|
|
1391
1554
|
|
|
1392
1555
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-via.ts
|
|
1393
|
-
import { applyToPoint as
|
|
1556
|
+
import { applyToPoint as applyToPoint14 } from "transformation-matrix";
|
|
1394
1557
|
function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
1395
1558
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
1396
|
-
const [x, y] =
|
|
1559
|
+
const [x, y] = applyToPoint14(transform, [hole.x, hole.y]);
|
|
1397
1560
|
const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a);
|
|
1398
1561
|
const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a);
|
|
1399
1562
|
const scaledHoleWidth = hole.hole_diameter * Math.abs(transform.a);
|
|
@@ -1439,10 +1602,10 @@ function createSvgObjectsFromPcbVia(hole, ctx) {
|
|
|
1439
1602
|
}
|
|
1440
1603
|
|
|
1441
1604
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-hole.ts
|
|
1442
|
-
import { applyToPoint as
|
|
1605
|
+
import { applyToPoint as applyToPoint15 } from "transformation-matrix";
|
|
1443
1606
|
function createSvgObjectsFromPcbHole(hole, ctx) {
|
|
1444
1607
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
1445
|
-
const [x, y] =
|
|
1608
|
+
const [x, y] = applyToPoint15(transform, [hole.x, hole.y]);
|
|
1446
1609
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
1447
1610
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
1448
1611
|
const radius = scaledDiameter / 2;
|
|
@@ -1516,7 +1679,7 @@ import {
|
|
|
1516
1679
|
getFullConnectivityMapFromCircuitJson
|
|
1517
1680
|
} from "circuit-json-to-connectivity-map";
|
|
1518
1681
|
import "svgson";
|
|
1519
|
-
import { applyToPoint as
|
|
1682
|
+
import { applyToPoint as applyToPoint16 } from "transformation-matrix";
|
|
1520
1683
|
|
|
1521
1684
|
// lib/pcb/create-svg-objects-from-pcb-rats-nest/get-element-position.ts
|
|
1522
1685
|
import { su } from "@tscircuit/circuit-json-util";
|
|
@@ -1596,11 +1759,11 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
1596
1759
|
});
|
|
1597
1760
|
const svgObjects = [];
|
|
1598
1761
|
for (const line of ratsNestLines) {
|
|
1599
|
-
const transformedStart =
|
|
1762
|
+
const transformedStart = applyToPoint16(transform, [
|
|
1600
1763
|
line.startPoint.x,
|
|
1601
1764
|
line.startPoint.y
|
|
1602
1765
|
]);
|
|
1603
|
-
const transformedEnd =
|
|
1766
|
+
const transformedEnd = applyToPoint16(transform, [
|
|
1604
1767
|
line.endPoint.x,
|
|
1605
1768
|
line.endPoint.y
|
|
1606
1769
|
]);
|
|
@@ -1628,7 +1791,7 @@ function createSvgObjectsForRatsNest(circuitJson, ctx) {
|
|
|
1628
1791
|
|
|
1629
1792
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-cutout.ts
|
|
1630
1793
|
import {
|
|
1631
|
-
applyToPoint as
|
|
1794
|
+
applyToPoint as applyToPoint17,
|
|
1632
1795
|
compose as compose3,
|
|
1633
1796
|
rotate as rotate3,
|
|
1634
1797
|
translate as translate3,
|
|
@@ -1638,7 +1801,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
1638
1801
|
const { transform, colorMap: colorMap2 } = ctx;
|
|
1639
1802
|
if (cutout.shape === "rect") {
|
|
1640
1803
|
const rectCutout = cutout;
|
|
1641
|
-
const [cx, cy] =
|
|
1804
|
+
const [cx, cy] = applyToPoint17(transform, [
|
|
1642
1805
|
rectCutout.center.x,
|
|
1643
1806
|
rectCutout.center.y
|
|
1644
1807
|
]);
|
|
@@ -1669,7 +1832,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
1669
1832
|
}
|
|
1670
1833
|
if (cutout.shape === "circle") {
|
|
1671
1834
|
const circleCutout = cutout;
|
|
1672
|
-
const [cx, cy] =
|
|
1835
|
+
const [cx, cy] = applyToPoint17(transform, [
|
|
1673
1836
|
circleCutout.center.x,
|
|
1674
1837
|
circleCutout.center.y
|
|
1675
1838
|
]);
|
|
@@ -1696,7 +1859,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
1696
1859
|
const polygonCutout = cutout;
|
|
1697
1860
|
if (!polygonCutout.points || polygonCutout.points.length === 0) return [];
|
|
1698
1861
|
const transformedPoints = polygonCutout.points.map(
|
|
1699
|
-
(p) =>
|
|
1862
|
+
(p) => applyToPoint17(transform, [p.x, p.y])
|
|
1700
1863
|
);
|
|
1701
1864
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
1702
1865
|
return [
|
|
@@ -1720,7 +1883,7 @@ function createSvgObjectsFromPcbCutout(cutout, ctx) {
|
|
|
1720
1883
|
|
|
1721
1884
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-copper-pour.ts
|
|
1722
1885
|
import {
|
|
1723
|
-
applyToPoint as
|
|
1886
|
+
applyToPoint as applyToPoint19,
|
|
1724
1887
|
compose as compose4,
|
|
1725
1888
|
rotate as rotate4,
|
|
1726
1889
|
toString as matrixToString7,
|
|
@@ -1728,11 +1891,11 @@ import {
|
|
|
1728
1891
|
} from "transformation-matrix";
|
|
1729
1892
|
|
|
1730
1893
|
// lib/utils/ring-to-path-d.ts
|
|
1731
|
-
import { applyToPoint as
|
|
1894
|
+
import { applyToPoint as applyToPoint18 } from "transformation-matrix";
|
|
1732
1895
|
function ringToPathD(vertices, transform) {
|
|
1733
1896
|
if (vertices.length === 0) return "";
|
|
1734
1897
|
const transformedVertices = vertices.map((v) => {
|
|
1735
|
-
const [x, y] =
|
|
1898
|
+
const [x, y] = applyToPoint18(transform, [v.x, v.y]);
|
|
1736
1899
|
return { ...v, x, y };
|
|
1737
1900
|
});
|
|
1738
1901
|
let d = `M ${transformedVertices[0].x} ${transformedVertices[0].y}`;
|
|
@@ -1765,7 +1928,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
1765
1928
|
const color = layerNameToColor(layer, colorMap2);
|
|
1766
1929
|
const opacity = "0.5";
|
|
1767
1930
|
if (pour.shape === "rect") {
|
|
1768
|
-
const [cx, cy] =
|
|
1931
|
+
const [cx, cy] = applyToPoint19(transform, [pour.center.x, pour.center.y]);
|
|
1769
1932
|
const scaledWidth = pour.width * Math.abs(transform.a);
|
|
1770
1933
|
const scaledHeight = pour.height * Math.abs(transform.d);
|
|
1771
1934
|
const svgRotation = -(pour.rotation ?? 0);
|
|
@@ -1795,7 +1958,7 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
1795
1958
|
if (pour.shape === "polygon") {
|
|
1796
1959
|
if (!pour.points || pour.points.length === 0) return [];
|
|
1797
1960
|
const transformedPoints = pour.points.map(
|
|
1798
|
-
(p) =>
|
|
1961
|
+
(p) => applyToPoint19(transform, [p.x, p.y])
|
|
1799
1962
|
);
|
|
1800
1963
|
const pointsString = transformedPoints.map((p) => `${p[0]},${p[1]}`).join(" ");
|
|
1801
1964
|
return [
|
|
@@ -1842,12 +2005,149 @@ function createSvgObjectsFromPcbCopperPour(pour, ctx) {
|
|
|
1842
2005
|
return [];
|
|
1843
2006
|
}
|
|
1844
2007
|
|
|
2008
|
+
// lib/pcb/svg-object-fns/create-svg-objects-for-pcb-grid.ts
|
|
2009
|
+
import "svgson";
|
|
2010
|
+
var DEFAULT_GRID_LINE_COLOR = "rgba(255, 255, 255, 0.5)";
|
|
2011
|
+
var GRID_PATTERN_ID = "pcb-grid-pattern";
|
|
2012
|
+
function createSvgObjectsForPcbGrid({
|
|
2013
|
+
grid,
|
|
2014
|
+
svgWidth,
|
|
2015
|
+
svgHeight
|
|
2016
|
+
}) {
|
|
2017
|
+
if (!grid) {
|
|
2018
|
+
return {};
|
|
2019
|
+
}
|
|
2020
|
+
const gridLineColor = grid.lineColor ?? DEFAULT_GRID_LINE_COLOR;
|
|
2021
|
+
const gridCellSize = grid.cellSize;
|
|
2022
|
+
const majorCellSize = grid.majorCellSize;
|
|
2023
|
+
const majorLineColor = grid.majorLineColor ?? gridLineColor;
|
|
2024
|
+
if (majorCellSize !== void 0) {
|
|
2025
|
+
if (!gridCellSize || gridCellSize <= 0) {
|
|
2026
|
+
throw new Error("grid.majorCellSize requires a positive grid.cellSize");
|
|
2027
|
+
}
|
|
2028
|
+
if (majorCellSize <= 0) {
|
|
2029
|
+
throw new Error(
|
|
2030
|
+
"grid.majorCellSize must be a positive multiple of grid.cellSize"
|
|
2031
|
+
);
|
|
2032
|
+
}
|
|
2033
|
+
const ratio = majorCellSize / gridCellSize;
|
|
2034
|
+
const nearestInteger = Math.round(ratio);
|
|
2035
|
+
if (!Number.isFinite(ratio) || Math.abs(ratio - nearestInteger) > 1e-6) {
|
|
2036
|
+
throw new Error(
|
|
2037
|
+
"grid.majorCellSize must be a positive multiple of grid.cellSize"
|
|
2038
|
+
);
|
|
2039
|
+
}
|
|
2040
|
+
}
|
|
2041
|
+
if (!gridCellSize || gridCellSize <= 0) {
|
|
2042
|
+
return {};
|
|
2043
|
+
}
|
|
2044
|
+
const hasMajorGrid = majorCellSize !== void 0;
|
|
2045
|
+
const patternChildren = hasMajorGrid ? createMajorGridPatternChildren(
|
|
2046
|
+
gridCellSize,
|
|
2047
|
+
majorCellSize,
|
|
2048
|
+
gridLineColor,
|
|
2049
|
+
majorLineColor
|
|
2050
|
+
) : [
|
|
2051
|
+
{
|
|
2052
|
+
name: "path",
|
|
2053
|
+
type: "element",
|
|
2054
|
+
value: "",
|
|
2055
|
+
attributes: {
|
|
2056
|
+
d: `M ${gridCellSize} 0 L 0 0 0 ${gridCellSize}`,
|
|
2057
|
+
fill: "none",
|
|
2058
|
+
stroke: gridLineColor,
|
|
2059
|
+
"stroke-width": "1",
|
|
2060
|
+
"shape-rendering": "crispEdges"
|
|
2061
|
+
},
|
|
2062
|
+
children: []
|
|
2063
|
+
}
|
|
2064
|
+
];
|
|
2065
|
+
const defs = {
|
|
2066
|
+
name: "defs",
|
|
2067
|
+
type: "element",
|
|
2068
|
+
value: "",
|
|
2069
|
+
attributes: {},
|
|
2070
|
+
children: [
|
|
2071
|
+
{
|
|
2072
|
+
name: "pattern",
|
|
2073
|
+
type: "element",
|
|
2074
|
+
value: "",
|
|
2075
|
+
attributes: {
|
|
2076
|
+
id: GRID_PATTERN_ID,
|
|
2077
|
+
width: hasMajorGrid ? majorCellSize.toString() : gridCellSize.toString(),
|
|
2078
|
+
height: hasMajorGrid ? majorCellSize.toString() : gridCellSize.toString(),
|
|
2079
|
+
patternUnits: "userSpaceOnUse"
|
|
2080
|
+
},
|
|
2081
|
+
children: patternChildren
|
|
2082
|
+
}
|
|
2083
|
+
]
|
|
2084
|
+
};
|
|
2085
|
+
const rect = {
|
|
2086
|
+
name: "rect",
|
|
2087
|
+
type: "element",
|
|
2088
|
+
value: "",
|
|
2089
|
+
attributes: {
|
|
2090
|
+
x: "0",
|
|
2091
|
+
y: "0",
|
|
2092
|
+
width: svgWidth.toString(),
|
|
2093
|
+
height: svgHeight.toString(),
|
|
2094
|
+
fill: `url(#${GRID_PATTERN_ID})`,
|
|
2095
|
+
"pointer-events": "none",
|
|
2096
|
+
"data-type": "pcb_grid",
|
|
2097
|
+
"data-pcb-layer": "global"
|
|
2098
|
+
},
|
|
2099
|
+
children: []
|
|
2100
|
+
};
|
|
2101
|
+
return { defs, rect };
|
|
2102
|
+
}
|
|
2103
|
+
function createMajorGridPatternChildren(cellSize, majorCellSize, lineColor, majorLineColor) {
|
|
2104
|
+
const children = [];
|
|
2105
|
+
const steps = Math.round(majorCellSize / cellSize);
|
|
2106
|
+
for (let step = 0; step < steps; step += 1) {
|
|
2107
|
+
const offset = Number((step * cellSize).toFixed(6));
|
|
2108
|
+
const offsetString = offset.toString();
|
|
2109
|
+
const color = step === 0 ? majorLineColor : lineColor;
|
|
2110
|
+
const majorSizeString = majorCellSize.toString();
|
|
2111
|
+
children.push({
|
|
2112
|
+
name: "line",
|
|
2113
|
+
type: "element",
|
|
2114
|
+
value: "",
|
|
2115
|
+
attributes: {
|
|
2116
|
+
x1: offsetString,
|
|
2117
|
+
y1: "0",
|
|
2118
|
+
x2: offsetString,
|
|
2119
|
+
y2: majorSizeString,
|
|
2120
|
+
stroke: color,
|
|
2121
|
+
"stroke-width": "1",
|
|
2122
|
+
"shape-rendering": "crispEdges"
|
|
2123
|
+
},
|
|
2124
|
+
children: []
|
|
2125
|
+
});
|
|
2126
|
+
children.push({
|
|
2127
|
+
name: "line",
|
|
2128
|
+
type: "element",
|
|
2129
|
+
value: "",
|
|
2130
|
+
attributes: {
|
|
2131
|
+
x1: "0",
|
|
2132
|
+
y1: offsetString,
|
|
2133
|
+
x2: majorSizeString,
|
|
2134
|
+
y2: offsetString,
|
|
2135
|
+
stroke: color,
|
|
2136
|
+
"stroke-width": "1",
|
|
2137
|
+
"shape-rendering": "crispEdges"
|
|
2138
|
+
},
|
|
2139
|
+
children: []
|
|
2140
|
+
});
|
|
2141
|
+
}
|
|
2142
|
+
return children;
|
|
2143
|
+
}
|
|
2144
|
+
|
|
1845
2145
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-component.ts
|
|
1846
|
-
import { applyToPoint as
|
|
2146
|
+
import { applyToPoint as applyToPoint20 } from "transformation-matrix";
|
|
1847
2147
|
function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
1848
2148
|
const { transform } = ctx;
|
|
1849
2149
|
const { center, width, height, rotation = 0 } = component;
|
|
1850
|
-
const [x, y] =
|
|
2150
|
+
const [x, y] = applyToPoint20(transform, [center.x, center.y]);
|
|
1851
2151
|
const scaledWidth = width * Math.abs(transform.a);
|
|
1852
2152
|
const scaledHeight = height * Math.abs(transform.d);
|
|
1853
2153
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
@@ -1897,7 +2197,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
1897
2197
|
var package_default = {
|
|
1898
2198
|
name: "circuit-to-svg",
|
|
1899
2199
|
type: "module",
|
|
1900
|
-
version: "0.0.
|
|
2200
|
+
version: "0.0.229",
|
|
1901
2201
|
description: "Convert Circuit JSON to SVG",
|
|
1902
2202
|
main: "dist/index.js",
|
|
1903
2203
|
files: [
|
|
@@ -2176,30 +2476,41 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
2176
2476
|
children: []
|
|
2177
2477
|
}
|
|
2178
2478
|
]
|
|
2179
|
-
},
|
|
2180
|
-
{
|
|
2181
|
-
name: "rect",
|
|
2182
|
-
type: "element",
|
|
2183
|
-
value: "",
|
|
2184
|
-
attributes: {
|
|
2185
|
-
class: "boundary",
|
|
2186
|
-
x: "0",
|
|
2187
|
-
y: "0",
|
|
2188
|
-
fill: options?.backgroundColor ?? "#000",
|
|
2189
|
-
width: svgWidth.toString(),
|
|
2190
|
-
height: svgHeight.toString(),
|
|
2191
|
-
"data-type": "pcb_background",
|
|
2192
|
-
"data-pcb-layer": "global"
|
|
2193
|
-
},
|
|
2194
|
-
children: []
|
|
2195
2479
|
}
|
|
2196
2480
|
];
|
|
2481
|
+
const gridObjects = createSvgObjectsForPcbGrid({
|
|
2482
|
+
grid: options?.grid,
|
|
2483
|
+
svgWidth,
|
|
2484
|
+
svgHeight
|
|
2485
|
+
});
|
|
2486
|
+
if (gridObjects.defs) {
|
|
2487
|
+
children.push(gridObjects.defs);
|
|
2488
|
+
}
|
|
2489
|
+
children.push({
|
|
2490
|
+
name: "rect",
|
|
2491
|
+
type: "element",
|
|
2492
|
+
value: "",
|
|
2493
|
+
attributes: {
|
|
2494
|
+
class: "boundary",
|
|
2495
|
+
x: "0",
|
|
2496
|
+
y: "0",
|
|
2497
|
+
fill: options?.backgroundColor ?? "#000",
|
|
2498
|
+
width: svgWidth.toString(),
|
|
2499
|
+
height: svgHeight.toString(),
|
|
2500
|
+
"data-type": "pcb_background",
|
|
2501
|
+
"data-pcb-layer": "global"
|
|
2502
|
+
},
|
|
2503
|
+
children: []
|
|
2504
|
+
});
|
|
2197
2505
|
if (drawPaddingOutsideBoard) {
|
|
2198
2506
|
children.push(
|
|
2199
2507
|
createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY)
|
|
2200
2508
|
);
|
|
2201
2509
|
}
|
|
2202
2510
|
children.push(...svgObjects);
|
|
2511
|
+
if (gridObjects.rect) {
|
|
2512
|
+
children.push(gridObjects.rect);
|
|
2513
|
+
}
|
|
2203
2514
|
const softwareUsedString = getSoftwareUsedString(circuitJson);
|
|
2204
2515
|
const version = CIRCUIT_TO_SVG_VERSION;
|
|
2205
2516
|
const svgObject = {
|
|
@@ -2299,6 +2610,12 @@ function createSvgObjects({
|
|
|
2299
2610
|
return createSvgObjectsFromPcbTraceError(elm, circuitJson, ctx).filter(
|
|
2300
2611
|
Boolean
|
|
2301
2612
|
);
|
|
2613
|
+
case "pcb_footprint_overlap_error":
|
|
2614
|
+
return createSvgObjectsFromPcbFootprintOverlapError(
|
|
2615
|
+
elm,
|
|
2616
|
+
circuitJson,
|
|
2617
|
+
ctx
|
|
2618
|
+
).filter(Boolean);
|
|
2302
2619
|
case "pcb_component":
|
|
2303
2620
|
return createSvgObjectsFromPcbComponent(elm, ctx).filter(Boolean);
|
|
2304
2621
|
case "pcb_trace":
|
|
@@ -2336,8 +2653,8 @@ function createSvgObjects({
|
|
|
2336
2653
|
}
|
|
2337
2654
|
}
|
|
2338
2655
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
2339
|
-
const [x1, y1] =
|
|
2340
|
-
const [x2, y2] =
|
|
2656
|
+
const [x1, y1] = applyToPoint21(transform, [minX, minY]);
|
|
2657
|
+
const [x2, y2] = applyToPoint21(transform, [maxX, maxY]);
|
|
2341
2658
|
const width = Math.abs(x2 - x1);
|
|
2342
2659
|
const height = Math.abs(y2 - y1);
|
|
2343
2660
|
const x = Math.min(x1, x2);
|
|
@@ -2367,14 +2684,14 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
2367
2684
|
import { stringify as stringify2 } from "svgson";
|
|
2368
2685
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
2369
2686
|
import {
|
|
2370
|
-
applyToPoint as
|
|
2687
|
+
applyToPoint as applyToPoint28,
|
|
2371
2688
|
compose as compose6,
|
|
2372
2689
|
scale as scale3,
|
|
2373
2690
|
translate as translate6
|
|
2374
2691
|
} from "transformation-matrix";
|
|
2375
2692
|
|
|
2376
2693
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
2377
|
-
import { applyToPoint as
|
|
2694
|
+
import { applyToPoint as applyToPoint22 } from "transformation-matrix";
|
|
2378
2695
|
var DEFAULT_BOARD_STYLE = {
|
|
2379
2696
|
fill: "none",
|
|
2380
2697
|
stroke: "rgb(0,0,0)",
|
|
@@ -2386,25 +2703,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
2386
2703
|
let path;
|
|
2387
2704
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
2388
2705
|
path = outline.map((point, index) => {
|
|
2389
|
-
const [x, y] =
|
|
2706
|
+
const [x, y] = applyToPoint22(transform, [point.x, point.y]);
|
|
2390
2707
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
2391
2708
|
}).join(" ");
|
|
2392
2709
|
} else {
|
|
2393
2710
|
const halfWidth = width / 2;
|
|
2394
2711
|
const halfHeight = height / 2;
|
|
2395
|
-
const topLeft =
|
|
2712
|
+
const topLeft = applyToPoint22(transform, [
|
|
2396
2713
|
center.x - halfWidth,
|
|
2397
2714
|
center.y - halfHeight
|
|
2398
2715
|
]);
|
|
2399
|
-
const topRight =
|
|
2716
|
+
const topRight = applyToPoint22(transform, [
|
|
2400
2717
|
center.x + halfWidth,
|
|
2401
2718
|
center.y - halfHeight
|
|
2402
2719
|
]);
|
|
2403
|
-
const bottomRight =
|
|
2720
|
+
const bottomRight = applyToPoint22(transform, [
|
|
2404
2721
|
center.x + halfWidth,
|
|
2405
2722
|
center.y + halfHeight
|
|
2406
2723
|
]);
|
|
2407
|
-
const bottomLeft =
|
|
2724
|
+
const bottomLeft = applyToPoint22(transform, [
|
|
2408
2725
|
center.x - halfWidth,
|
|
2409
2726
|
center.y + halfHeight
|
|
2410
2727
|
]);
|
|
@@ -2430,7 +2747,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
2430
2747
|
}
|
|
2431
2748
|
|
|
2432
2749
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
2433
|
-
import { applyToPoint as
|
|
2750
|
+
import { applyToPoint as applyToPoint24 } from "transformation-matrix";
|
|
2434
2751
|
|
|
2435
2752
|
// lib/utils/get-sch-font-size.ts
|
|
2436
2753
|
import "transformation-matrix";
|
|
@@ -2456,8 +2773,8 @@ function createSvgObjectsFromAssemblyComponent(params, ctx) {
|
|
|
2456
2773
|
const { center, width, height, rotation = 0, layer = "top" } = elm;
|
|
2457
2774
|
if (!center || typeof width !== "number" || typeof height !== "number")
|
|
2458
2775
|
return null;
|
|
2459
|
-
const [x, y] =
|
|
2460
|
-
const [pinX, pinY] =
|
|
2776
|
+
const [x, y] = applyToPoint24(transform, [center.x, center.y]);
|
|
2777
|
+
const [pinX, pinY] = applyToPoint24(transform, [portPosition.x, portPosition.y]);
|
|
2461
2778
|
const scaledWidth = width * Math.abs(transform.a);
|
|
2462
2779
|
const scaledHeight = height * Math.abs(transform.d);
|
|
2463
2780
|
const isTopLayer = layer === "top";
|
|
@@ -2619,11 +2936,11 @@ function getRectPathData(w, h, rotation) {
|
|
|
2619
2936
|
}
|
|
2620
2937
|
|
|
2621
2938
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-hole.ts
|
|
2622
|
-
import { applyToPoint as
|
|
2939
|
+
import { applyToPoint as applyToPoint25 } from "transformation-matrix";
|
|
2623
2940
|
var HOLE_COLOR2 = "rgb(190, 190, 190)";
|
|
2624
2941
|
function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
2625
2942
|
const { transform } = ctx;
|
|
2626
|
-
const [x, y] =
|
|
2943
|
+
const [x, y] = applyToPoint25(transform, [hole.x, hole.y]);
|
|
2627
2944
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
2628
2945
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
2629
2946
|
const radius = scaledDiameter / 2;
|
|
@@ -2687,12 +3004,12 @@ function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
|
2687
3004
|
}
|
|
2688
3005
|
|
|
2689
3006
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-plated-hole.ts
|
|
2690
|
-
import { applyToPoint as
|
|
3007
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
2691
3008
|
var PAD_COLOR = "rgb(210, 210, 210)";
|
|
2692
3009
|
var HOLE_COLOR3 = "rgb(190, 190, 190)";
|
|
2693
3010
|
function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
2694
3011
|
const { transform } = ctx;
|
|
2695
|
-
const [x, y] =
|
|
3012
|
+
const [x, y] = applyToPoint26(transform, [hole.x, hole.y]);
|
|
2696
3013
|
if (hole.shape === "pill") {
|
|
2697
3014
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
2698
3015
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -2787,7 +3104,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
2787
3104
|
const scaledRectPadHeight = circularHole.rect_pad_height * Math.abs(transform.a);
|
|
2788
3105
|
const scaledRectBorderRadius = (circularHole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
2789
3106
|
const holeRadius = scaledHoleDiameter / 2;
|
|
2790
|
-
const [holeCx, holeCy] =
|
|
3107
|
+
const [holeCx, holeCy] = applyToPoint26(transform, [
|
|
2791
3108
|
circularHole.x + circularHole.hole_offset_x,
|
|
2792
3109
|
circularHole.y + circularHole.hole_offset_y
|
|
2793
3110
|
]);
|
|
@@ -2845,7 +3162,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
2845
3162
|
const pillHoleWithOffsets = pillHole;
|
|
2846
3163
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
2847
3164
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
2848
|
-
const [holeCenterX, holeCenterY] =
|
|
3165
|
+
const [holeCenterX, holeCenterY] = applyToPoint26(transform, [
|
|
2849
3166
|
pillHole.x + holeOffsetX,
|
|
2850
3167
|
pillHole.y + holeOffsetY
|
|
2851
3168
|
]);
|
|
@@ -2907,7 +3224,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
2907
3224
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
2908
3225
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
2909
3226
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
2910
|
-
const [holeCenterX, holeCenterY] =
|
|
3227
|
+
const [holeCenterX, holeCenterY] = applyToPoint26(transform, [
|
|
2911
3228
|
rotatedHole.x + holeOffsetX,
|
|
2912
3229
|
rotatedHole.y + holeOffsetY
|
|
2913
3230
|
]);
|
|
@@ -2963,14 +3280,14 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
2963
3280
|
}
|
|
2964
3281
|
|
|
2965
3282
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-smt-pad.ts
|
|
2966
|
-
import { applyToPoint as
|
|
3283
|
+
import { applyToPoint as applyToPoint27 } from "transformation-matrix";
|
|
2967
3284
|
var PAD_COLOR2 = "rgb(210, 210, 210)";
|
|
2968
3285
|
function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
2969
3286
|
const { transform } = ctx;
|
|
2970
3287
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
2971
3288
|
const width = pad.width * Math.abs(transform.a);
|
|
2972
3289
|
const height = pad.height * Math.abs(transform.d);
|
|
2973
|
-
const [x, y] =
|
|
3290
|
+
const [x, y] = applyToPoint27(transform, [pad.x, pad.y]);
|
|
2974
3291
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
2975
3292
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
2976
3293
|
return [
|
|
@@ -3022,7 +3339,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3022
3339
|
const width = pad.width * Math.abs(transform.a);
|
|
3023
3340
|
const height = pad.height * Math.abs(transform.d);
|
|
3024
3341
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3025
|
-
const [x, y] =
|
|
3342
|
+
const [x, y] = applyToPoint27(transform, [pad.x, pad.y]);
|
|
3026
3343
|
return [
|
|
3027
3344
|
{
|
|
3028
3345
|
name: "rect",
|
|
@@ -3045,7 +3362,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3045
3362
|
}
|
|
3046
3363
|
if (pad.shape === "circle") {
|
|
3047
3364
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3048
|
-
const [x, y] =
|
|
3365
|
+
const [x, y] = applyToPoint27(transform, [pad.x, pad.y]);
|
|
3049
3366
|
return [
|
|
3050
3367
|
{
|
|
3051
3368
|
name: "circle",
|
|
@@ -3065,7 +3382,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
3065
3382
|
}
|
|
3066
3383
|
if (pad.shape === "polygon") {
|
|
3067
3384
|
const points = (pad.points ?? []).map(
|
|
3068
|
-
(point) =>
|
|
3385
|
+
(point) => applyToPoint27(transform, [point.x, point.y])
|
|
3069
3386
|
);
|
|
3070
3387
|
return [
|
|
3071
3388
|
{
|
|
@@ -3242,8 +3559,8 @@ function createSvgObjects2(elm, ctx, soup) {
|
|
|
3242
3559
|
}
|
|
3243
3560
|
}
|
|
3244
3561
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
3245
|
-
const [x1, y1] =
|
|
3246
|
-
const [x2, y2] =
|
|
3562
|
+
const [x1, y1] = applyToPoint28(transform, [minX, minY]);
|
|
3563
|
+
const [x2, y2] = applyToPoint28(transform, [maxX, maxY]);
|
|
3247
3564
|
const width = Math.abs(x2 - x1);
|
|
3248
3565
|
const height = Math.abs(y2 - y1);
|
|
3249
3566
|
const x = Math.min(x1, x2);
|
|
@@ -3272,7 +3589,7 @@ import {
|
|
|
3272
3589
|
} from "transformation-matrix";
|
|
3273
3590
|
|
|
3274
3591
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-board.ts
|
|
3275
|
-
import { applyToPoint as
|
|
3592
|
+
import { applyToPoint as applyToPoint29 } from "transformation-matrix";
|
|
3276
3593
|
import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
3277
3594
|
var BOARD_FILL_COLOR = "rgb(26, 115, 143)";
|
|
3278
3595
|
var BOARD_STROKE_COLOR = "rgba(0,0,0,0.9)";
|
|
@@ -3282,25 +3599,25 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
3282
3599
|
let path;
|
|
3283
3600
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
3284
3601
|
path = outline.map((point, index) => {
|
|
3285
|
-
const [x, y] =
|
|
3602
|
+
const [x, y] = applyToPoint29(transform, [point.x, point.y]);
|
|
3286
3603
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
3287
3604
|
}).join(" ");
|
|
3288
3605
|
} else {
|
|
3289
3606
|
const halfWidth = width / 2;
|
|
3290
3607
|
const halfHeight = height / 2;
|
|
3291
|
-
const topLeft =
|
|
3608
|
+
const topLeft = applyToPoint29(transform, [
|
|
3292
3609
|
center.x - halfWidth,
|
|
3293
3610
|
center.y - halfHeight
|
|
3294
3611
|
]);
|
|
3295
|
-
const topRight =
|
|
3612
|
+
const topRight = applyToPoint29(transform, [
|
|
3296
3613
|
center.x + halfWidth,
|
|
3297
3614
|
center.y - halfHeight
|
|
3298
3615
|
]);
|
|
3299
|
-
const bottomRight =
|
|
3616
|
+
const bottomRight = applyToPoint29(transform, [
|
|
3300
3617
|
center.x + halfWidth,
|
|
3301
3618
|
center.y + halfHeight
|
|
3302
3619
|
]);
|
|
3303
|
-
const bottomLeft =
|
|
3620
|
+
const bottomLeft = applyToPoint29(transform, [
|
|
3304
3621
|
center.x - halfWidth,
|
|
3305
3622
|
center.y + halfHeight
|
|
3306
3623
|
]);
|
|
@@ -3318,10 +3635,10 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
3318
3635
|
const halfWidth = width2 / 2;
|
|
3319
3636
|
const halfHeight = height2 / 2;
|
|
3320
3637
|
const [tl, tr, br, bl] = [
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3638
|
+
applyToPoint29(transform, [x - halfWidth, y - halfHeight]),
|
|
3639
|
+
applyToPoint29(transform, [x + halfWidth, y - halfHeight]),
|
|
3640
|
+
applyToPoint29(transform, [x + halfWidth, y + halfHeight]),
|
|
3641
|
+
applyToPoint29(transform, [x - halfWidth, y + halfHeight])
|
|
3325
3642
|
];
|
|
3326
3643
|
path += ` M ${tl[0]} ${tl[1]} L ${tr[0]} ${tr[1]} L ${br[0]} ${br[1]} L ${bl[0]} ${bl[1]} Z`;
|
|
3327
3644
|
} else if (cutout.shape === "circle") {
|
|
@@ -3348,7 +3665,7 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
3348
3665
|
|
|
3349
3666
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-component.ts
|
|
3350
3667
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
3351
|
-
import { applyToPoint as
|
|
3668
|
+
import { applyToPoint as applyToPoint30 } from "transformation-matrix";
|
|
3352
3669
|
var COMPONENT_FILL_COLOR = "rgba(120, 120, 120, 0.6)";
|
|
3353
3670
|
var COMPONENT_LABEL_COLOR = "rgba(255, 255, 255, 0.9)";
|
|
3354
3671
|
function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
@@ -3358,7 +3675,7 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
3358
3675
|
if (!center || typeof width !== "number" || typeof height !== "number" || width === 0 || height === 0) {
|
|
3359
3676
|
return [];
|
|
3360
3677
|
}
|
|
3361
|
-
const [x, y] =
|
|
3678
|
+
const [x, y] = applyToPoint30(transform, [center.x, center.y]);
|
|
3362
3679
|
const scaledWidth = width * Math.abs(transform.a);
|
|
3363
3680
|
const scaledHeight = height * Math.abs(transform.d);
|
|
3364
3681
|
const transformStr = `translate(${x}, ${y})`;
|
|
@@ -3419,11 +3736,11 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
3419
3736
|
}
|
|
3420
3737
|
|
|
3421
3738
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-hole.ts
|
|
3422
|
-
import { applyToPoint as
|
|
3739
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
3423
3740
|
var HOLE_COLOR4 = "rgb(50, 50, 50)";
|
|
3424
3741
|
function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
3425
3742
|
const { transform } = ctx;
|
|
3426
|
-
const [x, y] =
|
|
3743
|
+
const [x, y] = applyToPoint31(transform, [hole.x, hole.y]);
|
|
3427
3744
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
3428
3745
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
3429
3746
|
const radius = scaledDiameter / 2;
|
|
@@ -3487,12 +3804,12 @@ function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
|
3487
3804
|
}
|
|
3488
3805
|
|
|
3489
3806
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-plated-hole.ts
|
|
3490
|
-
import { applyToPoint as
|
|
3807
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
3491
3808
|
var PAD_COLOR3 = "rgb(218, 165, 32)";
|
|
3492
3809
|
var HOLE_COLOR5 = "rgb(40, 40, 40)";
|
|
3493
3810
|
function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
3494
3811
|
const { transform } = ctx;
|
|
3495
|
-
const [x, y] =
|
|
3812
|
+
const [x, y] = applyToPoint32(transform, [hole.x, hole.y]);
|
|
3496
3813
|
if (hole.shape === "pill") {
|
|
3497
3814
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
3498
3815
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -3727,14 +4044,14 @@ function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
|
3727
4044
|
}
|
|
3728
4045
|
|
|
3729
4046
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-smt-pad.ts
|
|
3730
|
-
import { applyToPoint as
|
|
4047
|
+
import { applyToPoint as applyToPoint33 } from "transformation-matrix";
|
|
3731
4048
|
var PAD_COLOR4 = "rgb(218, 165, 32)";
|
|
3732
4049
|
function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
3733
4050
|
const { transform } = ctx;
|
|
3734
4051
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
3735
4052
|
const width = pad.width * Math.abs(transform.a);
|
|
3736
4053
|
const height = pad.height * Math.abs(transform.d);
|
|
3737
|
-
const [x, y] =
|
|
4054
|
+
const [x, y] = applyToPoint33(transform, [pad.x, pad.y]);
|
|
3738
4055
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
3739
4056
|
return [
|
|
3740
4057
|
{
|
|
@@ -3777,7 +4094,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
3777
4094
|
const width = pad.width * Math.abs(transform.a);
|
|
3778
4095
|
const height = pad.height * Math.abs(transform.d);
|
|
3779
4096
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3780
|
-
const [x, y] =
|
|
4097
|
+
const [x, y] = applyToPoint33(transform, [pad.x, pad.y]);
|
|
3781
4098
|
return [
|
|
3782
4099
|
{
|
|
3783
4100
|
name: "rect",
|
|
@@ -3800,7 +4117,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
3800
4117
|
}
|
|
3801
4118
|
if (pad.shape === "circle") {
|
|
3802
4119
|
const radius = pad.radius * Math.abs(transform.a);
|
|
3803
|
-
const [x, y] =
|
|
4120
|
+
const [x, y] = applyToPoint33(transform, [pad.x, pad.y]);
|
|
3804
4121
|
return [
|
|
3805
4122
|
{
|
|
3806
4123
|
name: "circle",
|
|
@@ -3820,7 +4137,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
3820
4137
|
}
|
|
3821
4138
|
if (pad.shape === "polygon") {
|
|
3822
4139
|
const points = (pad.points ?? []).map(
|
|
3823
|
-
(point) =>
|
|
4140
|
+
(point) => applyToPoint33(transform, [point.x, point.y])
|
|
3824
4141
|
);
|
|
3825
4142
|
return [
|
|
3826
4143
|
{
|
|
@@ -3841,7 +4158,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
3841
4158
|
}
|
|
3842
4159
|
|
|
3843
4160
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-port.ts
|
|
3844
|
-
import { applyToPoint as
|
|
4161
|
+
import { applyToPoint as applyToPoint34 } from "transformation-matrix";
|
|
3845
4162
|
import { calculateElbow } from "calculate-elbow";
|
|
3846
4163
|
|
|
3847
4164
|
// lib/pinout/svg-object-fns/pinout-label-box.ts
|
|
@@ -3918,7 +4235,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
3918
4235
|
const label_info = ctx.label_positions.get(pcb_port.pcb_port_id);
|
|
3919
4236
|
if (!label_info) return [];
|
|
3920
4237
|
const { text: label, aliases, elbow_end, label_pos, edge } = label_info;
|
|
3921
|
-
const [port_x, port_y] =
|
|
4238
|
+
const [port_x, port_y] = applyToPoint34(ctx.transform, [pcb_port.x, pcb_port.y]);
|
|
3922
4239
|
const start_facing_direction = edge === "left" ? "x-" : edge === "right" ? "x+" : edge === "top" ? "y-" : "y+";
|
|
3923
4240
|
const end_facing_direction = edge === "left" ? "x+" : edge === "right" ? "x-" : edge === "top" ? "y+" : "y-";
|
|
3924
4241
|
const elbow_path = calculateElbow(
|
|
@@ -4059,7 +4376,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
4059
4376
|
}
|
|
4060
4377
|
|
|
4061
4378
|
// lib/pinout/calculate-label-positions.ts
|
|
4062
|
-
import { applyToPoint as
|
|
4379
|
+
import { applyToPoint as applyToPoint35 } from "transformation-matrix";
|
|
4063
4380
|
|
|
4064
4381
|
// lib/pinout/constants.ts
|
|
4065
4382
|
var LABEL_RECT_HEIGHT_BASE_MM = 1.6;
|
|
@@ -4097,7 +4414,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4097
4414
|
);
|
|
4098
4415
|
const mapToEdgePort = (pinout_label) => ({
|
|
4099
4416
|
pcb_port: pinout_label.pcb_port,
|
|
4100
|
-
y:
|
|
4417
|
+
y: applyToPoint35(transform, [
|
|
4101
4418
|
pinout_label.pcb_port.x,
|
|
4102
4419
|
pinout_label.pcb_port.y
|
|
4103
4420
|
])[1],
|
|
@@ -4112,7 +4429,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4112
4429
|
} else {
|
|
4113
4430
|
edge_ports = pinout_labels.map((pinout_label) => ({
|
|
4114
4431
|
pcb_port: pinout_label.pcb_port,
|
|
4115
|
-
y:
|
|
4432
|
+
y: applyToPoint35(transform, [
|
|
4116
4433
|
pinout_label.pcb_port.x,
|
|
4117
4434
|
pinout_label.pcb_port.y
|
|
4118
4435
|
])[1],
|
|
@@ -4120,7 +4437,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
4120
4437
|
})).sort((a, b) => a.y - b.y);
|
|
4121
4438
|
}
|
|
4122
4439
|
if (edge_ports.length === 0) return;
|
|
4123
|
-
const board_edge_x =
|
|
4440
|
+
const board_edge_x = applyToPoint35(transform, [
|
|
4124
4441
|
edge === "left" ? board_bounds.minX : board_bounds.maxX,
|
|
4125
4442
|
0
|
|
4126
4443
|
])[0];
|
|
@@ -4769,14 +5086,14 @@ import {
|
|
|
4769
5086
|
} from "transformation-matrix";
|
|
4770
5087
|
|
|
4771
5088
|
// lib/sch/draw-schematic-grid.ts
|
|
4772
|
-
import { applyToPoint as
|
|
5089
|
+
import { applyToPoint as applyToPoint36 } from "transformation-matrix";
|
|
4773
5090
|
function drawSchematicGrid(params) {
|
|
4774
5091
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
4775
5092
|
const cellSize = params.cellSize ?? 1;
|
|
4776
5093
|
const labelCells = params.labelCells ?? false;
|
|
4777
5094
|
const gridLines = [];
|
|
4778
5095
|
const transformPoint = (x, y) => {
|
|
4779
|
-
const [transformedX, transformedY] =
|
|
5096
|
+
const [transformedX, transformedY] = applyToPoint36(params.transform, [x, y]);
|
|
4780
5097
|
return { x: transformedX, y: transformedY };
|
|
4781
5098
|
};
|
|
4782
5099
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -4857,15 +5174,15 @@ function drawSchematicGrid(params) {
|
|
|
4857
5174
|
}
|
|
4858
5175
|
|
|
4859
5176
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
4860
|
-
import { applyToPoint as
|
|
5177
|
+
import { applyToPoint as applyToPoint37 } from "transformation-matrix";
|
|
4861
5178
|
function drawSchematicLabeledPoints(params) {
|
|
4862
5179
|
const { points, transform } = params;
|
|
4863
5180
|
const labeledPointsGroup = [];
|
|
4864
5181
|
for (const point of points) {
|
|
4865
|
-
const [x1, y1] =
|
|
4866
|
-
const [x2, y2] =
|
|
4867
|
-
const [x3, y3] =
|
|
4868
|
-
const [x4, y4] =
|
|
5182
|
+
const [x1, y1] = applyToPoint37(transform, [point.x - 0.1, point.y - 0.1]);
|
|
5183
|
+
const [x2, y2] = applyToPoint37(transform, [point.x + 0.1, point.y + 0.1]);
|
|
5184
|
+
const [x3, y3] = applyToPoint37(transform, [point.x - 0.1, point.y + 0.1]);
|
|
5185
|
+
const [x4, y4] = applyToPoint37(transform, [point.x + 0.1, point.y - 0.1]);
|
|
4869
5186
|
labeledPointsGroup.push({
|
|
4870
5187
|
name: "path",
|
|
4871
5188
|
type: "element",
|
|
@@ -4876,7 +5193,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
4876
5193
|
"stroke-opacity": "0.7"
|
|
4877
5194
|
}
|
|
4878
5195
|
});
|
|
4879
|
-
const [labelX, labelY] =
|
|
5196
|
+
const [labelX, labelY] = applyToPoint37(transform, [
|
|
4880
5197
|
point.x + 0.15,
|
|
4881
5198
|
point.y - 0.15
|
|
4882
5199
|
]);
|
|
@@ -5970,7 +6287,7 @@ import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
|
5970
6287
|
import { symbols } from "schematic-symbols";
|
|
5971
6288
|
import "svgson";
|
|
5972
6289
|
import {
|
|
5973
|
-
applyToPoint as
|
|
6290
|
+
applyToPoint as applyToPoint39,
|
|
5974
6291
|
compose as compose9
|
|
5975
6292
|
} from "transformation-matrix";
|
|
5976
6293
|
|
|
@@ -6054,13 +6371,13 @@ function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
|
6054
6371
|
}
|
|
6055
6372
|
|
|
6056
6373
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
6057
|
-
import { applyToPoint as
|
|
6374
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
6058
6375
|
var createSvgSchErrorText = ({
|
|
6059
6376
|
text,
|
|
6060
6377
|
realCenter,
|
|
6061
6378
|
realToScreenTransform
|
|
6062
6379
|
}) => {
|
|
6063
|
-
const screenCenter =
|
|
6380
|
+
const screenCenter = applyToPoint38(realToScreenTransform, realCenter);
|
|
6064
6381
|
return {
|
|
6065
6382
|
type: "element",
|
|
6066
6383
|
name: "text",
|
|
@@ -6169,11 +6486,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6169
6486
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
6170
6487
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
6171
6488
|
};
|
|
6172
|
-
const [screenMinX, screenMinY] =
|
|
6489
|
+
const [screenMinX, screenMinY] = applyToPoint39(
|
|
6173
6490
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6174
6491
|
[bounds.minX, bounds.minY]
|
|
6175
6492
|
);
|
|
6176
|
-
const [screenMaxX, screenMaxY] =
|
|
6493
|
+
const [screenMaxX, screenMaxY] = applyToPoint39(
|
|
6177
6494
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6178
6495
|
[bounds.maxX, bounds.maxY]
|
|
6179
6496
|
);
|
|
@@ -6202,7 +6519,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6202
6519
|
name: "path",
|
|
6203
6520
|
attributes: {
|
|
6204
6521
|
d: points.map((p, i) => {
|
|
6205
|
-
const [x, y] =
|
|
6522
|
+
const [x, y] = applyToPoint39(
|
|
6206
6523
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6207
6524
|
[p.x, p.y]
|
|
6208
6525
|
);
|
|
@@ -6218,7 +6535,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6218
6535
|
});
|
|
6219
6536
|
}
|
|
6220
6537
|
for (const text of texts) {
|
|
6221
|
-
const screenTextPos =
|
|
6538
|
+
const screenTextPos = applyToPoint39(
|
|
6222
6539
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6223
6540
|
text
|
|
6224
6541
|
);
|
|
@@ -6270,7 +6587,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6270
6587
|
});
|
|
6271
6588
|
}
|
|
6272
6589
|
for (const box of boxes) {
|
|
6273
|
-
const screenBoxPos =
|
|
6590
|
+
const screenBoxPos = applyToPoint39(
|
|
6274
6591
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6275
6592
|
box
|
|
6276
6593
|
);
|
|
@@ -6294,7 +6611,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6294
6611
|
}
|
|
6295
6612
|
for (const port of symbol.ports) {
|
|
6296
6613
|
if (connectedSymbolPorts.has(port)) continue;
|
|
6297
|
-
const screenPortPos =
|
|
6614
|
+
const screenPortPos = applyToPoint39(
|
|
6298
6615
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6299
6616
|
port
|
|
6300
6617
|
);
|
|
@@ -6314,7 +6631,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6314
6631
|
});
|
|
6315
6632
|
}
|
|
6316
6633
|
for (const circle of circles) {
|
|
6317
|
-
const screenCirclePos =
|
|
6634
|
+
const screenCirclePos = applyToPoint39(
|
|
6318
6635
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
6319
6636
|
circle
|
|
6320
6637
|
);
|
|
@@ -6341,14 +6658,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
6341
6658
|
import { su as su10 } from "@tscircuit/circuit-json-util";
|
|
6342
6659
|
import "schematic-symbols";
|
|
6343
6660
|
import "svgson";
|
|
6344
|
-
import { applyToPoint as
|
|
6661
|
+
import { applyToPoint as applyToPoint45 } from "transformation-matrix";
|
|
6345
6662
|
|
|
6346
6663
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
6347
6664
|
import "transformation-matrix";
|
|
6348
6665
|
import "@tscircuit/circuit-json-util";
|
|
6349
6666
|
|
|
6350
6667
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
6351
|
-
import { applyToPoint as
|
|
6668
|
+
import { applyToPoint as applyToPoint40 } from "transformation-matrix";
|
|
6352
6669
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
6353
6670
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
6354
6671
|
var createArrow = (tip, angle, size, color, strokeWidth) => {
|
|
@@ -6401,8 +6718,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
6401
6718
|
realEdgePos.y += realPinLineLength;
|
|
6402
6719
|
break;
|
|
6403
6720
|
}
|
|
6404
|
-
const screenSchPortPos =
|
|
6405
|
-
const screenRealEdgePos =
|
|
6721
|
+
const screenSchPortPos = applyToPoint40(transform, schPort.center);
|
|
6722
|
+
const screenRealEdgePos = applyToPoint40(transform, realEdgePos);
|
|
6406
6723
|
const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
|
|
6407
6724
|
const realLineEnd = { ...schPort.center };
|
|
6408
6725
|
if (!isConnected) {
|
|
@@ -6421,7 +6738,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
6421
6738
|
break;
|
|
6422
6739
|
}
|
|
6423
6740
|
}
|
|
6424
|
-
const screenLineEnd =
|
|
6741
|
+
const screenLineEnd = applyToPoint40(transform, realLineEnd);
|
|
6425
6742
|
svgObjects.push({
|
|
6426
6743
|
name: "line",
|
|
6427
6744
|
type: "element",
|
|
@@ -6542,7 +6859,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
6542
6859
|
};
|
|
6543
6860
|
|
|
6544
6861
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
6545
|
-
import { applyToPoint as
|
|
6862
|
+
import { applyToPoint as applyToPoint41 } from "transformation-matrix";
|
|
6546
6863
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
6547
6864
|
const svgObjects = [];
|
|
6548
6865
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -6560,7 +6877,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
6560
6877
|
} else {
|
|
6561
6878
|
realPinNumberPos.y += 0.02;
|
|
6562
6879
|
}
|
|
6563
|
-
const screenPinNumberTextPos =
|
|
6880
|
+
const screenPinNumberTextPos = applyToPoint41(transform, realPinNumberPos);
|
|
6564
6881
|
svgObjects.push({
|
|
6565
6882
|
name: "text",
|
|
6566
6883
|
type: "element",
|
|
@@ -6590,7 +6907,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
6590
6907
|
};
|
|
6591
6908
|
|
|
6592
6909
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
6593
|
-
import { applyToPoint as
|
|
6910
|
+
import { applyToPoint as applyToPoint42 } from "transformation-matrix";
|
|
6594
6911
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
6595
6912
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
6596
6913
|
const svgObjects = [];
|
|
@@ -6604,7 +6921,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
6604
6921
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
6605
6922
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
6606
6923
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
6607
|
-
const screenPinNumberTextPos =
|
|
6924
|
+
const screenPinNumberTextPos = applyToPoint42(transform, realPinNumberPos);
|
|
6608
6925
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
6609
6926
|
if (!label) return [];
|
|
6610
6927
|
const isNegated = label.startsWith("N_");
|
|
@@ -6652,13 +6969,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
6652
6969
|
};
|
|
6653
6970
|
|
|
6654
6971
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
6655
|
-
import { applyToPoint as
|
|
6972
|
+
import { applyToPoint as applyToPoint44 } from "transformation-matrix";
|
|
6656
6973
|
var createSvgSchText = ({
|
|
6657
6974
|
elm,
|
|
6658
6975
|
transform,
|
|
6659
6976
|
colorMap: colorMap2
|
|
6660
6977
|
}) => {
|
|
6661
|
-
const center =
|
|
6978
|
+
const center = applyToPoint44(transform, elm.position);
|
|
6662
6979
|
const textAnchorMap = {
|
|
6663
6980
|
center: "middle",
|
|
6664
6981
|
center_right: "end",
|
|
@@ -6742,11 +7059,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
6742
7059
|
colorMap: colorMap2
|
|
6743
7060
|
}) => {
|
|
6744
7061
|
const svgObjects = [];
|
|
6745
|
-
const componentScreenTopLeft =
|
|
7062
|
+
const componentScreenTopLeft = applyToPoint45(transform, {
|
|
6746
7063
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
6747
7064
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
6748
7065
|
});
|
|
6749
|
-
const componentScreenBottomRight =
|
|
7066
|
+
const componentScreenBottomRight = applyToPoint45(transform, {
|
|
6750
7067
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
6751
7068
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
6752
7069
|
});
|
|
@@ -6832,13 +7149,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
6832
7149
|
}
|
|
6833
7150
|
|
|
6834
7151
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
6835
|
-
import { applyToPoint as
|
|
7152
|
+
import { applyToPoint as applyToPoint46 } from "transformation-matrix";
|
|
6836
7153
|
function createSvgObjectsFromSchVoltageProbe({
|
|
6837
7154
|
probe,
|
|
6838
7155
|
transform,
|
|
6839
7156
|
colorMap: colorMap2
|
|
6840
7157
|
}) {
|
|
6841
|
-
const [screenX, screenY] =
|
|
7158
|
+
const [screenX, screenY] = applyToPoint46(transform, [
|
|
6842
7159
|
probe.position.x,
|
|
6843
7160
|
probe.position.y
|
|
6844
7161
|
]);
|
|
@@ -6898,17 +7215,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
6898
7215
|
}
|
|
6899
7216
|
|
|
6900
7217
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
6901
|
-
import { applyToPoint as
|
|
7218
|
+
import { applyToPoint as applyToPoint47 } from "transformation-matrix";
|
|
6902
7219
|
function createSvgObjectsFromSchDebugObject({
|
|
6903
7220
|
debugObject,
|
|
6904
7221
|
transform
|
|
6905
7222
|
}) {
|
|
6906
7223
|
if (debugObject.shape === "rect") {
|
|
6907
|
-
let [screenLeft, screenTop] =
|
|
7224
|
+
let [screenLeft, screenTop] = applyToPoint47(transform, [
|
|
6908
7225
|
debugObject.center.x - debugObject.size.width / 2,
|
|
6909
7226
|
debugObject.center.y - debugObject.size.height / 2
|
|
6910
7227
|
]);
|
|
6911
|
-
let [screenRight, screenBottom] =
|
|
7228
|
+
let [screenRight, screenBottom] = applyToPoint47(transform, [
|
|
6912
7229
|
debugObject.center.x + debugObject.size.width / 2,
|
|
6913
7230
|
debugObject.center.y + debugObject.size.height / 2
|
|
6914
7231
|
]);
|
|
@@ -6918,7 +7235,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
6918
7235
|
];
|
|
6919
7236
|
const width = Math.abs(screenRight - screenLeft);
|
|
6920
7237
|
const height = Math.abs(screenBottom - screenTop);
|
|
6921
|
-
const [screenCenterX, screenCenterY] =
|
|
7238
|
+
const [screenCenterX, screenCenterY] = applyToPoint47(transform, [
|
|
6922
7239
|
debugObject.center.x,
|
|
6923
7240
|
debugObject.center.y
|
|
6924
7241
|
]);
|
|
@@ -6964,11 +7281,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
6964
7281
|
];
|
|
6965
7282
|
}
|
|
6966
7283
|
if (debugObject.shape === "line") {
|
|
6967
|
-
const [screenStartX, screenStartY] =
|
|
7284
|
+
const [screenStartX, screenStartY] = applyToPoint47(transform, [
|
|
6968
7285
|
debugObject.start.x,
|
|
6969
7286
|
debugObject.start.y
|
|
6970
7287
|
]);
|
|
6971
|
-
const [screenEndX, screenEndY] =
|
|
7288
|
+
const [screenEndX, screenEndY] = applyToPoint47(transform, [
|
|
6972
7289
|
debugObject.end.x,
|
|
6973
7290
|
debugObject.end.y
|
|
6974
7291
|
]);
|
|
@@ -7018,7 +7335,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
7018
7335
|
}
|
|
7019
7336
|
|
|
7020
7337
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
7021
|
-
import { applyToPoint as
|
|
7338
|
+
import { applyToPoint as applyToPoint48 } from "transformation-matrix";
|
|
7022
7339
|
function createSchematicTrace({
|
|
7023
7340
|
trace,
|
|
7024
7341
|
transform,
|
|
@@ -7032,11 +7349,11 @@ function createSchematicTrace({
|
|
|
7032
7349
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
7033
7350
|
const edge = edges[edgeIndex];
|
|
7034
7351
|
if (edge.is_crossing) continue;
|
|
7035
|
-
const [screenFromX, screenFromY] =
|
|
7352
|
+
const [screenFromX, screenFromY] = applyToPoint48(transform, [
|
|
7036
7353
|
edge.from.x,
|
|
7037
7354
|
edge.from.y
|
|
7038
7355
|
]);
|
|
7039
|
-
const [screenToX, screenToY] =
|
|
7356
|
+
const [screenToX, screenToY] = applyToPoint48(transform, [
|
|
7040
7357
|
edge.to.x,
|
|
7041
7358
|
edge.to.y
|
|
7042
7359
|
]);
|
|
@@ -7080,11 +7397,11 @@ function createSchematicTrace({
|
|
|
7080
7397
|
}
|
|
7081
7398
|
for (const edge of edges) {
|
|
7082
7399
|
if (!edge.is_crossing) continue;
|
|
7083
|
-
const [screenFromX, screenFromY] =
|
|
7400
|
+
const [screenFromX, screenFromY] = applyToPoint48(transform, [
|
|
7084
7401
|
edge.from.x,
|
|
7085
7402
|
edge.from.y
|
|
7086
7403
|
]);
|
|
7087
|
-
const [screenToX, screenToY] =
|
|
7404
|
+
const [screenToX, screenToY] = applyToPoint48(transform, [
|
|
7088
7405
|
edge.to.x,
|
|
7089
7406
|
edge.to.y
|
|
7090
7407
|
]);
|
|
@@ -7128,7 +7445,7 @@ function createSchematicTrace({
|
|
|
7128
7445
|
}
|
|
7129
7446
|
if (trace.junctions) {
|
|
7130
7447
|
for (const junction of trace.junctions) {
|
|
7131
|
-
const [screenX, screenY] =
|
|
7448
|
+
const [screenX, screenY] = applyToPoint48(transform, [
|
|
7132
7449
|
junction.x,
|
|
7133
7450
|
junction.y
|
|
7134
7451
|
]);
|
|
@@ -7183,7 +7500,7 @@ function createSchematicTrace({
|
|
|
7183
7500
|
|
|
7184
7501
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
7185
7502
|
import {
|
|
7186
|
-
applyToPoint as
|
|
7503
|
+
applyToPoint as applyToPoint50,
|
|
7187
7504
|
compose as compose11,
|
|
7188
7505
|
rotate as rotate6,
|
|
7189
7506
|
scale as scale6,
|
|
@@ -7192,7 +7509,7 @@ import {
|
|
|
7192
7509
|
|
|
7193
7510
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
7194
7511
|
import {
|
|
7195
|
-
applyToPoint as
|
|
7512
|
+
applyToPoint as applyToPoint49,
|
|
7196
7513
|
compose as compose10,
|
|
7197
7514
|
rotate as rotate5,
|
|
7198
7515
|
scale as scale5,
|
|
@@ -7267,7 +7584,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7267
7584
|
x: symbolBounds.minX,
|
|
7268
7585
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
7269
7586
|
};
|
|
7270
|
-
const rotatedSymbolEnd =
|
|
7587
|
+
const rotatedSymbolEnd = applyToPoint49(rotationMatrix, symbolEndPoint);
|
|
7271
7588
|
const symbolToRealTransform = compose10(
|
|
7272
7589
|
translate10(
|
|
7273
7590
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
@@ -7277,11 +7594,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7277
7594
|
scale5(1)
|
|
7278
7595
|
// Use full symbol size
|
|
7279
7596
|
);
|
|
7280
|
-
const [screenMinX, screenMinY] =
|
|
7597
|
+
const [screenMinX, screenMinY] = applyToPoint49(
|
|
7281
7598
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
7282
7599
|
[bounds.minX, bounds.minY]
|
|
7283
7600
|
);
|
|
7284
|
-
const [screenMaxX, screenMaxY] =
|
|
7601
|
+
const [screenMaxX, screenMaxY] = applyToPoint49(
|
|
7285
7602
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
7286
7603
|
[bounds.maxX, bounds.maxY]
|
|
7287
7604
|
);
|
|
@@ -7305,7 +7622,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7305
7622
|
});
|
|
7306
7623
|
for (const path of symbolPaths) {
|
|
7307
7624
|
const symbolPath = path.points.map((p, i) => {
|
|
7308
|
-
const [x, y] =
|
|
7625
|
+
const [x, y] = applyToPoint49(
|
|
7309
7626
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
7310
7627
|
[p.x, p.y]
|
|
7311
7628
|
);
|
|
@@ -7326,7 +7643,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7326
7643
|
});
|
|
7327
7644
|
}
|
|
7328
7645
|
for (const text of symbolTexts) {
|
|
7329
|
-
const screenTextPos =
|
|
7646
|
+
const screenTextPos = applyToPoint49(
|
|
7330
7647
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
7331
7648
|
text
|
|
7332
7649
|
);
|
|
@@ -7368,7 +7685,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7368
7685
|
});
|
|
7369
7686
|
}
|
|
7370
7687
|
for (const box of symbolBoxes) {
|
|
7371
|
-
const screenBoxPos =
|
|
7688
|
+
const screenBoxPos = applyToPoint49(
|
|
7372
7689
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
7373
7690
|
box
|
|
7374
7691
|
);
|
|
@@ -7391,7 +7708,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
7391
7708
|
});
|
|
7392
7709
|
}
|
|
7393
7710
|
for (const circle of symbolCircles) {
|
|
7394
|
-
const screenCirclePos =
|
|
7711
|
+
const screenCirclePos = applyToPoint49(
|
|
7395
7712
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
7396
7713
|
circle
|
|
7397
7714
|
);
|
|
@@ -7436,14 +7753,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
7436
7753
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
7437
7754
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
7438
7755
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
7439
|
-
const screenCenter =
|
|
7756
|
+
const screenCenter = applyToPoint50(realToScreenTransform, schNetLabel.center);
|
|
7440
7757
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
7441
7758
|
schNetLabel.anchor_side
|
|
7442
7759
|
);
|
|
7443
7760
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
7444
7761
|
screenTextGrowthVec.y *= -1;
|
|
7445
7762
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
7446
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
7763
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint50(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
7447
7764
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
7448
7765
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
7449
7766
|
};
|
|
@@ -7484,7 +7801,7 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
7484
7801
|
y: -0.6
|
|
7485
7802
|
}
|
|
7486
7803
|
].map(
|
|
7487
|
-
(fontRelativePoint) =>
|
|
7804
|
+
(fontRelativePoint) => applyToPoint50(
|
|
7488
7805
|
compose11(
|
|
7489
7806
|
realToScreenTransform,
|
|
7490
7807
|
translate11(realAnchorPosition.x, realAnchorPosition.y),
|
|
@@ -7561,17 +7878,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
7561
7878
|
};
|
|
7562
7879
|
|
|
7563
7880
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
7564
|
-
import { applyToPoint as
|
|
7881
|
+
import { applyToPoint as applyToPoint51 } from "transformation-matrix";
|
|
7565
7882
|
var createSvgObjectsFromSchematicBox = ({
|
|
7566
7883
|
schematicBox,
|
|
7567
7884
|
transform,
|
|
7568
7885
|
colorMap: colorMap2
|
|
7569
7886
|
}) => {
|
|
7570
|
-
const topLeft =
|
|
7887
|
+
const topLeft = applyToPoint51(transform, {
|
|
7571
7888
|
x: schematicBox.x,
|
|
7572
7889
|
y: schematicBox.y
|
|
7573
7890
|
});
|
|
7574
|
-
const bottomRight =
|
|
7891
|
+
const bottomRight = applyToPoint51(transform, {
|
|
7575
7892
|
x: schematicBox.x + schematicBox.width,
|
|
7576
7893
|
y: schematicBox.y + schematicBox.height
|
|
7577
7894
|
});
|
|
@@ -7607,7 +7924,7 @@ var createSvgObjectsFromSchematicBox = ({
|
|
|
7607
7924
|
};
|
|
7608
7925
|
|
|
7609
7926
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-table.ts
|
|
7610
|
-
import { applyToPoint as
|
|
7927
|
+
import { applyToPoint as applyToPoint52 } from "transformation-matrix";
|
|
7611
7928
|
var createSvgObjectsFromSchematicTable = ({
|
|
7612
7929
|
schematicTable,
|
|
7613
7930
|
transform,
|
|
@@ -7640,11 +7957,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
7640
7957
|
const svgObjects = [];
|
|
7641
7958
|
const borderStrokeWidth = border_width * Math.abs(transform.a);
|
|
7642
7959
|
const gridStrokeWidth = getSchStrokeSize(transform);
|
|
7643
|
-
const [screenTopLeftX, screenTopLeftY] =
|
|
7960
|
+
const [screenTopLeftX, screenTopLeftY] = applyToPoint52(transform, [
|
|
7644
7961
|
topLeftX,
|
|
7645
7962
|
topLeftY
|
|
7646
7963
|
]);
|
|
7647
|
-
const [screenBottomRightX, screenBottomRightY] =
|
|
7964
|
+
const [screenBottomRightX, screenBottomRightY] = applyToPoint52(transform, [
|
|
7648
7965
|
topLeftX + totalWidth,
|
|
7649
7966
|
topLeftY - totalHeight
|
|
7650
7967
|
]);
|
|
@@ -7676,8 +7993,8 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
7676
7993
|
(cell) => cell.start_column_index <= i && cell.end_column_index > i && cell.start_row_index <= j && cell.end_row_index >= j
|
|
7677
7994
|
);
|
|
7678
7995
|
if (!isMerged) {
|
|
7679
|
-
const start =
|
|
7680
|
-
const end =
|
|
7996
|
+
const start = applyToPoint52(transform, { x: currentX, y: segmentStartY });
|
|
7997
|
+
const end = applyToPoint52(transform, { x: currentX, y: segmentEndY });
|
|
7681
7998
|
svgObjects.push({
|
|
7682
7999
|
name: "line",
|
|
7683
8000
|
type: "element",
|
|
@@ -7706,11 +8023,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
7706
8023
|
(cell) => cell.start_row_index <= i && cell.end_row_index > i && cell.start_column_index <= j && cell.end_column_index >= j
|
|
7707
8024
|
);
|
|
7708
8025
|
if (!isMerged) {
|
|
7709
|
-
const start =
|
|
8026
|
+
const start = applyToPoint52(transform, {
|
|
7710
8027
|
x: segmentStartX,
|
|
7711
8028
|
y: currentY
|
|
7712
8029
|
});
|
|
7713
|
-
const end =
|
|
8030
|
+
const end = applyToPoint52(transform, { x: segmentEndX, y: currentY });
|
|
7714
8031
|
svgObjects.push({
|
|
7715
8032
|
name: "line",
|
|
7716
8033
|
type: "element",
|
|
@@ -7752,7 +8069,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
7752
8069
|
} else if (vertical_align === "bottom") {
|
|
7753
8070
|
realTextAnchorPos.y = cellTopLeftY - cellHeight + cell_padding;
|
|
7754
8071
|
}
|
|
7755
|
-
const screenTextAnchorPos =
|
|
8072
|
+
const screenTextAnchorPos = applyToPoint52(transform, realTextAnchorPos);
|
|
7756
8073
|
const fontSize = getSchScreenFontSize(
|
|
7757
8074
|
transform,
|
|
7758
8075
|
"reference_designator",
|
|
@@ -7808,13 +8125,13 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
7808
8125
|
|
|
7809
8126
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
|
|
7810
8127
|
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
7811
|
-
import { applyToPoint as
|
|
8128
|
+
import { applyToPoint as applyToPoint53 } from "transformation-matrix";
|
|
7812
8129
|
var PIN_CIRCLE_RADIUS_MM2 = 0.02;
|
|
7813
8130
|
var createSvgObjectsForSchPortHover = ({
|
|
7814
8131
|
schPort,
|
|
7815
8132
|
transform
|
|
7816
8133
|
}) => {
|
|
7817
|
-
const screenSchPortPos =
|
|
8134
|
+
const screenSchPortPos = applyToPoint53(transform, schPort.center);
|
|
7818
8135
|
const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
|
|
7819
8136
|
return [
|
|
7820
8137
|
{
|
|
@@ -7859,14 +8176,14 @@ var createSvgObjectsForSchComponentPortHovers = ({
|
|
|
7859
8176
|
};
|
|
7860
8177
|
|
|
7861
8178
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-line.ts
|
|
7862
|
-
import { applyToPoint as
|
|
8179
|
+
import { applyToPoint as applyToPoint54 } from "transformation-matrix";
|
|
7863
8180
|
function createSvgObjectsFromSchematicLine({
|
|
7864
8181
|
schLine,
|
|
7865
8182
|
transform,
|
|
7866
8183
|
colorMap: colorMap2
|
|
7867
8184
|
}) {
|
|
7868
|
-
const p1 =
|
|
7869
|
-
const p2 =
|
|
8185
|
+
const p1 = applyToPoint54(transform, { x: schLine.x1, y: schLine.y1 });
|
|
8186
|
+
const p2 = applyToPoint54(transform, { x: schLine.x2, y: schLine.y2 });
|
|
7870
8187
|
const strokeWidth = schLine.stroke_width ?? 0.02;
|
|
7871
8188
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
7872
8189
|
return [
|
|
@@ -7895,13 +8212,13 @@ function createSvgObjectsFromSchematicLine({
|
|
|
7895
8212
|
}
|
|
7896
8213
|
|
|
7897
8214
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-circle.ts
|
|
7898
|
-
import { applyToPoint as
|
|
8215
|
+
import { applyToPoint as applyToPoint55 } from "transformation-matrix";
|
|
7899
8216
|
function createSvgObjectsFromSchematicCircle({
|
|
7900
8217
|
schCircle,
|
|
7901
8218
|
transform,
|
|
7902
8219
|
colorMap: colorMap2
|
|
7903
8220
|
}) {
|
|
7904
|
-
const center =
|
|
8221
|
+
const center = applyToPoint55(transform, schCircle.center);
|
|
7905
8222
|
const transformedRadius = Math.abs(transform.a) * schCircle.radius;
|
|
7906
8223
|
const strokeWidth = schCircle.stroke_width ?? 0.02;
|
|
7907
8224
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -7931,13 +8248,13 @@ function createSvgObjectsFromSchematicCircle({
|
|
|
7931
8248
|
}
|
|
7932
8249
|
|
|
7933
8250
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-rect.ts
|
|
7934
|
-
import { applyToPoint as
|
|
8251
|
+
import { applyToPoint as applyToPoint56 } from "transformation-matrix";
|
|
7935
8252
|
function createSvgObjectsFromSchematicRect({
|
|
7936
8253
|
schRect,
|
|
7937
8254
|
transform,
|
|
7938
8255
|
colorMap: colorMap2
|
|
7939
8256
|
}) {
|
|
7940
|
-
const center =
|
|
8257
|
+
const center = applyToPoint56(transform, schRect.center);
|
|
7941
8258
|
const transformedWidth = Math.abs(transform.a) * schRect.width;
|
|
7942
8259
|
const transformedHeight = Math.abs(transform.d) * schRect.height;
|
|
7943
8260
|
const strokeWidth = schRect.stroke_width ?? 0.02;
|
|
@@ -7973,13 +8290,13 @@ function createSvgObjectsFromSchematicRect({
|
|
|
7973
8290
|
}
|
|
7974
8291
|
|
|
7975
8292
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-arc.ts
|
|
7976
|
-
import { applyToPoint as
|
|
8293
|
+
import { applyToPoint as applyToPoint57 } from "transformation-matrix";
|
|
7977
8294
|
function createSvgObjectsFromSchematicArc({
|
|
7978
8295
|
schArc,
|
|
7979
8296
|
transform,
|
|
7980
8297
|
colorMap: colorMap2
|
|
7981
8298
|
}) {
|
|
7982
|
-
const center =
|
|
8299
|
+
const center = applyToPoint57(transform, schArc.center);
|
|
7983
8300
|
const transformedRadius = Math.abs(transform.a) * schArc.radius;
|
|
7984
8301
|
const strokeWidth = schArc.stroke_width ?? 0.02;
|
|
7985
8302
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -9011,18 +9328,18 @@ function formatNumber2(value) {
|
|
|
9011
9328
|
// lib/pcb/convert-circuit-json-to-solder-paste-mask.ts
|
|
9012
9329
|
import { stringify as stringify7 } from "svgson";
|
|
9013
9330
|
import {
|
|
9014
|
-
applyToPoint as
|
|
9331
|
+
applyToPoint as applyToPoint60,
|
|
9015
9332
|
compose as compose14,
|
|
9016
9333
|
scale as scale8,
|
|
9017
9334
|
translate as translate14
|
|
9018
9335
|
} from "transformation-matrix";
|
|
9019
9336
|
|
|
9020
9337
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
9021
|
-
import { applyToPoint as
|
|
9338
|
+
import { applyToPoint as applyToPoint59 } from "transformation-matrix";
|
|
9022
9339
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
9023
9340
|
const { transform, layer: layerFilter } = ctx;
|
|
9024
9341
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
9025
|
-
const [x, y] =
|
|
9342
|
+
const [x, y] = applyToPoint59(transform, [solderPaste.x, solderPaste.y]);
|
|
9026
9343
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
9027
9344
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
9028
9345
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -9233,8 +9550,8 @@ function createSvgObjects4({ elm, ctx }) {
|
|
|
9233
9550
|
}
|
|
9234
9551
|
}
|
|
9235
9552
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
9236
|
-
const [x1, y1] =
|
|
9237
|
-
const [x2, y2] =
|
|
9553
|
+
const [x1, y1] = applyToPoint60(transform, [minX, minY]);
|
|
9554
|
+
const [x2, y2] = applyToPoint60(transform, [maxX, maxY]);
|
|
9238
9555
|
const width = Math.abs(x2 - x1);
|
|
9239
9556
|
const height = Math.abs(y2 - y1);
|
|
9240
9557
|
const x = Math.min(x1, x2);
|