circuit-to-svg 0.0.102 → 0.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +235 -90
- 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;
|
|
@@ -652,7 +775,7 @@ import {
|
|
|
652
775
|
getFullConnectivityMapFromCircuitJson
|
|
653
776
|
} from "circuit-json-to-connectivity-map";
|
|
654
777
|
import "svgson";
|
|
655
|
-
import { applyToPoint as
|
|
778
|
+
import { applyToPoint as applyToPoint15 } from "transformation-matrix";
|
|
656
779
|
|
|
657
780
|
// lib/pcb/create-svg-objects-from-pcb-rats-nest/get-element-position.ts
|
|
658
781
|
import { su } from "@tscircuit/soup-util";
|
|
@@ -731,11 +854,11 @@ function createSvgObjectsForRatsNest(circuitJson, transform) {
|
|
|
731
854
|
});
|
|
732
855
|
const svgObjects = [];
|
|
733
856
|
for (const line of ratsNestLines) {
|
|
734
|
-
const transformedStart =
|
|
857
|
+
const transformedStart = applyToPoint15(transform, [
|
|
735
858
|
line.startPoint.x,
|
|
736
859
|
line.startPoint.y
|
|
737
860
|
]);
|
|
738
|
-
const transformedEnd =
|
|
861
|
+
const transformedEnd = applyToPoint15(transform, [
|
|
739
862
|
line.endPoint.x,
|
|
740
863
|
line.endPoint.y
|
|
741
864
|
]);
|
|
@@ -788,6 +911,8 @@ function convertCircuitJsonToPcbSvg(soup, options) {
|
|
|
788
911
|
updateBounds({ x: item.x, y: item.y }, 0, 0);
|
|
789
912
|
} else if ("route" in item) {
|
|
790
913
|
updateTraceBounds(item.route);
|
|
914
|
+
} else if (item.type === "pcb_silkscreen_text" || item.type === "pcb_silkscreen_rect" || item.type === "pcb_silkscreen_circle" || item.type === "pcb_silkscreen_line") {
|
|
915
|
+
updateSilkscreenBounds(item);
|
|
791
916
|
}
|
|
792
917
|
}
|
|
793
918
|
const padding = 1;
|
|
@@ -907,6 +1032,20 @@ function convertCircuitJsonToPcbSvg(soup, options) {
|
|
|
907
1032
|
maxY = Math.max(maxY, point.y);
|
|
908
1033
|
}
|
|
909
1034
|
}
|
|
1035
|
+
function updateSilkscreenBounds(item) {
|
|
1036
|
+
if (item.type === "pcb_silkscreen_text") {
|
|
1037
|
+
updateBounds(item.anchor_position, 0, 0);
|
|
1038
|
+
} else if (item.type === "pcb_silkscreen_path") {
|
|
1039
|
+
updateTraceBounds(item.route);
|
|
1040
|
+
} else if (item.type === "pcb_silkscreen_rect") {
|
|
1041
|
+
updateBounds(item.center, item.width, item.height);
|
|
1042
|
+
} else if (item.type === "pcb_silkscreen_circle") {
|
|
1043
|
+
updateBounds(item.center, item.radius * 2, item.radius * 2);
|
|
1044
|
+
} else if (item.type === "pcb_silkscreen_line") {
|
|
1045
|
+
updateBounds({ x: item.x1, y: item.y1 }, 0, 0);
|
|
1046
|
+
updateBounds({ x: item.x2, y: item.y2 }, 0, 0);
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
910
1049
|
}
|
|
911
1050
|
function createSvgObjects(elm, transform, soup, shouldDrawErrors) {
|
|
912
1051
|
switch (elm.type) {
|
|
@@ -929,6 +1068,12 @@ function createSvgObjects(elm, transform, soup, shouldDrawErrors) {
|
|
|
929
1068
|
return createSvgObjectsFromSmtPad(elm, transform);
|
|
930
1069
|
case "pcb_silkscreen_text":
|
|
931
1070
|
return createSvgObjectsFromPcbSilkscreenText(elm, transform);
|
|
1071
|
+
case "pcb_silkscreen_rect":
|
|
1072
|
+
return createSvgObjectsFromPcbSilkscreenRect(elm, transform);
|
|
1073
|
+
case "pcb_silkscreen_circle":
|
|
1074
|
+
return createSvgObjectsFromPcbSilkscreenCircle(elm, transform);
|
|
1075
|
+
case "pcb_silkscreen_line":
|
|
1076
|
+
return createSvgObjectsFromPcbSilkscreenLine(elm, transform);
|
|
932
1077
|
case "pcb_fabrication_note_path":
|
|
933
1078
|
return createSvgObjectsFromPcbFabricationNotePath(elm, transform);
|
|
934
1079
|
case "pcb_fabrication_note_text":
|
|
@@ -945,7 +1090,7 @@ function createSvgObjects(elm, transform, soup, shouldDrawErrors) {
|
|
|
945
1090
|
}
|
|
946
1091
|
function createSvgObjectsFromPcbComponent(component, transform) {
|
|
947
1092
|
const { center, width, height, rotation = 0 } = component;
|
|
948
|
-
const [x, y] =
|
|
1093
|
+
const [x, y] = applyToPoint16(transform, [center.x, center.y]);
|
|
949
1094
|
const scaledWidth = width * Math.abs(transform.a);
|
|
950
1095
|
const scaledHeight = height * Math.abs(transform.d);
|
|
951
1096
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
@@ -980,8 +1125,8 @@ function createSvgObjectsFromPcbComponent(component, transform) {
|
|
|
980
1125
|
};
|
|
981
1126
|
}
|
|
982
1127
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
983
|
-
const [x1, y1] =
|
|
984
|
-
const [x2, y2] =
|
|
1128
|
+
const [x1, y1] = applyToPoint16(transform, [minX, minY]);
|
|
1129
|
+
const [x2, y2] = applyToPoint16(transform, [maxX, maxY]);
|
|
985
1130
|
const width = Math.abs(x2 - x1);
|
|
986
1131
|
const height = Math.abs(y2 - y1);
|
|
987
1132
|
const x = Math.min(x1, x2);
|
|
@@ -1006,14 +1151,14 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
1006
1151
|
import { stringify as stringify2 } from "svgson";
|
|
1007
1152
|
import { su as su3 } from "@tscircuit/soup-util";
|
|
1008
1153
|
import {
|
|
1009
|
-
applyToPoint as
|
|
1154
|
+
applyToPoint as applyToPoint20,
|
|
1010
1155
|
compose as compose4,
|
|
1011
1156
|
scale as scale2,
|
|
1012
1157
|
translate as translate4
|
|
1013
1158
|
} from "transformation-matrix";
|
|
1014
1159
|
|
|
1015
1160
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
1016
|
-
import { applyToPoint as
|
|
1161
|
+
import { applyToPoint as applyToPoint17 } from "transformation-matrix";
|
|
1017
1162
|
var DEFAULT_BOARD_STYLE = {
|
|
1018
1163
|
fill: "none",
|
|
1019
1164
|
stroke: "rgb(0,0,0)",
|
|
@@ -1025,25 +1170,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
1025
1170
|
let path;
|
|
1026
1171
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
1027
1172
|
path = outline.map((point, index) => {
|
|
1028
|
-
const [x, y] =
|
|
1173
|
+
const [x, y] = applyToPoint17(transform, [point.x, point.y]);
|
|
1029
1174
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
1030
1175
|
}).join(" ");
|
|
1031
1176
|
} else {
|
|
1032
1177
|
const halfWidth = width / 2;
|
|
1033
1178
|
const halfHeight = height / 2;
|
|
1034
|
-
const topLeft =
|
|
1179
|
+
const topLeft = applyToPoint17(transform, [
|
|
1035
1180
|
center.x - halfWidth,
|
|
1036
1181
|
center.y - halfHeight
|
|
1037
1182
|
]);
|
|
1038
|
-
const topRight =
|
|
1183
|
+
const topRight = applyToPoint17(transform, [
|
|
1039
1184
|
center.x + halfWidth,
|
|
1040
1185
|
center.y - halfHeight
|
|
1041
1186
|
]);
|
|
1042
|
-
const bottomRight =
|
|
1187
|
+
const bottomRight = applyToPoint17(transform, [
|
|
1043
1188
|
center.x + halfWidth,
|
|
1044
1189
|
center.y + halfHeight
|
|
1045
1190
|
]);
|
|
1046
|
-
const bottomLeft =
|
|
1191
|
+
const bottomLeft = applyToPoint17(transform, [
|
|
1047
1192
|
center.x - halfWidth,
|
|
1048
1193
|
center.y + halfHeight
|
|
1049
1194
|
]);
|
|
@@ -1069,7 +1214,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
1069
1214
|
}
|
|
1070
1215
|
|
|
1071
1216
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
1072
|
-
import { applyToPoint as
|
|
1217
|
+
import { applyToPoint as applyToPoint19 } from "transformation-matrix";
|
|
1073
1218
|
|
|
1074
1219
|
// lib/utils/get-sch-font-size.ts
|
|
1075
1220
|
import "transformation-matrix";
|
|
@@ -1083,8 +1228,8 @@ var getSchScreenFontSize = (transform, textType) => {
|
|
|
1083
1228
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
1084
1229
|
function createSvgObjectsFromAssemblyComponent(component, transform, firstPin, name) {
|
|
1085
1230
|
const { center, width, height, rotation = 0 } = component;
|
|
1086
|
-
const [x, y] =
|
|
1087
|
-
const [pinX, pinY] =
|
|
1231
|
+
const [x, y] = applyToPoint19(transform, [center.x, center.y]);
|
|
1232
|
+
const [pinX, pinY] = applyToPoint19(transform, [firstPin.x, firstPin.y]);
|
|
1088
1233
|
const scaledWidth = width * Math.abs(transform.a);
|
|
1089
1234
|
const scaledHeight = height * Math.abs(transform.d);
|
|
1090
1235
|
return {
|
|
@@ -1320,8 +1465,8 @@ function createSvgObjects2(elm, transform, soup) {
|
|
|
1320
1465
|
}
|
|
1321
1466
|
}
|
|
1322
1467
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
1323
|
-
const [x1, y1] =
|
|
1324
|
-
const [x2, y2] =
|
|
1468
|
+
const [x1, y1] = applyToPoint20(transform, [minX, minY]);
|
|
1469
|
+
const [x2, y2] = applyToPoint20(transform, [maxX, maxY]);
|
|
1325
1470
|
const width = Math.abs(x2 - x1);
|
|
1326
1471
|
const height = Math.abs(y2 - y1);
|
|
1327
1472
|
const x = Math.min(x1, x2);
|
|
@@ -1586,14 +1731,14 @@ import {
|
|
|
1586
1731
|
} from "transformation-matrix";
|
|
1587
1732
|
|
|
1588
1733
|
// lib/sch/draw-schematic-grid.ts
|
|
1589
|
-
import { applyToPoint as
|
|
1734
|
+
import { applyToPoint as applyToPoint21 } from "transformation-matrix";
|
|
1590
1735
|
function drawSchematicGrid(params) {
|
|
1591
1736
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
1592
1737
|
const cellSize = params.cellSize ?? 1;
|
|
1593
1738
|
const labelCells = params.labelCells ?? false;
|
|
1594
1739
|
const gridLines = [];
|
|
1595
1740
|
const transformPoint = (x, y) => {
|
|
1596
|
-
const [transformedX, transformedY] =
|
|
1741
|
+
const [transformedX, transformedY] = applyToPoint21(params.transform, [x, y]);
|
|
1597
1742
|
return { x: transformedX, y: transformedY };
|
|
1598
1743
|
};
|
|
1599
1744
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -1674,15 +1819,15 @@ function drawSchematicGrid(params) {
|
|
|
1674
1819
|
}
|
|
1675
1820
|
|
|
1676
1821
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
1677
|
-
import { applyToPoint as
|
|
1822
|
+
import { applyToPoint as applyToPoint22 } from "transformation-matrix";
|
|
1678
1823
|
function drawSchematicLabeledPoints(params) {
|
|
1679
1824
|
const { points, transform } = params;
|
|
1680
1825
|
const labeledPointsGroup = [];
|
|
1681
1826
|
for (const point of points) {
|
|
1682
|
-
const [x1, y1] =
|
|
1683
|
-
const [x2, y2] =
|
|
1684
|
-
const [x3, y3] =
|
|
1685
|
-
const [x4, y4] =
|
|
1827
|
+
const [x1, y1] = applyToPoint22(transform, [point.x - 0.1, point.y - 0.1]);
|
|
1828
|
+
const [x2, y2] = applyToPoint22(transform, [point.x + 0.1, point.y + 0.1]);
|
|
1829
|
+
const [x3, y3] = applyToPoint22(transform, [point.x - 0.1, point.y + 0.1]);
|
|
1830
|
+
const [x4, y4] = applyToPoint22(transform, [point.x + 0.1, point.y - 0.1]);
|
|
1686
1831
|
labeledPointsGroup.push({
|
|
1687
1832
|
name: "path",
|
|
1688
1833
|
type: "element",
|
|
@@ -1693,7 +1838,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
1693
1838
|
"stroke-opacity": "0.7"
|
|
1694
1839
|
}
|
|
1695
1840
|
});
|
|
1696
|
-
const [labelX, labelY] =
|
|
1841
|
+
const [labelX, labelY] = applyToPoint22(transform, [
|
|
1697
1842
|
point.x + 0.15,
|
|
1698
1843
|
point.y - 0.15
|
|
1699
1844
|
]);
|
|
@@ -1796,7 +1941,7 @@ import { su as su4 } from "@tscircuit/soup-util";
|
|
|
1796
1941
|
import { symbols } from "schematic-symbols";
|
|
1797
1942
|
import "svgson";
|
|
1798
1943
|
import {
|
|
1799
|
-
applyToPoint as
|
|
1944
|
+
applyToPoint as applyToPoint24,
|
|
1800
1945
|
compose as compose6
|
|
1801
1946
|
} from "transformation-matrix";
|
|
1802
1947
|
|
|
@@ -1880,13 +2025,13 @@ function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
|
1880
2025
|
}
|
|
1881
2026
|
|
|
1882
2027
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
1883
|
-
import { applyToPoint as
|
|
2028
|
+
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
1884
2029
|
var createSvgSchErrorText = ({
|
|
1885
2030
|
text,
|
|
1886
2031
|
realCenter,
|
|
1887
2032
|
realToScreenTransform
|
|
1888
2033
|
}) => {
|
|
1889
|
-
const screenCenter =
|
|
2034
|
+
const screenCenter = applyToPoint23(realToScreenTransform, realCenter);
|
|
1890
2035
|
return {
|
|
1891
2036
|
type: "element",
|
|
1892
2037
|
name: "text",
|
|
@@ -1976,11 +2121,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
1976
2121
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
1977
2122
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
1978
2123
|
};
|
|
1979
|
-
const [screenMinX, screenMinY] =
|
|
2124
|
+
const [screenMinX, screenMinY] = applyToPoint24(
|
|
1980
2125
|
compose6(realToScreenTransform, transformFromSymbolToReal),
|
|
1981
2126
|
[bounds.minX, bounds.minY]
|
|
1982
2127
|
);
|
|
1983
|
-
const [screenMaxX, screenMaxY] =
|
|
2128
|
+
const [screenMaxX, screenMaxY] = applyToPoint24(
|
|
1984
2129
|
compose6(realToScreenTransform, transformFromSymbolToReal),
|
|
1985
2130
|
[bounds.maxX, bounds.maxY]
|
|
1986
2131
|
);
|
|
@@ -2009,7 +2154,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2009
2154
|
name: "path",
|
|
2010
2155
|
attributes: {
|
|
2011
2156
|
d: points.map((p, i) => {
|
|
2012
|
-
const [x, y] =
|
|
2157
|
+
const [x, y] = applyToPoint24(
|
|
2013
2158
|
compose6(realToScreenTransform, transformFromSymbolToReal),
|
|
2014
2159
|
[p.x, p.y]
|
|
2015
2160
|
);
|
|
@@ -2024,7 +2169,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2024
2169
|
});
|
|
2025
2170
|
}
|
|
2026
2171
|
for (const text of texts) {
|
|
2027
|
-
const screenTextPos =
|
|
2172
|
+
const screenTextPos = applyToPoint24(
|
|
2028
2173
|
compose6(realToScreenTransform, transformFromSymbolToReal),
|
|
2029
2174
|
text
|
|
2030
2175
|
);
|
|
@@ -2070,7 +2215,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2070
2215
|
});
|
|
2071
2216
|
}
|
|
2072
2217
|
for (const box of boxes) {
|
|
2073
|
-
const screenBoxPos =
|
|
2218
|
+
const screenBoxPos = applyToPoint24(
|
|
2074
2219
|
compose6(realToScreenTransform, transformFromSymbolToReal),
|
|
2075
2220
|
box
|
|
2076
2221
|
);
|
|
@@ -2093,7 +2238,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2093
2238
|
});
|
|
2094
2239
|
}
|
|
2095
2240
|
for (const port of symbol.ports) {
|
|
2096
|
-
const screenPortPos =
|
|
2241
|
+
const screenPortPos = applyToPoint24(
|
|
2097
2242
|
compose6(realToScreenTransform, transformFromSymbolToReal),
|
|
2098
2243
|
port
|
|
2099
2244
|
);
|
|
@@ -2119,14 +2264,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
2119
2264
|
import { su as su7 } from "@tscircuit/soup-util";
|
|
2120
2265
|
import "schematic-symbols";
|
|
2121
2266
|
import "svgson";
|
|
2122
|
-
import { applyToPoint as
|
|
2267
|
+
import { applyToPoint as applyToPoint30 } from "transformation-matrix";
|
|
2123
2268
|
|
|
2124
2269
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
2125
2270
|
import "transformation-matrix";
|
|
2126
2271
|
import "@tscircuit/soup-util";
|
|
2127
2272
|
|
|
2128
2273
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
2129
|
-
import { applyToPoint as
|
|
2274
|
+
import { applyToPoint as applyToPoint25 } from "transformation-matrix";
|
|
2130
2275
|
import { su as su5 } from "@tscircuit/soup-util";
|
|
2131
2276
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
2132
2277
|
var createSvgObjectsForSchPortBoxLine = ({
|
|
@@ -2156,8 +2301,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
2156
2301
|
realEdgePos.y += realPinLineLength;
|
|
2157
2302
|
break;
|
|
2158
2303
|
}
|
|
2159
|
-
const screenSchPortPos =
|
|
2160
|
-
const screenRealEdgePos =
|
|
2304
|
+
const screenSchPortPos = applyToPoint25(transform, schPort.center);
|
|
2305
|
+
const screenRealEdgePos = applyToPoint25(transform, realEdgePos);
|
|
2161
2306
|
const realLineEnd = { ...schPort.center };
|
|
2162
2307
|
switch (schPort.side_of_component) {
|
|
2163
2308
|
case "left":
|
|
@@ -2173,7 +2318,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
2173
2318
|
realLineEnd.y += PIN_CIRCLE_RADIUS_MM;
|
|
2174
2319
|
break;
|
|
2175
2320
|
}
|
|
2176
|
-
const screenLineEnd =
|
|
2321
|
+
const screenLineEnd = applyToPoint25(transform, realLineEnd);
|
|
2177
2322
|
svgObjects.push({
|
|
2178
2323
|
name: "line",
|
|
2179
2324
|
type: "element",
|
|
@@ -2220,7 +2365,7 @@ var getUnitVectorFromOutsideToEdge = (side) => {
|
|
|
2220
2365
|
};
|
|
2221
2366
|
|
|
2222
2367
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
2223
|
-
import { applyToPoint as
|
|
2368
|
+
import { applyToPoint as applyToPoint26 } from "transformation-matrix";
|
|
2224
2369
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
2225
2370
|
const svgObjects = [];
|
|
2226
2371
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -2238,7 +2383,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
2238
2383
|
} else {
|
|
2239
2384
|
realPinNumberPos.y += 0.02;
|
|
2240
2385
|
}
|
|
2241
|
-
const screenPinNumberTextPos =
|
|
2386
|
+
const screenPinNumberTextPos = applyToPoint26(transform, realPinNumberPos);
|
|
2242
2387
|
svgObjects.push({
|
|
2243
2388
|
name: "text",
|
|
2244
2389
|
type: "element",
|
|
@@ -2268,7 +2413,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
2268
2413
|
};
|
|
2269
2414
|
|
|
2270
2415
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
2271
|
-
import { applyToPoint as
|
|
2416
|
+
import { applyToPoint as applyToPoint27 } from "transformation-matrix";
|
|
2272
2417
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
2273
2418
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
2274
2419
|
const svgObjects = [];
|
|
@@ -2282,7 +2427,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
2282
2427
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
2283
2428
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
2284
2429
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
2285
|
-
const screenPinNumberTextPos =
|
|
2430
|
+
const screenPinNumberTextPos = applyToPoint27(transform, realPinNumberPos);
|
|
2286
2431
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
2287
2432
|
if (!label) return [];
|
|
2288
2433
|
svgObjects.push({
|
|
@@ -2324,9 +2469,9 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
2324
2469
|
};
|
|
2325
2470
|
|
|
2326
2471
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
2327
|
-
import { applyToPoint as
|
|
2472
|
+
import { applyToPoint as applyToPoint29 } from "transformation-matrix";
|
|
2328
2473
|
var createSvgSchText = (elm, transform) => {
|
|
2329
|
-
const center =
|
|
2474
|
+
const center = applyToPoint29(transform, elm.position);
|
|
2330
2475
|
const textAnchorMap = {
|
|
2331
2476
|
center: "middle",
|
|
2332
2477
|
left: "start",
|
|
@@ -2374,11 +2519,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
2374
2519
|
circuitJson
|
|
2375
2520
|
}) => {
|
|
2376
2521
|
const svgObjects = [];
|
|
2377
|
-
const componentScreenTopLeft =
|
|
2522
|
+
const componentScreenTopLeft = applyToPoint30(transform, {
|
|
2378
2523
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
2379
2524
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
2380
2525
|
});
|
|
2381
|
-
const componentScreenBottomRight =
|
|
2526
|
+
const componentScreenBottomRight = applyToPoint30(transform, {
|
|
2382
2527
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
2383
2528
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
2384
2529
|
});
|
|
@@ -2455,9 +2600,9 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
2455
2600
|
}
|
|
2456
2601
|
|
|
2457
2602
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
2458
|
-
import { applyToPoint as
|
|
2603
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
2459
2604
|
function createSvgObjectsFromSchVoltageProbe(probe, transform) {
|
|
2460
|
-
const [screenX, screenY] =
|
|
2605
|
+
const [screenX, screenY] = applyToPoint31(transform, [
|
|
2461
2606
|
probe.position.x,
|
|
2462
2607
|
probe.position.y
|
|
2463
2608
|
]);
|
|
@@ -2517,14 +2662,14 @@ function createSvgObjectsFromSchVoltageProbe(probe, transform) {
|
|
|
2517
2662
|
}
|
|
2518
2663
|
|
|
2519
2664
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
2520
|
-
import { applyToPoint as
|
|
2665
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
2521
2666
|
function createSvgObjectsFromSchDebugObject(debugObject, transform) {
|
|
2522
2667
|
if (debugObject.shape === "rect") {
|
|
2523
|
-
let [screenLeft, screenTop] =
|
|
2668
|
+
let [screenLeft, screenTop] = applyToPoint32(transform, [
|
|
2524
2669
|
debugObject.center.x - debugObject.size.width / 2,
|
|
2525
2670
|
debugObject.center.y - debugObject.size.height / 2
|
|
2526
2671
|
]);
|
|
2527
|
-
let [screenRight, screenBottom] =
|
|
2672
|
+
let [screenRight, screenBottom] = applyToPoint32(transform, [
|
|
2528
2673
|
debugObject.center.x + debugObject.size.width / 2,
|
|
2529
2674
|
debugObject.center.y + debugObject.size.height / 2
|
|
2530
2675
|
]);
|
|
@@ -2534,7 +2679,7 @@ function createSvgObjectsFromSchDebugObject(debugObject, transform) {
|
|
|
2534
2679
|
];
|
|
2535
2680
|
const width = Math.abs(screenRight - screenLeft);
|
|
2536
2681
|
const height = Math.abs(screenBottom - screenTop);
|
|
2537
|
-
const [screenCenterX, screenCenterY] =
|
|
2682
|
+
const [screenCenterX, screenCenterY] = applyToPoint32(transform, [
|
|
2538
2683
|
debugObject.center.x,
|
|
2539
2684
|
debugObject.center.y
|
|
2540
2685
|
]);
|
|
@@ -2580,11 +2725,11 @@ function createSvgObjectsFromSchDebugObject(debugObject, transform) {
|
|
|
2580
2725
|
];
|
|
2581
2726
|
}
|
|
2582
2727
|
if (debugObject.shape === "line") {
|
|
2583
|
-
const [screenStartX, screenStartY] =
|
|
2728
|
+
const [screenStartX, screenStartY] = applyToPoint32(transform, [
|
|
2584
2729
|
debugObject.start.x,
|
|
2585
2730
|
debugObject.start.y
|
|
2586
2731
|
]);
|
|
2587
|
-
const [screenEndX, screenEndY] =
|
|
2732
|
+
const [screenEndX, screenEndY] = applyToPoint32(transform, [
|
|
2588
2733
|
debugObject.end.x,
|
|
2589
2734
|
debugObject.end.y
|
|
2590
2735
|
]);
|
|
@@ -2634,7 +2779,7 @@ function createSvgObjectsFromSchDebugObject(debugObject, transform) {
|
|
|
2634
2779
|
}
|
|
2635
2780
|
|
|
2636
2781
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
2637
|
-
import { applyToPoint as
|
|
2782
|
+
import { applyToPoint as applyToPoint33 } from "transformation-matrix";
|
|
2638
2783
|
function createSchematicTrace(trace, transform) {
|
|
2639
2784
|
const edges = trace.edges;
|
|
2640
2785
|
if (edges.length === 0) return [];
|
|
@@ -2643,11 +2788,11 @@ function createSchematicTrace(trace, transform) {
|
|
|
2643
2788
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
2644
2789
|
const edge = edges[edgeIndex];
|
|
2645
2790
|
if (edge.is_crossing) continue;
|
|
2646
|
-
const [screenFromX, screenFromY] =
|
|
2791
|
+
const [screenFromX, screenFromY] = applyToPoint33(transform, [
|
|
2647
2792
|
edge.from.x,
|
|
2648
2793
|
edge.from.y
|
|
2649
2794
|
]);
|
|
2650
|
-
const [screenToX, screenToY] =
|
|
2795
|
+
const [screenToX, screenToY] = applyToPoint33(transform, [
|
|
2651
2796
|
edge.to.x,
|
|
2652
2797
|
edge.to.y
|
|
2653
2798
|
]);
|
|
@@ -2659,11 +2804,11 @@ function createSchematicTrace(trace, transform) {
|
|
|
2659
2804
|
}
|
|
2660
2805
|
for (const edge of edges) {
|
|
2661
2806
|
if (!edge.is_crossing) continue;
|
|
2662
|
-
const [screenFromX, screenFromY] =
|
|
2807
|
+
const [screenFromX, screenFromY] = applyToPoint33(transform, [
|
|
2663
2808
|
edge.from.x,
|
|
2664
2809
|
edge.from.y
|
|
2665
2810
|
]);
|
|
2666
|
-
const [screenToX, screenToY] =
|
|
2811
|
+
const [screenToX, screenToY] = applyToPoint33(transform, [
|
|
2667
2812
|
edge.to.x,
|
|
2668
2813
|
edge.to.y
|
|
2669
2814
|
]);
|
|
@@ -2739,7 +2884,7 @@ function createSchematicTrace(trace, transform) {
|
|
|
2739
2884
|
}
|
|
2740
2885
|
if (trace.junctions) {
|
|
2741
2886
|
for (const junction of trace.junctions) {
|
|
2742
|
-
const [screenX, screenY] =
|
|
2887
|
+
const [screenX, screenY] = applyToPoint33(transform, [
|
|
2743
2888
|
junction.x,
|
|
2744
2889
|
junction.y
|
|
2745
2890
|
]);
|
|
@@ -2774,7 +2919,7 @@ function createSchematicTrace(trace, transform) {
|
|
|
2774
2919
|
|
|
2775
2920
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
2776
2921
|
import {
|
|
2777
|
-
applyToPoint as
|
|
2922
|
+
applyToPoint as applyToPoint35,
|
|
2778
2923
|
compose as compose8,
|
|
2779
2924
|
rotate as rotate4,
|
|
2780
2925
|
scale as scale5,
|
|
@@ -3562,7 +3707,7 @@ var estimateTextWidth = (text) => {
|
|
|
3562
3707
|
|
|
3563
3708
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
3564
3709
|
import {
|
|
3565
|
-
applyToPoint as
|
|
3710
|
+
applyToPoint as applyToPoint34,
|
|
3566
3711
|
compose as compose7,
|
|
3567
3712
|
rotate as rotate3,
|
|
3568
3713
|
scale as scale4,
|
|
@@ -3682,7 +3827,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
3682
3827
|
x: symbolBounds.minX,
|
|
3683
3828
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
3684
3829
|
};
|
|
3685
|
-
const rotatedSymbolEnd =
|
|
3830
|
+
const rotatedSymbolEnd = applyToPoint34(rotationMatrix, symbolEndPoint);
|
|
3686
3831
|
const symbolToRealTransform = compose7(
|
|
3687
3832
|
translate7(
|
|
3688
3833
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
@@ -3692,11 +3837,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
3692
3837
|
scale4(1)
|
|
3693
3838
|
// Use full symbol size
|
|
3694
3839
|
);
|
|
3695
|
-
const [screenMinX, screenMinY] =
|
|
3840
|
+
const [screenMinX, screenMinY] = applyToPoint34(
|
|
3696
3841
|
compose7(realToScreenTransform, symbolToRealTransform),
|
|
3697
3842
|
[bounds.minX, bounds.minY]
|
|
3698
3843
|
);
|
|
3699
|
-
const [screenMaxX, screenMaxY] =
|
|
3844
|
+
const [screenMaxX, screenMaxY] = applyToPoint34(
|
|
3700
3845
|
compose7(realToScreenTransform, symbolToRealTransform),
|
|
3701
3846
|
[bounds.maxX, bounds.maxY]
|
|
3702
3847
|
);
|
|
@@ -3720,7 +3865,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
3720
3865
|
});
|
|
3721
3866
|
for (const path of symbolPaths) {
|
|
3722
3867
|
const symbolPath = path.points.map((p, i) => {
|
|
3723
|
-
const [x, y] =
|
|
3868
|
+
const [x, y] = applyToPoint34(
|
|
3724
3869
|
compose7(realToScreenTransform, symbolToRealTransform),
|
|
3725
3870
|
[p.x, p.y]
|
|
3726
3871
|
);
|
|
@@ -3740,7 +3885,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
3740
3885
|
});
|
|
3741
3886
|
}
|
|
3742
3887
|
for (const text of symbolTexts) {
|
|
3743
|
-
const screenTextPos =
|
|
3888
|
+
const screenTextPos = applyToPoint34(
|
|
3744
3889
|
compose7(realToScreenTransform, symbolToRealTransform),
|
|
3745
3890
|
text
|
|
3746
3891
|
);
|
|
@@ -3782,7 +3927,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
3782
3927
|
});
|
|
3783
3928
|
}
|
|
3784
3929
|
for (const box of symbolBoxes) {
|
|
3785
|
-
const screenBoxPos =
|
|
3930
|
+
const screenBoxPos = applyToPoint34(
|
|
3786
3931
|
compose7(realToScreenTransform, symbolToRealTransform),
|
|
3787
3932
|
box
|
|
3788
3933
|
);
|
|
@@ -3805,7 +3950,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransfo
|
|
|
3805
3950
|
});
|
|
3806
3951
|
}
|
|
3807
3952
|
for (const circle of symbolCircles) {
|
|
3808
|
-
const screenCirclePos =
|
|
3953
|
+
const screenCirclePos = applyToPoint34(
|
|
3809
3954
|
compose7(realToScreenTransform, symbolToRealTransform),
|
|
3810
3955
|
circle
|
|
3811
3956
|
);
|
|
@@ -3844,14 +3989,14 @@ var createSvgObjectsForSchNetLabel = (schNetLabel, realToScreenTransform) => {
|
|
|
3844
3989
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
3845
3990
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
3846
3991
|
const textWidthFSR = estimateTextWidth(schNetLabel.text || "");
|
|
3847
|
-
const screenCenter =
|
|
3992
|
+
const screenCenter = applyToPoint35(realToScreenTransform, schNetLabel.center);
|
|
3848
3993
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
3849
3994
|
schNetLabel.anchor_side
|
|
3850
3995
|
);
|
|
3851
3996
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
3852
3997
|
screenTextGrowthVec.y *= -1;
|
|
3853
3998
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + END_PADDING_FSR;
|
|
3854
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
3999
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint35(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
3855
4000
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
3856
4001
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
3857
4002
|
};
|
|
@@ -3892,7 +4037,7 @@ var createSvgObjectsForSchNetLabel = (schNetLabel, realToScreenTransform) => {
|
|
|
3892
4037
|
y: -0.6
|
|
3893
4038
|
}
|
|
3894
4039
|
].map(
|
|
3895
|
-
(fontRelativePoint) =>
|
|
4040
|
+
(fontRelativePoint) => applyToPoint35(
|
|
3896
4041
|
compose8(
|
|
3897
4042
|
realToScreenTransform,
|
|
3898
4043
|
translate8(realAnchorPosition.x, realAnchorPosition.y),
|