circuit-to-svg 0.0.101 → 0.0.103
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 +1 -0
- package/dist/index.js +344 -99
- 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 applyToPoint16,
|
|
5
5
|
compose as compose3,
|
|
6
6
|
scale,
|
|
7
7
|
translate as translate3
|
|
@@ -374,6 +374,129 @@ function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, transform) {
|
|
|
374
374
|
return [svgObject];
|
|
375
375
|
}
|
|
376
376
|
|
|
377
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-rect.ts
|
|
378
|
+
import {
|
|
379
|
+
applyToPoint as applyToPoint7
|
|
380
|
+
} from "transformation-matrix";
|
|
381
|
+
function createSvgObjectsFromPcbSilkscreenRect(pcbSilkscreenRect, transform) {
|
|
382
|
+
const {
|
|
383
|
+
center,
|
|
384
|
+
width,
|
|
385
|
+
height,
|
|
386
|
+
layer = "top",
|
|
387
|
+
pcb_silkscreen_rect_id
|
|
388
|
+
} = pcbSilkscreenRect;
|
|
389
|
+
if (!center || typeof center.x !== "number" || typeof center.y !== "number" || typeof width !== "number" || typeof height !== "number") {
|
|
390
|
+
console.error("Invalid rectangle data:", { center, width, height });
|
|
391
|
+
return [];
|
|
392
|
+
}
|
|
393
|
+
const [transformedX, transformedY] = applyToPoint7(transform, [
|
|
394
|
+
center.x,
|
|
395
|
+
center.y
|
|
396
|
+
]);
|
|
397
|
+
const transformedWidth = width * Math.abs(transform.a);
|
|
398
|
+
const transformedHeight = height * Math.abs(transform.d);
|
|
399
|
+
const svgObject = {
|
|
400
|
+
name: "rect",
|
|
401
|
+
type: "element",
|
|
402
|
+
attributes: {
|
|
403
|
+
x: (transformedX - transformedWidth / 2).toString(),
|
|
404
|
+
y: (transformedY - transformedHeight / 2).toString(),
|
|
405
|
+
width: transformedWidth.toString(),
|
|
406
|
+
height: transformedHeight.toString(),
|
|
407
|
+
class: `pcb-silkscreen-rect pcb-silkscreen-${layer}`,
|
|
408
|
+
stroke: "red",
|
|
409
|
+
"stroke-width": "1",
|
|
410
|
+
"data-pcb-silkscreen-rect-id": pcb_silkscreen_rect_id
|
|
411
|
+
},
|
|
412
|
+
value: "",
|
|
413
|
+
children: []
|
|
414
|
+
};
|
|
415
|
+
return [svgObject];
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-circle.ts
|
|
419
|
+
import {
|
|
420
|
+
applyToPoint as applyToPoint8
|
|
421
|
+
} from "transformation-matrix";
|
|
422
|
+
function createSvgObjectsFromPcbSilkscreenCircle(pcbSilkscreenCircle, transform) {
|
|
423
|
+
const {
|
|
424
|
+
center,
|
|
425
|
+
radius,
|
|
426
|
+
layer = "top",
|
|
427
|
+
pcb_silkscreen_circle_id
|
|
428
|
+
} = pcbSilkscreenCircle;
|
|
429
|
+
if (!center || typeof center.x !== "number" || typeof center.y !== "number" || typeof radius !== "number") {
|
|
430
|
+
console.error("Invalid PCB Silkscreen Circle data:", { center, radius });
|
|
431
|
+
return [];
|
|
432
|
+
}
|
|
433
|
+
const [transformedX, transformedY] = applyToPoint8(transform, [
|
|
434
|
+
center.x,
|
|
435
|
+
center.y
|
|
436
|
+
]);
|
|
437
|
+
const transformedRadius = radius * Math.abs(transform.a);
|
|
438
|
+
console.debug(
|
|
439
|
+
`Transformed Circle - X: ${transformedX}, Y: ${transformedY}, Radius: ${transformedRadius}`
|
|
440
|
+
);
|
|
441
|
+
const svgObject = {
|
|
442
|
+
name: "circle",
|
|
443
|
+
type: "element",
|
|
444
|
+
attributes: {
|
|
445
|
+
cx: transformedX.toString(),
|
|
446
|
+
cy: transformedY.toString(),
|
|
447
|
+
r: transformedRadius.toString(),
|
|
448
|
+
class: `pcb-silkscreen-circle pcb-silkscreen-${layer}`,
|
|
449
|
+
stroke: "red",
|
|
450
|
+
"stroke-width": "3",
|
|
451
|
+
"data-pcb-silkscreen-circle-id": pcb_silkscreen_circle_id
|
|
452
|
+
},
|
|
453
|
+
value: "",
|
|
454
|
+
children: []
|
|
455
|
+
};
|
|
456
|
+
console.log(svgObject);
|
|
457
|
+
return [svgObject];
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-silkscreen-line.ts
|
|
461
|
+
import {
|
|
462
|
+
applyToPoint as applyToPoint9
|
|
463
|
+
} from "transformation-matrix";
|
|
464
|
+
function createSvgObjectsFromPcbSilkscreenLine(pcbSilkscreenLine, transform) {
|
|
465
|
+
const {
|
|
466
|
+
x1,
|
|
467
|
+
y1,
|
|
468
|
+
x2,
|
|
469
|
+
y2,
|
|
470
|
+
stroke_width,
|
|
471
|
+
layer = "top",
|
|
472
|
+
pcb_silkscreen_line_id
|
|
473
|
+
} = pcbSilkscreenLine;
|
|
474
|
+
if (typeof x1 !== "number" || typeof y1 !== "number" || typeof x2 !== "number" || typeof y2 !== "number") {
|
|
475
|
+
console.error("Invalid coordinates:", { x1, y1, x2, y2 });
|
|
476
|
+
return [];
|
|
477
|
+
}
|
|
478
|
+
const [transformedX1, transformedY1] = applyToPoint9(transform, [x1, y1]);
|
|
479
|
+
const [transformedX2, transformedY2] = applyToPoint9(transform, [x2, y2]);
|
|
480
|
+
const transformedStrokeWidth = stroke_width * Math.abs(transform.a);
|
|
481
|
+
return [
|
|
482
|
+
{
|
|
483
|
+
name: "line",
|
|
484
|
+
type: "element",
|
|
485
|
+
attributes: {
|
|
486
|
+
x1: transformedX1.toString(),
|
|
487
|
+
y1: transformedY1.toString(),
|
|
488
|
+
x2: transformedX2.toString(),
|
|
489
|
+
y2: transformedY2.toString(),
|
|
490
|
+
"stroke-width": transformedStrokeWidth.toString(),
|
|
491
|
+
class: `pcb-silkscreen-line pcb-silkscreen-${layer}`,
|
|
492
|
+
"data-pcb-silkscreen-line-id": pcb_silkscreen_line_id
|
|
493
|
+
},
|
|
494
|
+
value: "",
|
|
495
|
+
children: []
|
|
496
|
+
}
|
|
497
|
+
];
|
|
498
|
+
}
|
|
499
|
+
|
|
377
500
|
// lib/utils/pairs.ts
|
|
378
501
|
function pairs(arr) {
|
|
379
502
|
const result = [];
|
|
@@ -384,7 +507,7 @@ function pairs(arr) {
|
|
|
384
507
|
}
|
|
385
508
|
|
|
386
509
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-trace.ts
|
|
387
|
-
import { applyToPoint as
|
|
510
|
+
import { applyToPoint as applyToPoint10 } from "transformation-matrix";
|
|
388
511
|
|
|
389
512
|
// lib/pcb/layer-name-to-color.ts
|
|
390
513
|
var LAYER_NAME_TO_COLOR = {
|
|
@@ -402,8 +525,8 @@ function createSvgObjectsFromPcbTrace(trace, transform) {
|
|
|
402
525
|
const segments = pairs(trace.route);
|
|
403
526
|
const svgObjects = [];
|
|
404
527
|
for (const [start, end] of segments) {
|
|
405
|
-
const startPoint =
|
|
406
|
-
const endPoint =
|
|
528
|
+
const startPoint = applyToPoint10(transform, [start.x, start.y]);
|
|
529
|
+
const endPoint = applyToPoint10(transform, [end.x, end.y]);
|
|
407
530
|
const layer = "layer" in start ? start.layer : "layer" in end ? end.layer : null;
|
|
408
531
|
if (!layer) continue;
|
|
409
532
|
const layerColor = LAYER_NAME_TO_COLOR[layer] ?? "white";
|
|
@@ -428,9 +551,9 @@ function createSvgObjectsFromPcbTrace(trace, transform) {
|
|
|
428
551
|
}
|
|
429
552
|
|
|
430
553
|
// lib/pcb/svg-object-fns/create-svg-objects-from-smt-pads.ts
|
|
431
|
-
import { applyToPoint as
|
|
554
|
+
import { applyToPoint as applyToPoint11 } from "transformation-matrix";
|
|
432
555
|
function createSvgObjectsFromSmtPad(pad, transform) {
|
|
433
|
-
const [x, y] =
|
|
556
|
+
const [x, y] = applyToPoint11(transform, [pad.x, pad.y]);
|
|
434
557
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
435
558
|
const width = pad.width * Math.abs(transform.a);
|
|
436
559
|
const height = pad.height * Math.abs(transform.d);
|
|
@@ -491,31 +614,31 @@ function createSvgObjectsFromSmtPad(pad, transform) {
|
|
|
491
614
|
}
|
|
492
615
|
|
|
493
616
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-board.ts
|
|
494
|
-
import { applyToPoint as
|
|
617
|
+
import { applyToPoint as applyToPoint12 } from "transformation-matrix";
|
|
495
618
|
function createSvgObjectsFromPcbBoard(pcbBoard, transform) {
|
|
496
619
|
const { width, height, center, outline } = pcbBoard;
|
|
497
620
|
let path;
|
|
498
621
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
499
622
|
path = outline.map((point, index) => {
|
|
500
|
-
const [x, y] =
|
|
623
|
+
const [x, y] = applyToPoint12(transform, [point.x, point.y]);
|
|
501
624
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
502
625
|
}).join(" ");
|
|
503
626
|
} else {
|
|
504
627
|
const halfWidth = width / 2;
|
|
505
628
|
const halfHeight = height / 2;
|
|
506
|
-
const topLeft =
|
|
629
|
+
const topLeft = applyToPoint12(transform, [
|
|
507
630
|
center.x - halfWidth,
|
|
508
631
|
center.y - halfHeight
|
|
509
632
|
]);
|
|
510
|
-
const topRight =
|
|
633
|
+
const topRight = applyToPoint12(transform, [
|
|
511
634
|
center.x + halfWidth,
|
|
512
635
|
center.y - halfHeight
|
|
513
636
|
]);
|
|
514
|
-
const bottomRight =
|
|
637
|
+
const bottomRight = applyToPoint12(transform, [
|
|
515
638
|
center.x + halfWidth,
|
|
516
639
|
center.y + halfHeight
|
|
517
640
|
]);
|
|
518
|
-
const bottomLeft =
|
|
641
|
+
const bottomLeft = applyToPoint12(transform, [
|
|
519
642
|
center.x - halfWidth,
|
|
520
643
|
center.y + halfHeight
|
|
521
644
|
]);
|
|
@@ -539,9 +662,9 @@ function createSvgObjectsFromPcbBoard(pcbBoard, transform) {
|
|
|
539
662
|
}
|
|
540
663
|
|
|
541
664
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-via.ts
|
|
542
|
-
import { applyToPoint as
|
|
665
|
+
import { applyToPoint as applyToPoint13 } from "transformation-matrix";
|
|
543
666
|
function createSvgObjectsFromPcbVia(hole, transform) {
|
|
544
|
-
const [x, y] =
|
|
667
|
+
const [x, y] = applyToPoint13(transform, [hole.x, hole.y]);
|
|
545
668
|
const scaledOuterWidth = hole.outer_diameter * Math.abs(transform.a);
|
|
546
669
|
const scaledOuterHeight = hole.outer_diameter * Math.abs(transform.a);
|
|
547
670
|
const scaledHoleWidth = hole.hole_diameter * Math.abs(transform.a);
|
|
@@ -577,14 +700,14 @@ function createSvgObjectsFromPcbVia(hole, transform) {
|
|
|
577
700
|
}
|
|
578
701
|
|
|
579
702
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-hole.ts
|
|
580
|
-
import { applyToPoint as
|
|
703
|
+
import { applyToPoint as applyToPoint14 } from "transformation-matrix";
|
|
581
704
|
|
|
582
705
|
// lib/pcb/colors.ts
|
|
583
706
|
var HOLE_COLOR = "#FF26E2";
|
|
584
707
|
|
|
585
708
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-hole.ts
|
|
586
709
|
function createSvgObjectsFromPcbHole(hole, transform) {
|
|
587
|
-
const [x, y] =
|
|
710
|
+
const [x, y] = applyToPoint14(transform, [hole.x, hole.y]);
|
|
588
711
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
589
712
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
590
713
|
const radius = scaledDiameter / 2;
|
|
@@ -647,6 +770,118 @@ function createSvgObjectsFromPcbHole(hole, transform) {
|
|
|
647
770
|
return [];
|
|
648
771
|
}
|
|
649
772
|
|
|
773
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-rats-nests.ts
|
|
774
|
+
import {
|
|
775
|
+
getFullConnectivityMapFromCircuitJson
|
|
776
|
+
} from "circuit-json-to-connectivity-map";
|
|
777
|
+
import "svgson";
|
|
778
|
+
import { applyToPoint as applyToPoint15 } from "transformation-matrix";
|
|
779
|
+
|
|
780
|
+
// lib/pcb/create-svg-objects-from-pcb-rats-nest/get-element-position.ts
|
|
781
|
+
import { su } from "@tscircuit/soup-util";
|
|
782
|
+
var getElementPosition = (id, circuitJson) => {
|
|
783
|
+
const pcbSmtpad = su(circuitJson).pcb_smtpad.get(id);
|
|
784
|
+
if (pcbSmtpad && "x" in pcbSmtpad && "y" in pcbSmtpad) {
|
|
785
|
+
return { x: pcbSmtpad.x, y: pcbSmtpad.y };
|
|
786
|
+
}
|
|
787
|
+
const pcbPlatedHole = su(circuitJson).pcb_plated_hole.get(id);
|
|
788
|
+
if (pcbPlatedHole && "x" in pcbPlatedHole && "y" in pcbPlatedHole) {
|
|
789
|
+
return { x: pcbPlatedHole.x, y: pcbPlatedHole.y };
|
|
790
|
+
}
|
|
791
|
+
return null;
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
// lib/pcb/create-svg-objects-from-pcb-rats-nest/find-nearest-point-in-nest.ts
|
|
795
|
+
import "circuit-json-to-connectivity-map";
|
|
796
|
+
var findNearestPointInNet = (sourcePoint, netId, connectivity, circuitJson) => {
|
|
797
|
+
const connectedIds = connectivity.getIdsConnectedToNet(netId);
|
|
798
|
+
let nearestPoint = null;
|
|
799
|
+
let minDistance = Infinity;
|
|
800
|
+
for (const id of connectedIds) {
|
|
801
|
+
const pos = getElementPosition(id, circuitJson);
|
|
802
|
+
if (pos) {
|
|
803
|
+
const dx = sourcePoint.x - pos.x;
|
|
804
|
+
const dy = sourcePoint.y - pos.y;
|
|
805
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
806
|
+
if (distance > 0 && distance < minDistance) {
|
|
807
|
+
minDistance = distance;
|
|
808
|
+
nearestPoint = pos;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
return nearestPoint;
|
|
813
|
+
};
|
|
814
|
+
|
|
815
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-rats-nests.ts
|
|
816
|
+
import { su as su2 } from "@tscircuit/soup-util";
|
|
817
|
+
function createSvgObjectsForRatsNest(circuitJson, transform) {
|
|
818
|
+
const connectivity = getFullConnectivityMapFromCircuitJson(circuitJson);
|
|
819
|
+
const pcbPorts = circuitJson.filter((elm) => elm.type === "pcb_port");
|
|
820
|
+
const sourceTraces = circuitJson.filter((elm) => elm.type === "source_trace");
|
|
821
|
+
const ratsNestLines = [];
|
|
822
|
+
pcbPorts.forEach((port, index) => {
|
|
823
|
+
const portId = port.pcb_port_id;
|
|
824
|
+
if (!portId) return;
|
|
825
|
+
const netId = connectivity.getNetConnectedToId(portId);
|
|
826
|
+
if (!netId) return;
|
|
827
|
+
let isInNet = false;
|
|
828
|
+
const sourcePort = su2(circuitJson).source_port.getWhere({
|
|
829
|
+
pcb_port_id: portId
|
|
830
|
+
});
|
|
831
|
+
if (sourcePort && sourcePort.source_port_id) {
|
|
832
|
+
const sourcePortId = sourcePort.source_port_id;
|
|
833
|
+
for (const trace of sourceTraces) {
|
|
834
|
+
if (Array.isArray(trace.connected_source_port_ids) && trace.connected_source_port_ids.includes(sourcePortId) && Array.isArray(trace.connected_source_net_ids) && trace.connected_source_net_ids.length > 0) {
|
|
835
|
+
isInNet = true;
|
|
836
|
+
break;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
const startPoint = { x: port.x, y: port.y };
|
|
841
|
+
const nearestPoint = findNearestPointInNet(
|
|
842
|
+
startPoint,
|
|
843
|
+
netId,
|
|
844
|
+
connectivity,
|
|
845
|
+
circuitJson
|
|
846
|
+
);
|
|
847
|
+
if (!nearestPoint) return;
|
|
848
|
+
ratsNestLines.push({
|
|
849
|
+
key: `${portId}-${index}`,
|
|
850
|
+
startPoint,
|
|
851
|
+
endPoint: nearestPoint,
|
|
852
|
+
isInNet
|
|
853
|
+
});
|
|
854
|
+
});
|
|
855
|
+
const svgObjects = [];
|
|
856
|
+
for (const line of ratsNestLines) {
|
|
857
|
+
const transformedStart = applyToPoint15(transform, [
|
|
858
|
+
line.startPoint.x,
|
|
859
|
+
line.startPoint.y
|
|
860
|
+
]);
|
|
861
|
+
const transformedEnd = applyToPoint15(transform, [
|
|
862
|
+
line.endPoint.x,
|
|
863
|
+
line.endPoint.y
|
|
864
|
+
]);
|
|
865
|
+
const attributes = {
|
|
866
|
+
x1: transformedStart[0].toString(),
|
|
867
|
+
y1: transformedStart[1].toString(),
|
|
868
|
+
x2: transformedEnd[0].toString(),
|
|
869
|
+
y2: transformedEnd[1].toString(),
|
|
870
|
+
stroke: "white",
|
|
871
|
+
"stroke-width": "1",
|
|
872
|
+
"stroke-dasharray": "6,6"
|
|
873
|
+
};
|
|
874
|
+
svgObjects.push({
|
|
875
|
+
name: "line",
|
|
876
|
+
type: "element",
|
|
877
|
+
attributes,
|
|
878
|
+
value: "",
|
|
879
|
+
children: []
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
return svgObjects;
|
|
883
|
+
}
|
|
884
|
+
|
|
650
885
|
// lib/pcb/convert-circuit-json-to-pcb-svg.ts
|
|
651
886
|
var OBJECT_ORDER = [
|
|
652
887
|
"pcb_trace_error",
|
|
@@ -702,7 +937,7 @@ function convertCircuitJsonToPcbSvg(soup, options) {
|
|
|
702
937
|
scale(scaleFactor, -scaleFactor)
|
|
703
938
|
// Flip in y-direction
|
|
704
939
|
);
|
|
705
|
-
|
|
940
|
+
let svgObjects = soup.sort(
|
|
706
941
|
(a, b) => (OBJECT_ORDER.indexOf(b.type) ?? 9999) - (OBJECT_ORDER.indexOf(a.type) ?? 9999)
|
|
707
942
|
).flatMap(
|
|
708
943
|
(item) => createSvgObjects(item, transform, soup, options?.shouldDrawErrors)
|
|
@@ -714,6 +949,10 @@ function convertCircuitJsonToPcbSvg(soup, options) {
|
|
|
714
949
|
break;
|
|
715
950
|
}
|
|
716
951
|
}
|
|
952
|
+
if (options?.shouldDrawRatsNest) {
|
|
953
|
+
const ratsNestObjects = createSvgObjectsForRatsNest(soup, transform);
|
|
954
|
+
svgObjects = svgObjects.concat(ratsNestObjects);
|
|
955
|
+
}
|
|
717
956
|
const svgObject = {
|
|
718
957
|
name: "svg",
|
|
719
958
|
type: "element",
|
|
@@ -813,6 +1052,12 @@ function createSvgObjects(elm, transform, soup, shouldDrawErrors) {
|
|
|
813
1052
|
return createSvgObjectsFromSmtPad(elm, transform);
|
|
814
1053
|
case "pcb_silkscreen_text":
|
|
815
1054
|
return createSvgObjectsFromPcbSilkscreenText(elm, transform);
|
|
1055
|
+
case "pcb_silkscreen_rect":
|
|
1056
|
+
return createSvgObjectsFromPcbSilkscreenRect(elm, transform);
|
|
1057
|
+
case "pcb_silkscreen_circle":
|
|
1058
|
+
return createSvgObjectsFromPcbSilkscreenCircle(elm, transform);
|
|
1059
|
+
case "pcb_silkscreen_line":
|
|
1060
|
+
return createSvgObjectsFromPcbSilkscreenLine(elm, transform);
|
|
816
1061
|
case "pcb_fabrication_note_path":
|
|
817
1062
|
return createSvgObjectsFromPcbFabricationNotePath(elm, transform);
|
|
818
1063
|
case "pcb_fabrication_note_text":
|
|
@@ -829,7 +1074,7 @@ function createSvgObjects(elm, transform, soup, shouldDrawErrors) {
|
|
|
829
1074
|
}
|
|
830
1075
|
function createSvgObjectsFromPcbComponent(component, transform) {
|
|
831
1076
|
const { center, width, height, rotation = 0 } = component;
|
|
832
|
-
const [x, y] =
|
|
1077
|
+
const [x, y] = applyToPoint16(transform, [center.x, center.y]);
|
|
833
1078
|
const scaledWidth = width * Math.abs(transform.a);
|
|
834
1079
|
const scaledHeight = height * Math.abs(transform.d);
|
|
835
1080
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
@@ -864,8 +1109,8 @@ function createSvgObjectsFromPcbComponent(component, transform) {
|
|
|
864
1109
|
};
|
|
865
1110
|
}
|
|
866
1111
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
867
|
-
const [x1, y1] =
|
|
868
|
-
const [x2, y2] =
|
|
1112
|
+
const [x1, y1] = applyToPoint16(transform, [minX, minY]);
|
|
1113
|
+
const [x2, y2] = applyToPoint16(transform, [maxX, maxY]);
|
|
869
1114
|
const width = Math.abs(x2 - x1);
|
|
870
1115
|
const height = Math.abs(y2 - y1);
|
|
871
1116
|
const x = Math.min(x1, x2);
|
|
@@ -888,16 +1133,16 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
888
1133
|
|
|
889
1134
|
// lib/assembly/convert-circuit-json-to-assembly-svg.ts
|
|
890
1135
|
import { stringify as stringify2 } from "svgson";
|
|
891
|
-
import { su } from "@tscircuit/soup-util";
|
|
1136
|
+
import { su as su3 } from "@tscircuit/soup-util";
|
|
892
1137
|
import {
|
|
893
|
-
applyToPoint as
|
|
1138
|
+
applyToPoint as applyToPoint20,
|
|
894
1139
|
compose as compose4,
|
|
895
1140
|
scale as scale2,
|
|
896
1141
|
translate as translate4
|
|
897
1142
|
} from "transformation-matrix";
|
|
898
1143
|
|
|
899
1144
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
900
|
-
import { applyToPoint as
|
|
1145
|
+
import { applyToPoint as applyToPoint17 } from "transformation-matrix";
|
|
901
1146
|
var DEFAULT_BOARD_STYLE = {
|
|
902
1147
|
fill: "none",
|
|
903
1148
|
stroke: "rgb(0,0,0)",
|
|
@@ -909,25 +1154,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
909
1154
|
let path;
|
|
910
1155
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
911
1156
|
path = outline.map((point, index) => {
|
|
912
|
-
const [x, y] =
|
|
1157
|
+
const [x, y] = applyToPoint17(transform, [point.x, point.y]);
|
|
913
1158
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
914
1159
|
}).join(" ");
|
|
915
1160
|
} else {
|
|
916
1161
|
const halfWidth = width / 2;
|
|
917
1162
|
const halfHeight = height / 2;
|
|
918
|
-
const topLeft =
|
|
1163
|
+
const topLeft = applyToPoint17(transform, [
|
|
919
1164
|
center.x - halfWidth,
|
|
920
1165
|
center.y - halfHeight
|
|
921
1166
|
]);
|
|
922
|
-
const topRight =
|
|
1167
|
+
const topRight = applyToPoint17(transform, [
|
|
923
1168
|
center.x + halfWidth,
|
|
924
1169
|
center.y - halfHeight
|
|
925
1170
|
]);
|
|
926
|
-
const bottomRight =
|
|
1171
|
+
const bottomRight = applyToPoint17(transform, [
|
|
927
1172
|
center.x + halfWidth,
|
|
928
1173
|
center.y + halfHeight
|
|
929
1174
|
]);
|
|
930
|
-
const bottomLeft =
|
|
1175
|
+
const bottomLeft = applyToPoint17(transform, [
|
|
931
1176
|
center.x - halfWidth,
|
|
932
1177
|
center.y + halfHeight
|
|
933
1178
|
]);
|
|
@@ -953,7 +1198,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
953
1198
|
}
|
|
954
1199
|
|
|
955
1200
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
956
|
-
import { applyToPoint as
|
|
1201
|
+
import { applyToPoint as applyToPoint19 } from "transformation-matrix";
|
|
957
1202
|
|
|
958
1203
|
// lib/utils/get-sch-font-size.ts
|
|
959
1204
|
import "transformation-matrix";
|
|
@@ -967,8 +1212,8 @@ var getSchScreenFontSize = (transform, textType) => {
|
|
|
967
1212
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
968
1213
|
function createSvgObjectsFromAssemblyComponent(component, transform, firstPin, name) {
|
|
969
1214
|
const { center, width, height, rotation = 0 } = component;
|
|
970
|
-
const [x, y] =
|
|
971
|
-
const [pinX, pinY] =
|
|
1215
|
+
const [x, y] = applyToPoint19(transform, [center.x, center.y]);
|
|
1216
|
+
const [pinX, pinY] = applyToPoint19(transform, [firstPin.x, firstPin.y]);
|
|
972
1217
|
const scaledWidth = width * Math.abs(transform.a);
|
|
973
1218
|
const scaledHeight = height * Math.abs(transform.d);
|
|
974
1219
|
return {
|
|
@@ -1177,7 +1422,7 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
|
|
|
1177
1422
|
return stringify2(svgObject);
|
|
1178
1423
|
}
|
|
1179
1424
|
function createSvgObjects2(elm, transform, soup) {
|
|
1180
|
-
const sourceComponents =
|
|
1425
|
+
const sourceComponents = su3(soup).source_component.list();
|
|
1181
1426
|
switch (elm.type) {
|
|
1182
1427
|
case "pcb_board":
|
|
1183
1428
|
return createSvgObjectsFromAssemblyBoard(elm, transform);
|
|
@@ -1185,7 +1430,7 @@ function createSvgObjects2(elm, transform, soup) {
|
|
|
1185
1430
|
const sourceComponent = sourceComponents.find(
|
|
1186
1431
|
(item) => item.source_component_id === elm.source_component_id
|
|
1187
1432
|
);
|
|
1188
|
-
const ports =
|
|
1433
|
+
const ports = su3(soup).pcb_port.list().filter((port) => port.pcb_component_id === elm.pcb_component_id);
|
|
1189
1434
|
const firstPort = ports[0];
|
|
1190
1435
|
if (sourceComponent && firstPort) {
|
|
1191
1436
|
return [
|
|
@@ -1204,8 +1449,8 @@ function createSvgObjects2(elm, transform, soup) {
|
|
|
1204
1449
|
}
|
|
1205
1450
|
}
|
|
1206
1451
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
1207
|
-
const [x1, y1] =
|
|
1208
|
-
const [x2, y2] =
|
|
1452
|
+
const [x1, y1] = applyToPoint20(transform, [minX, minY]);
|
|
1453
|
+
const [x2, y2] = applyToPoint20(transform, [maxX, maxY]);
|
|
1209
1454
|
const width = Math.abs(x2 - x1);
|
|
1210
1455
|
const height = Math.abs(y2 - y1);
|
|
1211
1456
|
const x = Math.min(x1, x2);
|
|
@@ -1470,14 +1715,14 @@ import {
|
|
|
1470
1715
|
} from "transformation-matrix";
|
|
1471
1716
|
|
|
1472
1717
|
// lib/sch/draw-schematic-grid.ts
|
|
1473
|
-
import { applyToPoint as
|
|
1718
|
+
import { applyToPoint as applyToPoint21 } from "transformation-matrix";
|
|
1474
1719
|
function drawSchematicGrid(params) {
|
|
1475
1720
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
1476
1721
|
const cellSize = params.cellSize ?? 1;
|
|
1477
1722
|
const labelCells = params.labelCells ?? false;
|
|
1478
1723
|
const gridLines = [];
|
|
1479
1724
|
const transformPoint = (x, y) => {
|
|
1480
|
-
const [transformedX, transformedY] =
|
|
1725
|
+
const [transformedX, transformedY] = applyToPoint21(params.transform, [x, y]);
|
|
1481
1726
|
return { x: transformedX, y: transformedY };
|
|
1482
1727
|
};
|
|
1483
1728
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -1558,15 +1803,15 @@ function drawSchematicGrid(params) {
|
|
|
1558
1803
|
}
|
|
1559
1804
|
|
|
1560
1805
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
1561
|
-
import { applyToPoint as
|
|
1806
|
+
import { applyToPoint as applyToPoint22 } from "transformation-matrix";
|
|
1562
1807
|
function drawSchematicLabeledPoints(params) {
|
|
1563
1808
|
const { points, transform } = params;
|
|
1564
1809
|
const labeledPointsGroup = [];
|
|
1565
1810
|
for (const point of points) {
|
|
1566
|
-
const [x1, y1] =
|
|
1567
|
-
const [x2, y2] =
|
|
1568
|
-
const [x3, y3] =
|
|
1569
|
-
const [x4, y4] =
|
|
1811
|
+
const [x1, y1] = applyToPoint22(transform, [point.x - 0.1, point.y - 0.1]);
|
|
1812
|
+
const [x2, y2] = applyToPoint22(transform, [point.x + 0.1, point.y + 0.1]);
|
|
1813
|
+
const [x3, y3] = applyToPoint22(transform, [point.x - 0.1, point.y + 0.1]);
|
|
1814
|
+
const [x4, y4] = applyToPoint22(transform, [point.x + 0.1, point.y - 0.1]);
|
|
1570
1815
|
labeledPointsGroup.push({
|
|
1571
1816
|
name: "path",
|
|
1572
1817
|
type: "element",
|
|
@@ -1577,7 +1822,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
1577
1822
|
"stroke-opacity": "0.7"
|
|
1578
1823
|
}
|
|
1579
1824
|
});
|
|
1580
|
-
const [labelX, labelY] =
|
|
1825
|
+
const [labelX, labelY] = applyToPoint22(transform, [
|
|
1581
1826
|
point.x + 0.15,
|
|
1582
1827
|
point.y - 0.15
|
|
1583
1828
|
]);
|
|
@@ -1676,11 +1921,11 @@ function getSchematicBoundsFromCircuitJson(soup, padding = 0.5) {
|
|
|
1676
1921
|
}
|
|
1677
1922
|
|
|
1678
1923
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-component-with-symbol.ts
|
|
1679
|
-
import { su as
|
|
1924
|
+
import { su as su4 } from "@tscircuit/soup-util";
|
|
1680
1925
|
import { symbols } from "schematic-symbols";
|
|
1681
1926
|
import "svgson";
|
|
1682
1927
|
import {
|
|
1683
|
-
applyToPoint as
|
|
1928
|
+
applyToPoint as applyToPoint24,
|
|
1684
1929
|
compose as compose6
|
|
1685
1930
|
} from "transformation-matrix";
|
|
1686
1931
|
|
|
@@ -1764,13 +2009,13 @@ function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
|
1764
2009
|
}
|
|
1765
2010
|
|
|
1766
2011
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
1767
|
-
import { applyToPoint as
|
|
2012
|
+
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
1768
2013
|
var createSvgSchErrorText = ({
|
|
1769
2014
|
text,
|
|
1770
2015
|
realCenter,
|
|
1771
2016
|
realToScreenTransform
|
|
1772
2017
|
}) => {
|
|
1773
|
-
const screenCenter =
|
|
2018
|
+
const screenCenter = applyToPoint23(realToScreenTransform, realCenter);
|
|
1774
2019
|
return {
|
|
1775
2020
|
type: "element",
|
|
1776
2021
|
name: "text",
|
|
@@ -1824,10 +2069,10 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
1824
2069
|
})
|
|
1825
2070
|
];
|
|
1826
2071
|
}
|
|
1827
|
-
const schPorts =
|
|
2072
|
+
const schPorts = su4(circuitJson).schematic_port.list({
|
|
1828
2073
|
schematic_component_id: schComponent.schematic_component_id
|
|
1829
2074
|
});
|
|
1830
|
-
const srcComponent =
|
|
2075
|
+
const srcComponent = su4(circuitJson).source_component.get(
|
|
1831
2076
|
schComponent.source_component_id
|
|
1832
2077
|
);
|
|
1833
2078
|
const schPortsWithSymbolPorts = matchSchPortsToSymbolPorts({
|
|
@@ -1860,11 +2105,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
1860
2105
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
1861
2106
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
1862
2107
|
};
|
|
1863
|
-
const [screenMinX, screenMinY] =
|
|
2108
|
+
const [screenMinX, screenMinY] = applyToPoint24(
|
|
1864
2109
|
compose6(realToScreenTransform, transformFromSymbolToReal),
|
|
1865
2110
|
[bounds.minX, bounds.minY]
|
|
1866
2111
|
);
|
|
1867
|
-
const [screenMaxX, screenMaxY] =
|
|
2112
|
+
const [screenMaxX, screenMaxY] = applyToPoint24(
|
|
1868
2113
|
compose6(realToScreenTransform, transformFromSymbolToReal),
|
|
1869
2114
|
[bounds.maxX, bounds.maxY]
|
|
1870
2115
|
);
|
|
@@ -1893,7 +2138,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
1893
2138
|
name: "path",
|
|
1894
2139
|
attributes: {
|
|
1895
2140
|
d: points.map((p, i) => {
|
|
1896
|
-
const [x, y] =
|
|
2141
|
+
const [x, y] = applyToPoint24(
|
|
1897
2142
|
compose6(realToScreenTransform, transformFromSymbolToReal),
|
|
1898
2143
|
[p.x, p.y]
|
|
1899
2144
|
);
|
|
@@ -1908,7 +2153,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
1908
2153
|
});
|
|
1909
2154
|
}
|
|
1910
2155
|
for (const text of texts) {
|
|
1911
|
-
const screenTextPos =
|
|
2156
|
+
const screenTextPos = applyToPoint24(
|
|
1912
2157
|
compose6(realToScreenTransform, transformFromSymbolToReal),
|
|
1913
2158
|
text
|
|
1914
2159
|
);
|
|
@@ -1954,7 +2199,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
1954
2199
|
});
|
|
1955
2200
|
}
|
|
1956
2201
|
for (const box of boxes) {
|
|
1957
|
-
const screenBoxPos =
|
|
2202
|
+
const screenBoxPos = applyToPoint24(
|
|
1958
2203
|
compose6(realToScreenTransform, transformFromSymbolToReal),
|
|
1959
2204
|
box
|
|
1960
2205
|
);
|
|
@@ -1977,7 +2222,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
1977
2222
|
});
|
|
1978
2223
|
}
|
|
1979
2224
|
for (const port of symbol.ports) {
|
|
1980
|
-
const screenPortPos =
|
|
2225
|
+
const screenPortPos = applyToPoint24(
|
|
1981
2226
|
compose6(realToScreenTransform, transformFromSymbolToReal),
|
|
1982
2227
|
port
|
|
1983
2228
|
);
|
|
@@ -2000,18 +2245,18 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2000
2245
|
};
|
|
2001
2246
|
|
|
2002
2247
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-component-with-box.ts
|
|
2003
|
-
import { su as
|
|
2248
|
+
import { su as su7 } from "@tscircuit/soup-util";
|
|
2004
2249
|
import "schematic-symbols";
|
|
2005
2250
|
import "svgson";
|
|
2006
|
-
import { applyToPoint as
|
|
2251
|
+
import { applyToPoint as applyToPoint30 } from "transformation-matrix";
|
|
2007
2252
|
|
|
2008
2253
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
2009
2254
|
import "transformation-matrix";
|
|
2010
2255
|
import "@tscircuit/soup-util";
|
|
2011
2256
|
|
|
2012
2257
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
2013
|
-
import { applyToPoint as
|
|
2014
|
-
import { su as
|
|
2258
|
+
import { applyToPoint as applyToPoint25 } from "transformation-matrix";
|
|
2259
|
+
import { su as su5 } from "@tscircuit/soup-util";
|
|
2015
2260
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
2016
2261
|
var createSvgObjectsForSchPortBoxLine = ({
|
|
2017
2262
|
schPort,
|
|
@@ -2020,7 +2265,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
2020
2265
|
circuitJson
|
|
2021
2266
|
}) => {
|
|
2022
2267
|
const svgObjects = [];
|
|
2023
|
-
const srcPort =
|
|
2268
|
+
const srcPort = su5(circuitJson).source_port.get(schPort.source_port_id);
|
|
2024
2269
|
const realEdgePos = {
|
|
2025
2270
|
x: schPort.center.x,
|
|
2026
2271
|
y: schPort.center.y
|
|
@@ -2040,8 +2285,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
2040
2285
|
realEdgePos.y += realPinLineLength;
|
|
2041
2286
|
break;
|
|
2042
2287
|
}
|
|
2043
|
-
const screenSchPortPos =
|
|
2044
|
-
const screenRealEdgePos =
|
|
2288
|
+
const screenSchPortPos = applyToPoint25(transform, schPort.center);
|
|
2289
|
+
const screenRealEdgePos = applyToPoint25(transform, realEdgePos);
|
|
2045
2290
|
const realLineEnd = { ...schPort.center };
|
|
2046
2291
|
switch (schPort.side_of_component) {
|
|
2047
2292
|
case "left":
|
|
@@ -2057,7 +2302,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
2057
2302
|
realLineEnd.y += PIN_CIRCLE_RADIUS_MM;
|
|
2058
2303
|
break;
|
|
2059
2304
|
}
|
|
2060
|
-
const screenLineEnd =
|
|
2305
|
+
const screenLineEnd = applyToPoint25(transform, realLineEnd);
|
|
2061
2306
|
svgObjects.push({
|
|
2062
2307
|
name: "line",
|
|
2063
2308
|
type: "element",
|
|
@@ -2104,7 +2349,7 @@ var getUnitVectorFromOutsideToEdge = (side) => {
|
|
|
2104
2349
|
};
|
|
2105
2350
|
|
|
2106
2351
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
2107
|
-
import { applyToPoint as
|
|
2352
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
2108
2353
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
2109
2354
|
const svgObjects = [];
|
|
2110
2355
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -2122,7 +2367,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
2122
2367
|
} else {
|
|
2123
2368
|
realPinNumberPos.y += 0.02;
|
|
2124
2369
|
}
|
|
2125
|
-
const screenPinNumberTextPos =
|
|
2370
|
+
const screenPinNumberTextPos = applyToPoint26(transform, realPinNumberPos);
|
|
2126
2371
|
svgObjects.push({
|
|
2127
2372
|
name: "text",
|
|
2128
2373
|
type: "element",
|
|
@@ -2152,7 +2397,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
2152
2397
|
};
|
|
2153
2398
|
|
|
2154
2399
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
2155
|
-
import { applyToPoint as
|
|
2400
|
+
import { applyToPoint as applyToPoint27 } from "transformation-matrix";
|
|
2156
2401
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
2157
2402
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
2158
2403
|
const svgObjects = [];
|
|
@@ -2166,7 +2411,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
2166
2411
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
2167
2412
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
2168
2413
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
2169
|
-
const screenPinNumberTextPos =
|
|
2414
|
+
const screenPinNumberTextPos = applyToPoint27(transform, realPinNumberPos);
|
|
2170
2415
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
2171
2416
|
if (!label) return [];
|
|
2172
2417
|
svgObjects.push({
|
|
@@ -2208,9 +2453,9 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
2208
2453
|
};
|
|
2209
2454
|
|
|
2210
2455
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
2211
|
-
import { applyToPoint as
|
|
2456
|
+
import { applyToPoint as applyToPoint29 } from "transformation-matrix";
|
|
2212
2457
|
var createSvgSchText = (elm, transform) => {
|
|
2213
|
-
const center =
|
|
2458
|
+
const center = applyToPoint29(transform, elm.position);
|
|
2214
2459
|
const textAnchorMap = {
|
|
2215
2460
|
center: "middle",
|
|
2216
2461
|
left: "start",
|
|
@@ -2258,11 +2503,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
2258
2503
|
circuitJson
|
|
2259
2504
|
}) => {
|
|
2260
2505
|
const svgObjects = [];
|
|
2261
|
-
const componentScreenTopLeft =
|
|
2506
|
+
const componentScreenTopLeft = applyToPoint30(transform, {
|
|
2262
2507
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
2263
2508
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
2264
2509
|
});
|
|
2265
|
-
const componentScreenBottomRight =
|
|
2510
|
+
const componentScreenBottomRight = applyToPoint30(transform, {
|
|
2266
2511
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
2267
2512
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
2268
2513
|
});
|
|
@@ -2298,13 +2543,13 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
2298
2543
|
},
|
|
2299
2544
|
children: []
|
|
2300
2545
|
});
|
|
2301
|
-
const schTexts =
|
|
2546
|
+
const schTexts = su7(circuitJson).schematic_text.list();
|
|
2302
2547
|
for (const schText of schTexts) {
|
|
2303
2548
|
if (schText.schematic_component_id === schComponent.schematic_component_id) {
|
|
2304
2549
|
svgObjects.push(createSvgSchText(schText, transform));
|
|
2305
2550
|
}
|
|
2306
2551
|
}
|
|
2307
|
-
const schematicPorts =
|
|
2552
|
+
const schematicPorts = su7(circuitJson).schematic_port.list({
|
|
2308
2553
|
schematic_component_id: schComponent.schematic_component_id
|
|
2309
2554
|
});
|
|
2310
2555
|
for (const schPort of schematicPorts) {
|
|
@@ -2339,9 +2584,9 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
2339
2584
|
}
|
|
2340
2585
|
|
|
2341
2586
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
2342
|
-
import { applyToPoint as
|
|
2587
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
2343
2588
|
function createSvgObjectsFromSchVoltageProbe(probe, transform) {
|
|
2344
|
-
const [screenX, screenY] =
|
|
2589
|
+
const [screenX, screenY] = applyToPoint31(transform, [
|
|
2345
2590
|
probe.position.x,
|
|
2346
2591
|
probe.position.y
|
|
2347
2592
|
]);
|
|
@@ -2401,14 +2646,14 @@ function createSvgObjectsFromSchVoltageProbe(probe, transform) {
|
|
|
2401
2646
|
}
|
|
2402
2647
|
|
|
2403
2648
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
2404
|
-
import { applyToPoint as
|
|
2649
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
2405
2650
|
function createSvgObjectsFromSchDebugObject(debugObject, transform) {
|
|
2406
2651
|
if (debugObject.shape === "rect") {
|
|
2407
|
-
let [screenLeft, screenTop] =
|
|
2652
|
+
let [screenLeft, screenTop] = applyToPoint32(transform, [
|
|
2408
2653
|
debugObject.center.x - debugObject.size.width / 2,
|
|
2409
2654
|
debugObject.center.y - debugObject.size.height / 2
|
|
2410
2655
|
]);
|
|
2411
|
-
let [screenRight, screenBottom] =
|
|
2656
|
+
let [screenRight, screenBottom] = applyToPoint32(transform, [
|
|
2412
2657
|
debugObject.center.x + debugObject.size.width / 2,
|
|
2413
2658
|
debugObject.center.y + debugObject.size.height / 2
|
|
2414
2659
|
]);
|
|
@@ -2418,7 +2663,7 @@ function createSvgObjectsFromSchDebugObject(debugObject, transform) {
|
|
|
2418
2663
|
];
|
|
2419
2664
|
const width = Math.abs(screenRight - screenLeft);
|
|
2420
2665
|
const height = Math.abs(screenBottom - screenTop);
|
|
2421
|
-
const [screenCenterX, screenCenterY] =
|
|
2666
|
+
const [screenCenterX, screenCenterY] = applyToPoint32(transform, [
|
|
2422
2667
|
debugObject.center.x,
|
|
2423
2668
|
debugObject.center.y
|
|
2424
2669
|
]);
|
|
@@ -2464,11 +2709,11 @@ function createSvgObjectsFromSchDebugObject(debugObject, transform) {
|
|
|
2464
2709
|
];
|
|
2465
2710
|
}
|
|
2466
2711
|
if (debugObject.shape === "line") {
|
|
2467
|
-
const [screenStartX, screenStartY] =
|
|
2712
|
+
const [screenStartX, screenStartY] = applyToPoint32(transform, [
|
|
2468
2713
|
debugObject.start.x,
|
|
2469
2714
|
debugObject.start.y
|
|
2470
2715
|
]);
|
|
2471
|
-
const [screenEndX, screenEndY] =
|
|
2716
|
+
const [screenEndX, screenEndY] = applyToPoint32(transform, [
|
|
2472
2717
|
debugObject.end.x,
|
|
2473
2718
|
debugObject.end.y
|
|
2474
2719
|
]);
|
|
@@ -2518,7 +2763,7 @@ function createSvgObjectsFromSchDebugObject(debugObject, transform) {
|
|
|
2518
2763
|
}
|
|
2519
2764
|
|
|
2520
2765
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
2521
|
-
import { applyToPoint as
|
|
2766
|
+
import { applyToPoint as applyToPoint33 } from "transformation-matrix";
|
|
2522
2767
|
function createSchematicTrace(trace, transform) {
|
|
2523
2768
|
const edges = trace.edges;
|
|
2524
2769
|
if (edges.length === 0) return [];
|
|
@@ -2527,11 +2772,11 @@ function createSchematicTrace(trace, transform) {
|
|
|
2527
2772
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
2528
2773
|
const edge = edges[edgeIndex];
|
|
2529
2774
|
if (edge.is_crossing) continue;
|
|
2530
|
-
const [screenFromX, screenFromY] =
|
|
2775
|
+
const [screenFromX, screenFromY] = applyToPoint33(transform, [
|
|
2531
2776
|
edge.from.x,
|
|
2532
2777
|
edge.from.y
|
|
2533
2778
|
]);
|
|
2534
|
-
const [screenToX, screenToY] =
|
|
2779
|
+
const [screenToX, screenToY] = applyToPoint33(transform, [
|
|
2535
2780
|
edge.to.x,
|
|
2536
2781
|
edge.to.y
|
|
2537
2782
|
]);
|
|
@@ -2543,11 +2788,11 @@ function createSchematicTrace(trace, transform) {
|
|
|
2543
2788
|
}
|
|
2544
2789
|
for (const edge of edges) {
|
|
2545
2790
|
if (!edge.is_crossing) continue;
|
|
2546
|
-
const [screenFromX, screenFromY] =
|
|
2791
|
+
const [screenFromX, screenFromY] = applyToPoint33(transform, [
|
|
2547
2792
|
edge.from.x,
|
|
2548
2793
|
edge.from.y
|
|
2549
2794
|
]);
|
|
2550
|
-
const [screenToX, screenToY] =
|
|
2795
|
+
const [screenToX, screenToY] = applyToPoint33(transform, [
|
|
2551
2796
|
edge.to.x,
|
|
2552
2797
|
edge.to.y
|
|
2553
2798
|
]);
|
|
@@ -2623,7 +2868,7 @@ function createSchematicTrace(trace, transform) {
|
|
|
2623
2868
|
}
|
|
2624
2869
|
if (trace.junctions) {
|
|
2625
2870
|
for (const junction of trace.junctions) {
|
|
2626
|
-
const [screenX, screenY] =
|
|
2871
|
+
const [screenX, screenY] = applyToPoint33(transform, [
|
|
2627
2872
|
junction.x,
|
|
2628
2873
|
junction.y
|
|
2629
2874
|
]);
|
|
@@ -2658,7 +2903,7 @@ function createSchematicTrace(trace, transform) {
|
|
|
2658
2903
|
|
|
2659
2904
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
2660
2905
|
import {
|
|
2661
|
-
applyToPoint as
|
|
2906
|
+
applyToPoint as applyToPoint35,
|
|
2662
2907
|
compose as compose8,
|
|
2663
2908
|
rotate as rotate4,
|
|
2664
2909
|
scale as scale5,
|
|
@@ -3446,7 +3691,7 @@ var estimateTextWidth = (text) => {
|
|
|
3446
3691
|
|
|
3447
3692
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
3448
3693
|
import {
|
|
3449
|
-
applyToPoint as
|
|
3694
|
+
applyToPoint as applyToPoint34,
|
|
3450
3695
|
compose as compose7,
|
|
3451
3696
|
rotate as rotate3,
|
|
3452
3697
|
scale as scale4,
|
|
@@ -3566,7 +3811,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
3566
3811
|
x: symbolBounds.minX,
|
|
3567
3812
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
3568
3813
|
};
|
|
3569
|
-
const rotatedSymbolEnd =
|
|
3814
|
+
const rotatedSymbolEnd = applyToPoint34(rotationMatrix, symbolEndPoint);
|
|
3570
3815
|
const symbolToRealTransform = compose7(
|
|
3571
3816
|
translate7(
|
|
3572
3817
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
@@ -3576,11 +3821,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
3576
3821
|
scale4(1)
|
|
3577
3822
|
// Use full symbol size
|
|
3578
3823
|
);
|
|
3579
|
-
const [screenMinX, screenMinY] =
|
|
3824
|
+
const [screenMinX, screenMinY] = applyToPoint34(
|
|
3580
3825
|
compose7(realToScreenTransform, symbolToRealTransform),
|
|
3581
3826
|
[bounds.minX, bounds.minY]
|
|
3582
3827
|
);
|
|
3583
|
-
const [screenMaxX, screenMaxY] =
|
|
3828
|
+
const [screenMaxX, screenMaxY] = applyToPoint34(
|
|
3584
3829
|
compose7(realToScreenTransform, symbolToRealTransform),
|
|
3585
3830
|
[bounds.maxX, bounds.maxY]
|
|
3586
3831
|
);
|
|
@@ -3604,7 +3849,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
3604
3849
|
});
|
|
3605
3850
|
for (const path of symbolPaths) {
|
|
3606
3851
|
const symbolPath = path.points.map((p, i) => {
|
|
3607
|
-
const [x, y] =
|
|
3852
|
+
const [x, y] = applyToPoint34(
|
|
3608
3853
|
compose7(realToScreenTransform, symbolToRealTransform),
|
|
3609
3854
|
[p.x, p.y]
|
|
3610
3855
|
);
|
|
@@ -3624,7 +3869,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
3624
3869
|
});
|
|
3625
3870
|
}
|
|
3626
3871
|
for (const text of symbolTexts) {
|
|
3627
|
-
const screenTextPos =
|
|
3872
|
+
const screenTextPos = applyToPoint34(
|
|
3628
3873
|
compose7(realToScreenTransform, symbolToRealTransform),
|
|
3629
3874
|
text
|
|
3630
3875
|
);
|
|
@@ -3666,7 +3911,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
3666
3911
|
});
|
|
3667
3912
|
}
|
|
3668
3913
|
for (const box of symbolBoxes) {
|
|
3669
|
-
const screenBoxPos =
|
|
3914
|
+
const screenBoxPos = applyToPoint34(
|
|
3670
3915
|
compose7(realToScreenTransform, symbolToRealTransform),
|
|
3671
3916
|
box
|
|
3672
3917
|
);
|
|
@@ -3689,7 +3934,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
3689
3934
|
});
|
|
3690
3935
|
}
|
|
3691
3936
|
for (const circle of symbolCircles) {
|
|
3692
|
-
const screenCirclePos =
|
|
3937
|
+
const screenCirclePos = applyToPoint34(
|
|
3693
3938
|
compose7(realToScreenTransform, symbolToRealTransform),
|
|
3694
3939
|
circle
|
|
3695
3940
|
);
|
|
@@ -3728,14 +3973,14 @@ var createSvgObjectsForSchNetLabel = (schNetLabel, realToScreenTransform) => {
|
|
|
3728
3973
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
3729
3974
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
3730
3975
|
const textWidthFSR = estimateTextWidth(schNetLabel.text || "");
|
|
3731
|
-
const screenCenter =
|
|
3976
|
+
const screenCenter = applyToPoint35(realToScreenTransform, schNetLabel.center);
|
|
3732
3977
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
3733
3978
|
schNetLabel.anchor_side
|
|
3734
3979
|
);
|
|
3735
3980
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
3736
3981
|
screenTextGrowthVec.y *= -1;
|
|
3737
3982
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + END_PADDING_FSR;
|
|
3738
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
3983
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint35(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
3739
3984
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
3740
3985
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
3741
3986
|
};
|
|
@@ -3776,7 +4021,7 @@ var createSvgObjectsForSchNetLabel = (schNetLabel, realToScreenTransform) => {
|
|
|
3776
4021
|
y: -0.6
|
|
3777
4022
|
}
|
|
3778
4023
|
].map(
|
|
3779
|
-
(fontRelativePoint) =>
|
|
4024
|
+
(fontRelativePoint) => applyToPoint35(
|
|
3780
4025
|
compose8(
|
|
3781
4026
|
realToScreenTransform,
|
|
3782
4027
|
translate8(realAnchorPosition.x, realAnchorPosition.y),
|