circuit-to-svg 0.0.263 → 0.0.264
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 +3 -0
- package/dist/index.js +500 -176
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { distance } from "circuit-json";
|
|
3
3
|
import { stringify } from "svgson";
|
|
4
4
|
import {
|
|
5
|
-
applyToPoint as
|
|
5
|
+
applyToPoint as applyToPoint32,
|
|
6
6
|
compose as compose5,
|
|
7
7
|
scale as scale2,
|
|
8
8
|
translate as translate5
|
|
@@ -1953,7 +1953,7 @@ import {
|
|
|
1953
1953
|
toString as matrixToString2
|
|
1954
1954
|
} from "transformation-matrix";
|
|
1955
1955
|
function createSvgObjectsFromPcbSilkscreenText(pcbSilkscreenText, ctx) {
|
|
1956
|
-
const { transform, layer: layerFilter, colorMap: colorMap2 } = ctx;
|
|
1956
|
+
const { transform, layer: layerFilter, colorMap: colorMap2, circuitJson } = ctx;
|
|
1957
1957
|
const {
|
|
1958
1958
|
anchor_position,
|
|
1959
1959
|
text,
|
|
@@ -3370,50 +3370,372 @@ function createMajorGridPatternChildren(cellSize, majorCellSize, lineColor, majo
|
|
|
3370
3370
|
}
|
|
3371
3371
|
|
|
3372
3372
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-component.ts
|
|
3373
|
+
import { applyToPoint as applyToPoint30 } from "transformation-matrix";
|
|
3374
|
+
|
|
3375
|
+
// lib/utils/create-pcb-component-anchor-offset-indicators.ts
|
|
3373
3376
|
import { applyToPoint as applyToPoint29 } from "transformation-matrix";
|
|
3377
|
+
var OFFSET_THRESHOLD_MM = 0.01;
|
|
3378
|
+
var TICK_SIZE_PX = 4;
|
|
3379
|
+
var LABEL_GAP_PX = 8;
|
|
3380
|
+
var LABEL_FONT_SIZE_PX = 11;
|
|
3381
|
+
var STROKE_WIDTH_PX = 1;
|
|
3382
|
+
var ANCHOR_MARKER_SIZE_PX = 5;
|
|
3383
|
+
var ANCHOR_MARKER_STROKE_WIDTH_PX = 1.5;
|
|
3384
|
+
var COMPONENT_GAP_PX = 15;
|
|
3385
|
+
var COMPONENT_SIDE_GAP_PX = 10;
|
|
3386
|
+
var DISTANCE_MULTIPLIER = 0.2;
|
|
3387
|
+
var MAX_OFFSET_PX = 50;
|
|
3388
|
+
function createAnchorOffsetIndicators(params) {
|
|
3389
|
+
const {
|
|
3390
|
+
groupAnchorPosition,
|
|
3391
|
+
componentPosition,
|
|
3392
|
+
transform,
|
|
3393
|
+
componentWidth = 0,
|
|
3394
|
+
componentHeight = 0
|
|
3395
|
+
} = params;
|
|
3396
|
+
const objects = [];
|
|
3397
|
+
const [screenGroupAnchorX, screenGroupAnchorY] = applyToPoint29(transform, [
|
|
3398
|
+
groupAnchorPosition.x,
|
|
3399
|
+
groupAnchorPosition.y
|
|
3400
|
+
]);
|
|
3401
|
+
const [screenComponentX, screenComponentY] = applyToPoint29(transform, [
|
|
3402
|
+
componentPosition.x,
|
|
3403
|
+
componentPosition.y
|
|
3404
|
+
]);
|
|
3405
|
+
const offsetX = componentPosition.x - groupAnchorPosition.x;
|
|
3406
|
+
const offsetY = componentPosition.y - groupAnchorPosition.y;
|
|
3407
|
+
const scale9 = Math.abs(transform.a);
|
|
3408
|
+
const screenComponentWidth = componentWidth * scale9;
|
|
3409
|
+
const screenComponentHeight = componentHeight * scale9;
|
|
3410
|
+
objects.push(createAnchorMarker(screenGroupAnchorX, screenGroupAnchorY));
|
|
3411
|
+
objects.push({
|
|
3412
|
+
name: "line",
|
|
3413
|
+
type: "element",
|
|
3414
|
+
attributes: {
|
|
3415
|
+
x1: screenGroupAnchorX.toString(),
|
|
3416
|
+
y1: screenGroupAnchorY.toString(),
|
|
3417
|
+
x2: screenComponentX.toString(),
|
|
3418
|
+
y2: screenComponentY.toString(),
|
|
3419
|
+
stroke: "#ffffff",
|
|
3420
|
+
"stroke-width": "0.5",
|
|
3421
|
+
"stroke-dasharray": "3,3",
|
|
3422
|
+
opacity: "0.5",
|
|
3423
|
+
class: "anchor-offset-connector"
|
|
3424
|
+
},
|
|
3425
|
+
children: [],
|
|
3426
|
+
value: ""
|
|
3427
|
+
});
|
|
3428
|
+
objects.push({
|
|
3429
|
+
name: "circle",
|
|
3430
|
+
type: "element",
|
|
3431
|
+
attributes: {
|
|
3432
|
+
cx: screenComponentX.toString(),
|
|
3433
|
+
cy: screenComponentY.toString(),
|
|
3434
|
+
r: "2",
|
|
3435
|
+
fill: "#ffffff",
|
|
3436
|
+
opacity: "0.7",
|
|
3437
|
+
class: "anchor-offset-component-marker"
|
|
3438
|
+
},
|
|
3439
|
+
children: [],
|
|
3440
|
+
value: ""
|
|
3441
|
+
});
|
|
3442
|
+
const yDistance = Math.abs(screenComponentY - screenGroupAnchorY);
|
|
3443
|
+
const xDistance = Math.abs(screenComponentX - screenGroupAnchorX);
|
|
3444
|
+
const totalDistance = Math.sqrt(xDistance * xDistance + yDistance * yDistance);
|
|
3445
|
+
const componentHeightOffset = screenComponentHeight / 2 + COMPONENT_GAP_PX;
|
|
3446
|
+
const dynamicOffset = Math.max(
|
|
3447
|
+
componentHeightOffset,
|
|
3448
|
+
Math.min(MAX_OFFSET_PX, totalDistance * DISTANCE_MULTIPLIER)
|
|
3449
|
+
);
|
|
3450
|
+
const horizontalLineY = offsetY > 0 ? screenComponentY - dynamicOffset : screenComponentY + dynamicOffset;
|
|
3451
|
+
const componentWidthOffset = screenComponentWidth / 2 + COMPONENT_SIDE_GAP_PX;
|
|
3452
|
+
const verticalLineX = offsetX > 0 ? screenComponentX + componentWidthOffset : screenComponentX - componentWidthOffset;
|
|
3453
|
+
if (Math.abs(offsetX) > OFFSET_THRESHOLD_MM) {
|
|
3454
|
+
objects.push(
|
|
3455
|
+
...createHorizontalDimension({
|
|
3456
|
+
startX: screenGroupAnchorX,
|
|
3457
|
+
endX: screenComponentX,
|
|
3458
|
+
y: horizontalLineY,
|
|
3459
|
+
offsetMm: offsetX,
|
|
3460
|
+
offsetY
|
|
3461
|
+
})
|
|
3462
|
+
);
|
|
3463
|
+
}
|
|
3464
|
+
if (Math.abs(offsetY) > OFFSET_THRESHOLD_MM) {
|
|
3465
|
+
objects.push(
|
|
3466
|
+
...createVerticalDimension({
|
|
3467
|
+
x: verticalLineX,
|
|
3468
|
+
startY: screenGroupAnchorY,
|
|
3469
|
+
endY: screenComponentY,
|
|
3470
|
+
offsetMm: -offsetY,
|
|
3471
|
+
offsetX
|
|
3472
|
+
})
|
|
3473
|
+
);
|
|
3474
|
+
}
|
|
3475
|
+
return objects;
|
|
3476
|
+
}
|
|
3477
|
+
function createAnchorMarker(x, y) {
|
|
3478
|
+
return {
|
|
3479
|
+
name: "g",
|
|
3480
|
+
type: "element",
|
|
3481
|
+
attributes: {
|
|
3482
|
+
class: "anchor-offset-marker",
|
|
3483
|
+
"data-type": "anchor_offset_marker"
|
|
3484
|
+
},
|
|
3485
|
+
children: [
|
|
3486
|
+
{
|
|
3487
|
+
name: "line",
|
|
3488
|
+
type: "element",
|
|
3489
|
+
attributes: {
|
|
3490
|
+
x1: x.toString(),
|
|
3491
|
+
y1: (y - ANCHOR_MARKER_SIZE_PX).toString(),
|
|
3492
|
+
x2: x.toString(),
|
|
3493
|
+
y2: (y + ANCHOR_MARKER_SIZE_PX).toString(),
|
|
3494
|
+
stroke: "#ffffff",
|
|
3495
|
+
"stroke-width": ANCHOR_MARKER_STROKE_WIDTH_PX.toString(),
|
|
3496
|
+
"stroke-linecap": "round"
|
|
3497
|
+
},
|
|
3498
|
+
children: [],
|
|
3499
|
+
value: ""
|
|
3500
|
+
},
|
|
3501
|
+
{
|
|
3502
|
+
name: "line",
|
|
3503
|
+
type: "element",
|
|
3504
|
+
attributes: {
|
|
3505
|
+
x1: (x - ANCHOR_MARKER_SIZE_PX).toString(),
|
|
3506
|
+
y1: y.toString(),
|
|
3507
|
+
x2: (x + ANCHOR_MARKER_SIZE_PX).toString(),
|
|
3508
|
+
y2: y.toString(),
|
|
3509
|
+
stroke: "#ffffff",
|
|
3510
|
+
"stroke-width": ANCHOR_MARKER_STROKE_WIDTH_PX.toString(),
|
|
3511
|
+
"stroke-linecap": "round"
|
|
3512
|
+
},
|
|
3513
|
+
children: [],
|
|
3514
|
+
value: ""
|
|
3515
|
+
}
|
|
3516
|
+
],
|
|
3517
|
+
value: ""
|
|
3518
|
+
};
|
|
3519
|
+
}
|
|
3520
|
+
function createHorizontalDimension({
|
|
3521
|
+
startX,
|
|
3522
|
+
endX,
|
|
3523
|
+
y,
|
|
3524
|
+
offsetMm,
|
|
3525
|
+
offsetY
|
|
3526
|
+
}) {
|
|
3527
|
+
const objects = [];
|
|
3528
|
+
objects.push({
|
|
3529
|
+
name: "line",
|
|
3530
|
+
type: "element",
|
|
3531
|
+
attributes: {
|
|
3532
|
+
x1: startX.toString(),
|
|
3533
|
+
y1: y.toString(),
|
|
3534
|
+
x2: endX.toString(),
|
|
3535
|
+
y2: y.toString(),
|
|
3536
|
+
stroke: "#ffffff",
|
|
3537
|
+
"stroke-width": STROKE_WIDTH_PX.toString(),
|
|
3538
|
+
class: "anchor-offset-dimension-x"
|
|
3539
|
+
},
|
|
3540
|
+
children: [],
|
|
3541
|
+
value: ""
|
|
3542
|
+
});
|
|
3543
|
+
objects.push({
|
|
3544
|
+
name: "line",
|
|
3545
|
+
type: "element",
|
|
3546
|
+
attributes: {
|
|
3547
|
+
x1: startX.toString(),
|
|
3548
|
+
y1: (y - TICK_SIZE_PX).toString(),
|
|
3549
|
+
x2: startX.toString(),
|
|
3550
|
+
y2: (y + TICK_SIZE_PX).toString(),
|
|
3551
|
+
stroke: "#ffffff",
|
|
3552
|
+
"stroke-width": STROKE_WIDTH_PX.toString()
|
|
3553
|
+
},
|
|
3554
|
+
children: [],
|
|
3555
|
+
value: ""
|
|
3556
|
+
});
|
|
3557
|
+
objects.push({
|
|
3558
|
+
name: "line",
|
|
3559
|
+
type: "element",
|
|
3560
|
+
attributes: {
|
|
3561
|
+
x1: endX.toString(),
|
|
3562
|
+
y1: (y - TICK_SIZE_PX).toString(),
|
|
3563
|
+
x2: endX.toString(),
|
|
3564
|
+
y2: (y + TICK_SIZE_PX).toString(),
|
|
3565
|
+
stroke: "#ffffff",
|
|
3566
|
+
"stroke-width": STROKE_WIDTH_PX.toString()
|
|
3567
|
+
},
|
|
3568
|
+
children: [],
|
|
3569
|
+
value: ""
|
|
3570
|
+
});
|
|
3571
|
+
const midX = (startX + endX) / 2;
|
|
3572
|
+
const labelY = offsetY > 0 ? y - TICK_SIZE_PX - LABEL_GAP_PX : y + TICK_SIZE_PX + LABEL_GAP_PX;
|
|
3573
|
+
objects.push({
|
|
3574
|
+
name: "text",
|
|
3575
|
+
type: "element",
|
|
3576
|
+
attributes: {
|
|
3577
|
+
x: midX.toString(),
|
|
3578
|
+
y: labelY.toString(),
|
|
3579
|
+
fill: "#ffffff",
|
|
3580
|
+
"font-size": LABEL_FONT_SIZE_PX.toString(),
|
|
3581
|
+
"font-family": "Arial, sans-serif",
|
|
3582
|
+
"text-anchor": "middle",
|
|
3583
|
+
"dominant-baseline": offsetY > 0 ? "baseline" : "hanging",
|
|
3584
|
+
class: "anchor-offset-label"
|
|
3585
|
+
},
|
|
3586
|
+
children: [
|
|
3587
|
+
{
|
|
3588
|
+
type: "text",
|
|
3589
|
+
value: `X: ${offsetMm.toFixed(2)}mm`,
|
|
3590
|
+
name: "",
|
|
3591
|
+
attributes: {},
|
|
3592
|
+
children: []
|
|
3593
|
+
}
|
|
3594
|
+
],
|
|
3595
|
+
value: ""
|
|
3596
|
+
});
|
|
3597
|
+
return objects;
|
|
3598
|
+
}
|
|
3599
|
+
function createVerticalDimension({
|
|
3600
|
+
x,
|
|
3601
|
+
startY,
|
|
3602
|
+
endY,
|
|
3603
|
+
offsetMm,
|
|
3604
|
+
offsetX
|
|
3605
|
+
}) {
|
|
3606
|
+
const objects = [];
|
|
3607
|
+
objects.push({
|
|
3608
|
+
name: "line",
|
|
3609
|
+
type: "element",
|
|
3610
|
+
attributes: {
|
|
3611
|
+
x1: x.toString(),
|
|
3612
|
+
y1: startY.toString(),
|
|
3613
|
+
x2: x.toString(),
|
|
3614
|
+
y2: endY.toString(),
|
|
3615
|
+
stroke: "#ffffff",
|
|
3616
|
+
"stroke-width": STROKE_WIDTH_PX.toString(),
|
|
3617
|
+
class: "anchor-offset-dimension-y"
|
|
3618
|
+
},
|
|
3619
|
+
children: [],
|
|
3620
|
+
value: ""
|
|
3621
|
+
});
|
|
3622
|
+
objects.push({
|
|
3623
|
+
name: "line",
|
|
3624
|
+
type: "element",
|
|
3625
|
+
attributes: {
|
|
3626
|
+
x1: (x - TICK_SIZE_PX).toString(),
|
|
3627
|
+
y1: startY.toString(),
|
|
3628
|
+
x2: (x + TICK_SIZE_PX).toString(),
|
|
3629
|
+
y2: startY.toString(),
|
|
3630
|
+
stroke: "#ffffff",
|
|
3631
|
+
"stroke-width": STROKE_WIDTH_PX.toString()
|
|
3632
|
+
},
|
|
3633
|
+
children: [],
|
|
3634
|
+
value: ""
|
|
3635
|
+
});
|
|
3636
|
+
objects.push({
|
|
3637
|
+
name: "line",
|
|
3638
|
+
type: "element",
|
|
3639
|
+
attributes: {
|
|
3640
|
+
x1: (x - TICK_SIZE_PX).toString(),
|
|
3641
|
+
y1: endY.toString(),
|
|
3642
|
+
x2: (x + TICK_SIZE_PX).toString(),
|
|
3643
|
+
y2: endY.toString(),
|
|
3644
|
+
stroke: "#ffffff",
|
|
3645
|
+
"stroke-width": STROKE_WIDTH_PX.toString()
|
|
3646
|
+
},
|
|
3647
|
+
children: [],
|
|
3648
|
+
value: ""
|
|
3649
|
+
});
|
|
3650
|
+
const midY = (startY + endY) / 2;
|
|
3651
|
+
const labelX = offsetX < 0 ? x - TICK_SIZE_PX - 4 : x + TICK_SIZE_PX + 4;
|
|
3652
|
+
objects.push({
|
|
3653
|
+
name: "text",
|
|
3654
|
+
type: "element",
|
|
3655
|
+
attributes: {
|
|
3656
|
+
x: labelX.toString(),
|
|
3657
|
+
y: midY.toString(),
|
|
3658
|
+
fill: "#ffffff",
|
|
3659
|
+
"font-size": LABEL_FONT_SIZE_PX.toString(),
|
|
3660
|
+
"font-family": "Arial, sans-serif",
|
|
3661
|
+
"text-anchor": offsetX < 0 ? "end" : "start",
|
|
3662
|
+
"dominant-baseline": "middle",
|
|
3663
|
+
class: "anchor-offset-label"
|
|
3664
|
+
},
|
|
3665
|
+
children: [
|
|
3666
|
+
{
|
|
3667
|
+
type: "text",
|
|
3668
|
+
value: `Y: ${offsetMm.toFixed(2)}mm`,
|
|
3669
|
+
name: "",
|
|
3670
|
+
attributes: {},
|
|
3671
|
+
children: []
|
|
3672
|
+
}
|
|
3673
|
+
],
|
|
3674
|
+
value: ""
|
|
3675
|
+
});
|
|
3676
|
+
return objects;
|
|
3677
|
+
}
|
|
3678
|
+
|
|
3679
|
+
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-component.ts
|
|
3374
3680
|
function createSvgObjectsFromPcbComponent(component, ctx) {
|
|
3375
|
-
const { transform } = ctx;
|
|
3681
|
+
const { transform, circuitJson } = ctx;
|
|
3376
3682
|
const { center, width, height, rotation = 0 } = component;
|
|
3377
|
-
const [x, y] =
|
|
3683
|
+
const [x, y] = applyToPoint30(transform, [center.x, center.y]);
|
|
3378
3684
|
const scaledWidth = width * Math.abs(transform.a);
|
|
3379
3685
|
const scaledHeight = height * Math.abs(transform.d);
|
|
3380
3686
|
const transformStr = `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`;
|
|
3687
|
+
const svgObjects = [];
|
|
3688
|
+
if (ctx.showAnchorOffsets && component.positioned_relative_to_pcb_group_id && component.position_mode === "relative" && circuitJson) {
|
|
3689
|
+
const pcbGroup = circuitJson.find(
|
|
3690
|
+
(elm) => elm.type === "pcb_group" && elm.pcb_group_id === component.positioned_relative_to_pcb_group_id
|
|
3691
|
+
);
|
|
3692
|
+
if (pcbGroup?.center) {
|
|
3693
|
+
svgObjects.push(
|
|
3694
|
+
...createAnchorOffsetIndicators({
|
|
3695
|
+
groupAnchorPosition: pcbGroup.center,
|
|
3696
|
+
componentPosition: center,
|
|
3697
|
+
transform,
|
|
3698
|
+
componentWidth: width,
|
|
3699
|
+
componentHeight: height
|
|
3700
|
+
})
|
|
3701
|
+
);
|
|
3702
|
+
}
|
|
3703
|
+
}
|
|
3381
3704
|
if (!ctx.colorMap.debugComponent?.fill && !ctx.colorMap.debugComponent?.stroke) {
|
|
3382
|
-
return
|
|
3705
|
+
return svgObjects;
|
|
3383
3706
|
}
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
"data-pcb-layer": component.layer ?? "top"
|
|
3407
|
-
}
|
|
3707
|
+
svgObjects.push({
|
|
3708
|
+
name: "g",
|
|
3709
|
+
type: "element",
|
|
3710
|
+
attributes: {
|
|
3711
|
+
transform: transformStr,
|
|
3712
|
+
"data-type": "pcb_component",
|
|
3713
|
+
"data-pcb-layer": component.layer ?? "top"
|
|
3714
|
+
},
|
|
3715
|
+
children: [
|
|
3716
|
+
{
|
|
3717
|
+
name: "rect",
|
|
3718
|
+
type: "element",
|
|
3719
|
+
attributes: {
|
|
3720
|
+
class: "pcb-component",
|
|
3721
|
+
x: (-scaledWidth / 2).toString(),
|
|
3722
|
+
y: (-scaledHeight / 2).toString(),
|
|
3723
|
+
width: scaledWidth.toString(),
|
|
3724
|
+
height: scaledHeight.toString(),
|
|
3725
|
+
fill: ctx.colorMap.debugComponent.fill ?? "transparent",
|
|
3726
|
+
stroke: ctx.colorMap.debugComponent.stroke ?? "transparent",
|
|
3727
|
+
"data-type": "pcb_component",
|
|
3728
|
+
"data-pcb-layer": component.layer ?? "top"
|
|
3408
3729
|
}
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3730
|
+
}
|
|
3731
|
+
],
|
|
3732
|
+
value: ""
|
|
3733
|
+
});
|
|
3734
|
+
return svgObjects;
|
|
3413
3735
|
}
|
|
3414
3736
|
|
|
3415
3737
|
// lib/pcb/svg-object-fns/create-svg-objects-from-pcb-group.ts
|
|
3416
|
-
import { applyToPoint as
|
|
3738
|
+
import { applyToPoint as applyToPoint31 } from "transformation-matrix";
|
|
3417
3739
|
var DEFAULT_GROUP_COLOR = "rgba(100, 200, 255, 0.6)";
|
|
3418
3740
|
var DEFAULT_STROKE_WIDTH = 0.1;
|
|
3419
3741
|
function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
@@ -3440,7 +3762,7 @@ function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
|
3440
3762
|
(point) => point && typeof point.x === "number" && typeof point.y === "number"
|
|
3441
3763
|
)) {
|
|
3442
3764
|
const path = outline.map((point, index) => {
|
|
3443
|
-
const [x, y] =
|
|
3765
|
+
const [x, y] = applyToPoint31(transform, [point.x, point.y]);
|
|
3444
3766
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
3445
3767
|
}).join(" ");
|
|
3446
3768
|
return [
|
|
@@ -3462,11 +3784,11 @@ function createSvgObjectsFromPcbGroup(pcbGroup, ctx) {
|
|
|
3462
3784
|
}
|
|
3463
3785
|
const halfWidth = width / 2;
|
|
3464
3786
|
const halfHeight = height / 2;
|
|
3465
|
-
const [topLeftX, topLeftY] =
|
|
3787
|
+
const [topLeftX, topLeftY] = applyToPoint31(transform, [
|
|
3466
3788
|
center.x - halfWidth,
|
|
3467
3789
|
center.y + halfHeight
|
|
3468
3790
|
]);
|
|
3469
|
-
const [bottomRightX, bottomRightY] =
|
|
3791
|
+
const [bottomRightX, bottomRightY] = applyToPoint31(transform, [
|
|
3470
3792
|
center.x + halfWidth,
|
|
3471
3793
|
center.y - halfHeight
|
|
3472
3794
|
]);
|
|
@@ -3502,7 +3824,7 @@ function getSoftwareUsedString(circuitJson) {
|
|
|
3502
3824
|
var package_default = {
|
|
3503
3825
|
name: "circuit-to-svg",
|
|
3504
3826
|
type: "module",
|
|
3505
|
-
version: "0.0.
|
|
3827
|
+
version: "0.0.263",
|
|
3506
3828
|
description: "Convert Circuit JSON to SVG",
|
|
3507
3829
|
main: "dist/index.js",
|
|
3508
3830
|
files: [
|
|
@@ -3839,7 +4161,9 @@ function convertCircuitJsonToPcbSvg(circuitJson, options) {
|
|
|
3839
4161
|
showPcbGroups: options?.showPcbGroups,
|
|
3840
4162
|
drawPaddingOutsideBoard,
|
|
3841
4163
|
colorMap: colorMap2,
|
|
3842
|
-
showSolderMask: options?.showSolderMask
|
|
4164
|
+
showSolderMask: options?.showSolderMask,
|
|
4165
|
+
showAnchorOffsets: options?.showAnchorOffsets,
|
|
4166
|
+
circuitJson
|
|
3843
4167
|
};
|
|
3844
4168
|
const unsortedSvgObjects = circuitJson.flatMap(
|
|
3845
4169
|
(elm) => createSvgObjects({ elm, circuitJson, ctx })
|
|
@@ -4124,8 +4448,8 @@ function createSvgObjects({
|
|
|
4124
4448
|
}
|
|
4125
4449
|
}
|
|
4126
4450
|
function createSvgObjectFromPcbBoundary(transform, minX, minY, maxX, maxY) {
|
|
4127
|
-
const [x1, y1] =
|
|
4128
|
-
const [x2, y2] =
|
|
4451
|
+
const [x1, y1] = applyToPoint32(transform, [minX, minY]);
|
|
4452
|
+
const [x2, y2] = applyToPoint32(transform, [maxX, maxY]);
|
|
4129
4453
|
const width = Math.abs(x2 - x1);
|
|
4130
4454
|
const height = Math.abs(y2 - y1);
|
|
4131
4455
|
const x = Math.min(x1, x2);
|
|
@@ -4155,14 +4479,14 @@ var circuitJsonToPcbSvg = convertCircuitJsonToPcbSvg;
|
|
|
4155
4479
|
import { stringify as stringify2 } from "svgson";
|
|
4156
4480
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
4157
4481
|
import {
|
|
4158
|
-
applyToPoint as
|
|
4482
|
+
applyToPoint as applyToPoint39,
|
|
4159
4483
|
compose as compose6,
|
|
4160
4484
|
scale as scale3,
|
|
4161
4485
|
translate as translate6
|
|
4162
4486
|
} from "transformation-matrix";
|
|
4163
4487
|
|
|
4164
4488
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-board.ts
|
|
4165
|
-
import { applyToPoint as
|
|
4489
|
+
import { applyToPoint as applyToPoint33 } from "transformation-matrix";
|
|
4166
4490
|
var DEFAULT_BOARD_STYLE = {
|
|
4167
4491
|
fill: "none",
|
|
4168
4492
|
stroke: "rgb(0,0,0)",
|
|
@@ -4174,25 +4498,25 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
4174
4498
|
let path;
|
|
4175
4499
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
4176
4500
|
path = outline.map((point, index) => {
|
|
4177
|
-
const [x, y] =
|
|
4501
|
+
const [x, y] = applyToPoint33(transform, [point.x, point.y]);
|
|
4178
4502
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
4179
4503
|
}).join(" ");
|
|
4180
4504
|
} else {
|
|
4181
4505
|
const halfWidth = width / 2;
|
|
4182
4506
|
const halfHeight = height / 2;
|
|
4183
|
-
const topLeft =
|
|
4507
|
+
const topLeft = applyToPoint33(transform, [
|
|
4184
4508
|
center.x - halfWidth,
|
|
4185
4509
|
center.y - halfHeight
|
|
4186
4510
|
]);
|
|
4187
|
-
const topRight =
|
|
4511
|
+
const topRight = applyToPoint33(transform, [
|
|
4188
4512
|
center.x + halfWidth,
|
|
4189
4513
|
center.y - halfHeight
|
|
4190
4514
|
]);
|
|
4191
|
-
const bottomRight =
|
|
4515
|
+
const bottomRight = applyToPoint33(transform, [
|
|
4192
4516
|
center.x + halfWidth,
|
|
4193
4517
|
center.y + halfHeight
|
|
4194
4518
|
]);
|
|
4195
|
-
const bottomLeft =
|
|
4519
|
+
const bottomLeft = applyToPoint33(transform, [
|
|
4196
4520
|
center.x - halfWidth,
|
|
4197
4521
|
center.y + halfHeight
|
|
4198
4522
|
]);
|
|
@@ -4218,7 +4542,7 @@ function createSvgObjectsFromAssemblyBoard(pcbBoard, transform, style = {}) {
|
|
|
4218
4542
|
}
|
|
4219
4543
|
|
|
4220
4544
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-component.ts
|
|
4221
|
-
import { applyToPoint as
|
|
4545
|
+
import { applyToPoint as applyToPoint35 } from "transformation-matrix";
|
|
4222
4546
|
|
|
4223
4547
|
// lib/utils/get-sch-font-size.ts
|
|
4224
4548
|
import "transformation-matrix";
|
|
@@ -4244,8 +4568,8 @@ function createSvgObjectsFromAssemblyComponent(params, ctx) {
|
|
|
4244
4568
|
const { center, width, height, rotation = 0, layer = "top" } = elm;
|
|
4245
4569
|
if (!center || typeof width !== "number" || typeof height !== "number")
|
|
4246
4570
|
return null;
|
|
4247
|
-
const [x, y] =
|
|
4248
|
-
const [pinX, pinY] =
|
|
4571
|
+
const [x, y] = applyToPoint35(transform, [center.x, center.y]);
|
|
4572
|
+
const [pinX, pinY] = applyToPoint35(transform, [portPosition.x, portPosition.y]);
|
|
4249
4573
|
const scaledWidth = width * Math.abs(transform.a);
|
|
4250
4574
|
const scaledHeight = height * Math.abs(transform.d);
|
|
4251
4575
|
const isTopLayer = layer === "top";
|
|
@@ -4407,11 +4731,11 @@ function getRectPathData(w, h, rotation) {
|
|
|
4407
4731
|
}
|
|
4408
4732
|
|
|
4409
4733
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-hole.ts
|
|
4410
|
-
import { applyToPoint as
|
|
4734
|
+
import { applyToPoint as applyToPoint36 } from "transformation-matrix";
|
|
4411
4735
|
var HOLE_COLOR2 = "rgb(190, 190, 190)";
|
|
4412
4736
|
function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
4413
4737
|
const { transform } = ctx;
|
|
4414
|
-
const [x, y] =
|
|
4738
|
+
const [x, y] = applyToPoint36(transform, [hole.x, hole.y]);
|
|
4415
4739
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
4416
4740
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
4417
4741
|
const radius = scaledDiameter / 2;
|
|
@@ -4475,12 +4799,12 @@ function createSvgObjectsFromAssemblyHole(hole, ctx) {
|
|
|
4475
4799
|
}
|
|
4476
4800
|
|
|
4477
4801
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-plated-hole.ts
|
|
4478
|
-
import { applyToPoint as
|
|
4802
|
+
import { applyToPoint as applyToPoint37 } from "transformation-matrix";
|
|
4479
4803
|
var PAD_COLOR = "rgb(210, 210, 210)";
|
|
4480
4804
|
var HOLE_COLOR3 = "rgb(190, 190, 190)";
|
|
4481
4805
|
function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
4482
4806
|
const { transform } = ctx;
|
|
4483
|
-
const [x, y] =
|
|
4807
|
+
const [x, y] = applyToPoint37(transform, [hole.x, hole.y]);
|
|
4484
4808
|
if (hole.shape === "pill") {
|
|
4485
4809
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
4486
4810
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -4575,7 +4899,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
4575
4899
|
const scaledRectPadHeight = circularHole.rect_pad_height * Math.abs(transform.a);
|
|
4576
4900
|
const scaledRectBorderRadius = (circularHole.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
4577
4901
|
const holeRadius = scaledHoleDiameter / 2;
|
|
4578
|
-
const [holeCx, holeCy] =
|
|
4902
|
+
const [holeCx, holeCy] = applyToPoint37(transform, [
|
|
4579
4903
|
circularHole.x + circularHole.hole_offset_x,
|
|
4580
4904
|
circularHole.y + circularHole.hole_offset_y
|
|
4581
4905
|
]);
|
|
@@ -4633,7 +4957,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
4633
4957
|
const pillHoleWithOffsets = pillHole;
|
|
4634
4958
|
const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
|
|
4635
4959
|
const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
|
|
4636
|
-
const [holeCenterX, holeCenterY] =
|
|
4960
|
+
const [holeCenterX, holeCenterY] = applyToPoint37(transform, [
|
|
4637
4961
|
pillHole.x + holeOffsetX,
|
|
4638
4962
|
pillHole.y + holeOffsetY
|
|
4639
4963
|
]);
|
|
@@ -4695,7 +5019,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
4695
5019
|
const rotatedHoleWithOffsets = rotatedHole;
|
|
4696
5020
|
const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
|
|
4697
5021
|
const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
|
|
4698
|
-
const [holeCenterX, holeCenterY] =
|
|
5022
|
+
const [holeCenterX, holeCenterY] = applyToPoint37(transform, [
|
|
4699
5023
|
rotatedHole.x + holeOffsetX,
|
|
4700
5024
|
rotatedHole.y + holeOffsetY
|
|
4701
5025
|
]);
|
|
@@ -4751,14 +5075,14 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
|
|
|
4751
5075
|
}
|
|
4752
5076
|
|
|
4753
5077
|
// lib/assembly/svg-object-fns/create-svg-objects-from-assembly-smt-pad.ts
|
|
4754
|
-
import { applyToPoint as
|
|
5078
|
+
import { applyToPoint as applyToPoint38 } from "transformation-matrix";
|
|
4755
5079
|
var PAD_COLOR2 = "rgb(210, 210, 210)";
|
|
4756
5080
|
function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
4757
5081
|
const { transform } = ctx;
|
|
4758
5082
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
4759
5083
|
const width = pad.width * Math.abs(transform.a);
|
|
4760
5084
|
const height = pad.height * Math.abs(transform.d);
|
|
4761
|
-
const [x, y] =
|
|
5085
|
+
const [x, y] = applyToPoint38(transform, [pad.x, pad.y]);
|
|
4762
5086
|
const scaledBorderRadius = (pad.rect_border_radius ?? 0) * Math.abs(transform.a);
|
|
4763
5087
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
4764
5088
|
return [
|
|
@@ -4810,7 +5134,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
4810
5134
|
const width = pad.width * Math.abs(transform.a);
|
|
4811
5135
|
const height = pad.height * Math.abs(transform.d);
|
|
4812
5136
|
const radius = pad.radius * Math.abs(transform.a);
|
|
4813
|
-
const [x, y] =
|
|
5137
|
+
const [x, y] = applyToPoint38(transform, [pad.x, pad.y]);
|
|
4814
5138
|
return [
|
|
4815
5139
|
{
|
|
4816
5140
|
name: "rect",
|
|
@@ -4833,7 +5157,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
4833
5157
|
}
|
|
4834
5158
|
if (pad.shape === "circle") {
|
|
4835
5159
|
const radius = pad.radius * Math.abs(transform.a);
|
|
4836
|
-
const [x, y] =
|
|
5160
|
+
const [x, y] = applyToPoint38(transform, [pad.x, pad.y]);
|
|
4837
5161
|
return [
|
|
4838
5162
|
{
|
|
4839
5163
|
name: "circle",
|
|
@@ -4853,7 +5177,7 @@ function createSvgObjectsFromAssemblySmtPad(pad, ctx) {
|
|
|
4853
5177
|
}
|
|
4854
5178
|
if (pad.shape === "polygon") {
|
|
4855
5179
|
const points = (pad.points ?? []).map(
|
|
4856
|
-
(point) =>
|
|
5180
|
+
(point) => applyToPoint38(transform, [point.x, point.y])
|
|
4857
5181
|
);
|
|
4858
5182
|
return [
|
|
4859
5183
|
{
|
|
@@ -5037,8 +5361,8 @@ function createSvgObjects2(elm, ctx, soup) {
|
|
|
5037
5361
|
}
|
|
5038
5362
|
}
|
|
5039
5363
|
function createSvgObjectFromAssemblyBoundary(transform, minX, minY, maxX, maxY) {
|
|
5040
|
-
const [x1, y1] =
|
|
5041
|
-
const [x2, y2] =
|
|
5364
|
+
const [x1, y1] = applyToPoint39(transform, [minX, minY]);
|
|
5365
|
+
const [x2, y2] = applyToPoint39(transform, [maxX, maxY]);
|
|
5042
5366
|
const width = Math.abs(x2 - x1);
|
|
5043
5367
|
const height = Math.abs(y2 - y1);
|
|
5044
5368
|
const x = Math.min(x1, x2);
|
|
@@ -5067,7 +5391,7 @@ import {
|
|
|
5067
5391
|
} from "transformation-matrix";
|
|
5068
5392
|
|
|
5069
5393
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-board.ts
|
|
5070
|
-
import { applyToPoint as
|
|
5394
|
+
import { applyToPoint as applyToPoint40 } from "transformation-matrix";
|
|
5071
5395
|
import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
5072
5396
|
var BOARD_FILL_COLOR = "rgb(26, 115, 143)";
|
|
5073
5397
|
var BOARD_STROKE_COLOR = "rgba(0,0,0,0.9)";
|
|
@@ -5081,25 +5405,25 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
5081
5405
|
let path;
|
|
5082
5406
|
if (outline && Array.isArray(outline) && outline.length >= 3) {
|
|
5083
5407
|
path = outline.map((point, index) => {
|
|
5084
|
-
const [x, y] =
|
|
5408
|
+
const [x, y] = applyToPoint40(transform, [point.x, point.y]);
|
|
5085
5409
|
return index === 0 ? `M ${x} ${y}` : `L ${x} ${y}`;
|
|
5086
5410
|
}).join(" ");
|
|
5087
5411
|
} else {
|
|
5088
5412
|
const halfWidth = width / 2;
|
|
5089
5413
|
const halfHeight = height / 2;
|
|
5090
|
-
const topLeft =
|
|
5414
|
+
const topLeft = applyToPoint40(transform, [
|
|
5091
5415
|
center.x - halfWidth,
|
|
5092
5416
|
center.y - halfHeight
|
|
5093
5417
|
]);
|
|
5094
|
-
const topRight =
|
|
5418
|
+
const topRight = applyToPoint40(transform, [
|
|
5095
5419
|
center.x + halfWidth,
|
|
5096
5420
|
center.y - halfHeight
|
|
5097
5421
|
]);
|
|
5098
|
-
const bottomRight =
|
|
5422
|
+
const bottomRight = applyToPoint40(transform, [
|
|
5099
5423
|
center.x + halfWidth,
|
|
5100
5424
|
center.y + halfHeight
|
|
5101
5425
|
]);
|
|
5102
|
-
const bottomLeft =
|
|
5426
|
+
const bottomLeft = applyToPoint40(transform, [
|
|
5103
5427
|
center.x - halfWidth,
|
|
5104
5428
|
center.y + halfHeight
|
|
5105
5429
|
]);
|
|
@@ -5117,10 +5441,10 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
5117
5441
|
const halfWidth = width2 / 2;
|
|
5118
5442
|
const halfHeight = height2 / 2;
|
|
5119
5443
|
const [tl, tr, br, bl] = [
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5444
|
+
applyToPoint40(transform, [x - halfWidth, y - halfHeight]),
|
|
5445
|
+
applyToPoint40(transform, [x + halfWidth, y - halfHeight]),
|
|
5446
|
+
applyToPoint40(transform, [x + halfWidth, y + halfHeight]),
|
|
5447
|
+
applyToPoint40(transform, [x - halfWidth, y + halfHeight])
|
|
5124
5448
|
];
|
|
5125
5449
|
path += ` M ${tl[0]} ${tl[1]} L ${tr[0]} ${tr[1]} L ${br[0]} ${br[1]} L ${bl[0]} ${bl[1]} Z`;
|
|
5126
5450
|
} else if (cutout.shape === "circle") {
|
|
@@ -5170,7 +5494,7 @@ function createSvgObjectsFromPinoutBoard(pcbBoard, ctx) {
|
|
|
5170
5494
|
|
|
5171
5495
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-component.ts
|
|
5172
5496
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
5173
|
-
import { applyToPoint as
|
|
5497
|
+
import { applyToPoint as applyToPoint41 } from "transformation-matrix";
|
|
5174
5498
|
var COMPONENT_FILL_COLOR = "rgba(120, 120, 120, 0.6)";
|
|
5175
5499
|
var COMPONENT_LABEL_COLOR = "rgba(255, 255, 255, 0.9)";
|
|
5176
5500
|
function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
@@ -5180,7 +5504,7 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
5180
5504
|
if (!center || typeof width !== "number" || typeof height !== "number" || width === 0 || height === 0) {
|
|
5181
5505
|
return [];
|
|
5182
5506
|
}
|
|
5183
|
-
const [x, y] =
|
|
5507
|
+
const [x, y] = applyToPoint41(transform, [center.x, center.y]);
|
|
5184
5508
|
const scaledWidth = width * Math.abs(transform.a);
|
|
5185
5509
|
const scaledHeight = height * Math.abs(transform.d);
|
|
5186
5510
|
const transformStr = `translate(${x}, ${y})`;
|
|
@@ -5241,11 +5565,11 @@ function createSvgObjectsFromPinoutComponent(elm, ctx) {
|
|
|
5241
5565
|
}
|
|
5242
5566
|
|
|
5243
5567
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-hole.ts
|
|
5244
|
-
import { applyToPoint as
|
|
5568
|
+
import { applyToPoint as applyToPoint42 } from "transformation-matrix";
|
|
5245
5569
|
var HOLE_COLOR4 = "rgb(50, 50, 50)";
|
|
5246
5570
|
function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
5247
5571
|
const { transform } = ctx;
|
|
5248
|
-
const [x, y] =
|
|
5572
|
+
const [x, y] = applyToPoint42(transform, [hole.x, hole.y]);
|
|
5249
5573
|
if (hole.hole_shape === "circle" || hole.hole_shape === "square") {
|
|
5250
5574
|
const scaledDiameter = hole.hole_diameter * Math.abs(transform.a);
|
|
5251
5575
|
const radius = scaledDiameter / 2;
|
|
@@ -5309,12 +5633,12 @@ function createSvgObjectsFromPinoutHole(hole, ctx) {
|
|
|
5309
5633
|
}
|
|
5310
5634
|
|
|
5311
5635
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-plated-hole.ts
|
|
5312
|
-
import { applyToPoint as
|
|
5636
|
+
import { applyToPoint as applyToPoint43 } from "transformation-matrix";
|
|
5313
5637
|
var PAD_COLOR3 = "rgb(218, 165, 32)";
|
|
5314
5638
|
var HOLE_COLOR5 = "rgb(40, 40, 40)";
|
|
5315
5639
|
function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
5316
5640
|
const { transform } = ctx;
|
|
5317
|
-
const [x, y] =
|
|
5641
|
+
const [x, y] = applyToPoint43(transform, [hole.x, hole.y]);
|
|
5318
5642
|
if (hole.shape === "pill") {
|
|
5319
5643
|
const scaledOuterWidth = hole.outer_width * Math.abs(transform.a);
|
|
5320
5644
|
const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
|
|
@@ -5549,14 +5873,14 @@ function createSvgObjectsFromPinoutPlatedHole(hole, ctx) {
|
|
|
5549
5873
|
}
|
|
5550
5874
|
|
|
5551
5875
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-smt-pad.ts
|
|
5552
|
-
import { applyToPoint as
|
|
5876
|
+
import { applyToPoint as applyToPoint44 } from "transformation-matrix";
|
|
5553
5877
|
var PAD_COLOR4 = "rgb(218, 165, 32)";
|
|
5554
5878
|
function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
5555
5879
|
const { transform } = ctx;
|
|
5556
5880
|
if (pad.shape === "rect" || pad.shape === "rotated_rect") {
|
|
5557
5881
|
const width = pad.width * Math.abs(transform.a);
|
|
5558
5882
|
const height = pad.height * Math.abs(transform.d);
|
|
5559
|
-
const [x, y] =
|
|
5883
|
+
const [x, y] = applyToPoint44(transform, [pad.x, pad.y]);
|
|
5560
5884
|
if (pad.shape === "rotated_rect" && pad.ccw_rotation) {
|
|
5561
5885
|
return [
|
|
5562
5886
|
{
|
|
@@ -5599,7 +5923,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
5599
5923
|
const width = pad.width * Math.abs(transform.a);
|
|
5600
5924
|
const height = pad.height * Math.abs(transform.d);
|
|
5601
5925
|
const radius = pad.radius * Math.abs(transform.a);
|
|
5602
|
-
const [x, y] =
|
|
5926
|
+
const [x, y] = applyToPoint44(transform, [pad.x, pad.y]);
|
|
5603
5927
|
return [
|
|
5604
5928
|
{
|
|
5605
5929
|
name: "rect",
|
|
@@ -5622,7 +5946,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
5622
5946
|
}
|
|
5623
5947
|
if (pad.shape === "circle") {
|
|
5624
5948
|
const radius = pad.radius * Math.abs(transform.a);
|
|
5625
|
-
const [x, y] =
|
|
5949
|
+
const [x, y] = applyToPoint44(transform, [pad.x, pad.y]);
|
|
5626
5950
|
return [
|
|
5627
5951
|
{
|
|
5628
5952
|
name: "circle",
|
|
@@ -5642,7 +5966,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
5642
5966
|
}
|
|
5643
5967
|
if (pad.shape === "polygon") {
|
|
5644
5968
|
const points = (pad.points ?? []).map(
|
|
5645
|
-
(point) =>
|
|
5969
|
+
(point) => applyToPoint44(transform, [point.x, point.y])
|
|
5646
5970
|
);
|
|
5647
5971
|
return [
|
|
5648
5972
|
{
|
|
@@ -5663,7 +5987,7 @@ function createSvgObjectsFromPinoutSmtPad(pad, ctx) {
|
|
|
5663
5987
|
}
|
|
5664
5988
|
|
|
5665
5989
|
// lib/pinout/svg-object-fns/create-svg-objects-from-pinout-port.ts
|
|
5666
|
-
import { applyToPoint as
|
|
5990
|
+
import { applyToPoint as applyToPoint45 } from "transformation-matrix";
|
|
5667
5991
|
import { calculateElbow } from "calculate-elbow";
|
|
5668
5992
|
|
|
5669
5993
|
// lib/pinout/svg-object-fns/pinout-label-box.ts
|
|
@@ -5740,7 +6064,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
5740
6064
|
const label_info = ctx.label_positions.get(pcb_port.pcb_port_id);
|
|
5741
6065
|
if (!label_info) return [];
|
|
5742
6066
|
const { text: label, aliases, elbow_end, label_pos, edge } = label_info;
|
|
5743
|
-
const [port_x, port_y] =
|
|
6067
|
+
const [port_x, port_y] = applyToPoint45(ctx.transform, [pcb_port.x, pcb_port.y]);
|
|
5744
6068
|
const start_facing_direction = edge === "left" ? "x-" : edge === "right" ? "x+" : edge === "top" ? "y-" : "y+";
|
|
5745
6069
|
const end_facing_direction = edge === "left" ? "x+" : edge === "right" ? "x-" : edge === "top" ? "y+" : "y-";
|
|
5746
6070
|
const elbow_path = calculateElbow(
|
|
@@ -5881,7 +6205,7 @@ function createSvgObjectsFromPinoutPort(pcb_port, ctx) {
|
|
|
5881
6205
|
}
|
|
5882
6206
|
|
|
5883
6207
|
// lib/pinout/calculate-label-positions.ts
|
|
5884
|
-
import { applyToPoint as
|
|
6208
|
+
import { applyToPoint as applyToPoint46 } from "transformation-matrix";
|
|
5885
6209
|
|
|
5886
6210
|
// lib/pinout/constants.ts
|
|
5887
6211
|
var LABEL_RECT_HEIGHT_BASE_MM = 1.6;
|
|
@@ -5919,7 +6243,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
5919
6243
|
);
|
|
5920
6244
|
const mapToEdgePort = (pinout_label) => ({
|
|
5921
6245
|
pcb_port: pinout_label.pcb_port,
|
|
5922
|
-
y:
|
|
6246
|
+
y: applyToPoint46(transform, [
|
|
5923
6247
|
pinout_label.pcb_port.x,
|
|
5924
6248
|
pinout_label.pcb_port.y
|
|
5925
6249
|
])[1],
|
|
@@ -5934,7 +6258,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
5934
6258
|
} else {
|
|
5935
6259
|
edge_ports = pinout_labels.map((pinout_label) => ({
|
|
5936
6260
|
pcb_port: pinout_label.pcb_port,
|
|
5937
|
-
y:
|
|
6261
|
+
y: applyToPoint46(transform, [
|
|
5938
6262
|
pinout_label.pcb_port.x,
|
|
5939
6263
|
pinout_label.pcb_port.y
|
|
5940
6264
|
])[1],
|
|
@@ -5942,7 +6266,7 @@ function calculateVerticalEdgeLabels(edge, pinout_labels, {
|
|
|
5942
6266
|
})).sort((a, b) => a.y - b.y);
|
|
5943
6267
|
}
|
|
5944
6268
|
if (edge_ports.length === 0) return;
|
|
5945
|
-
const board_edge_x =
|
|
6269
|
+
const board_edge_x = applyToPoint46(transform, [
|
|
5946
6270
|
edge === "left" ? board_bounds.minX : board_bounds.maxX,
|
|
5947
6271
|
0
|
|
5948
6272
|
])[0];
|
|
@@ -6364,14 +6688,14 @@ import {
|
|
|
6364
6688
|
} from "transformation-matrix";
|
|
6365
6689
|
|
|
6366
6690
|
// lib/sch/draw-schematic-grid.ts
|
|
6367
|
-
import { applyToPoint as
|
|
6691
|
+
import { applyToPoint as applyToPoint47 } from "transformation-matrix";
|
|
6368
6692
|
function drawSchematicGrid(params) {
|
|
6369
6693
|
const { minX, minY, maxX, maxY } = params.bounds;
|
|
6370
6694
|
const cellSize = params.cellSize ?? 1;
|
|
6371
6695
|
const labelCells = params.labelCells ?? false;
|
|
6372
6696
|
const gridLines = [];
|
|
6373
6697
|
const transformPoint = (x, y) => {
|
|
6374
|
-
const [transformedX, transformedY] =
|
|
6698
|
+
const [transformedX, transformedY] = applyToPoint47(params.transform, [x, y]);
|
|
6375
6699
|
return { x: transformedX, y: transformedY };
|
|
6376
6700
|
};
|
|
6377
6701
|
for (let x = Math.floor(minX); x <= Math.ceil(maxX); x += cellSize) {
|
|
@@ -6452,15 +6776,15 @@ function drawSchematicGrid(params) {
|
|
|
6452
6776
|
}
|
|
6453
6777
|
|
|
6454
6778
|
// lib/sch/draw-schematic-labeled-points.ts
|
|
6455
|
-
import { applyToPoint as
|
|
6779
|
+
import { applyToPoint as applyToPoint48 } from "transformation-matrix";
|
|
6456
6780
|
function drawSchematicLabeledPoints(params) {
|
|
6457
6781
|
const { points, transform } = params;
|
|
6458
6782
|
const labeledPointsGroup = [];
|
|
6459
6783
|
for (const point of points) {
|
|
6460
|
-
const [x1, y1] =
|
|
6461
|
-
const [x2, y2] =
|
|
6462
|
-
const [x3, y3] =
|
|
6463
|
-
const [x4, y4] =
|
|
6784
|
+
const [x1, y1] = applyToPoint48(transform, [point.x - 0.1, point.y - 0.1]);
|
|
6785
|
+
const [x2, y2] = applyToPoint48(transform, [point.x + 0.1, point.y + 0.1]);
|
|
6786
|
+
const [x3, y3] = applyToPoint48(transform, [point.x - 0.1, point.y + 0.1]);
|
|
6787
|
+
const [x4, y4] = applyToPoint48(transform, [point.x + 0.1, point.y - 0.1]);
|
|
6464
6788
|
labeledPointsGroup.push({
|
|
6465
6789
|
name: "path",
|
|
6466
6790
|
type: "element",
|
|
@@ -6471,7 +6795,7 @@ function drawSchematicLabeledPoints(params) {
|
|
|
6471
6795
|
"stroke-opacity": "0.7"
|
|
6472
6796
|
}
|
|
6473
6797
|
});
|
|
6474
|
-
const [labelX, labelY] =
|
|
6798
|
+
const [labelX, labelY] = applyToPoint48(transform, [
|
|
6475
6799
|
point.x + 0.15,
|
|
6476
6800
|
point.y - 0.15
|
|
6477
6801
|
]);
|
|
@@ -7565,7 +7889,7 @@ import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
|
7565
7889
|
import { symbols } from "schematic-symbols";
|
|
7566
7890
|
import "svgson";
|
|
7567
7891
|
import {
|
|
7568
|
-
applyToPoint as
|
|
7892
|
+
applyToPoint as applyToPoint50,
|
|
7569
7893
|
compose as compose9
|
|
7570
7894
|
} from "transformation-matrix";
|
|
7571
7895
|
|
|
@@ -7649,13 +7973,13 @@ function pointPairsToMatrix(a1, a2, b1, b2) {
|
|
|
7649
7973
|
}
|
|
7650
7974
|
|
|
7651
7975
|
// lib/sch/svg-object-fns/create-svg-error-text.ts
|
|
7652
|
-
import { applyToPoint as
|
|
7976
|
+
import { applyToPoint as applyToPoint49 } from "transformation-matrix";
|
|
7653
7977
|
var createSvgSchErrorText = ({
|
|
7654
7978
|
text,
|
|
7655
7979
|
realCenter,
|
|
7656
7980
|
realToScreenTransform
|
|
7657
7981
|
}) => {
|
|
7658
|
-
const screenCenter =
|
|
7982
|
+
const screenCenter = applyToPoint49(realToScreenTransform, realCenter);
|
|
7659
7983
|
return {
|
|
7660
7984
|
type: "element",
|
|
7661
7985
|
name: "text",
|
|
@@ -7764,11 +8088,11 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7764
8088
|
minY: Math.min(...paths.flatMap((p) => p.points.map((pt) => pt.y))),
|
|
7765
8089
|
maxY: Math.max(...paths.flatMap((p) => p.points.map((pt) => pt.y)))
|
|
7766
8090
|
};
|
|
7767
|
-
const [screenMinX, screenMinY] =
|
|
8091
|
+
const [screenMinX, screenMinY] = applyToPoint50(
|
|
7768
8092
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7769
8093
|
[bounds.minX, bounds.minY]
|
|
7770
8094
|
);
|
|
7771
|
-
const [screenMaxX, screenMaxY] =
|
|
8095
|
+
const [screenMaxX, screenMaxY] = applyToPoint50(
|
|
7772
8096
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7773
8097
|
[bounds.maxX, bounds.maxY]
|
|
7774
8098
|
);
|
|
@@ -7797,7 +8121,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7797
8121
|
name: "path",
|
|
7798
8122
|
attributes: {
|
|
7799
8123
|
d: points.map((p, i) => {
|
|
7800
|
-
const [x, y] =
|
|
8124
|
+
const [x, y] = applyToPoint50(
|
|
7801
8125
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7802
8126
|
[p.x, p.y]
|
|
7803
8127
|
);
|
|
@@ -7813,7 +8137,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7813
8137
|
});
|
|
7814
8138
|
}
|
|
7815
8139
|
for (const text of texts) {
|
|
7816
|
-
const screenTextPos =
|
|
8140
|
+
const screenTextPos = applyToPoint50(
|
|
7817
8141
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7818
8142
|
text
|
|
7819
8143
|
);
|
|
@@ -7865,7 +8189,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7865
8189
|
});
|
|
7866
8190
|
}
|
|
7867
8191
|
for (const box of boxes) {
|
|
7868
|
-
const screenBoxPos =
|
|
8192
|
+
const screenBoxPos = applyToPoint50(
|
|
7869
8193
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7870
8194
|
box
|
|
7871
8195
|
);
|
|
@@ -7889,7 +8213,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7889
8213
|
}
|
|
7890
8214
|
for (const port of symbol.ports) {
|
|
7891
8215
|
if (connectedSymbolPorts.has(port)) continue;
|
|
7892
|
-
const screenPortPos =
|
|
8216
|
+
const screenPortPos = applyToPoint50(
|
|
7893
8217
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7894
8218
|
port
|
|
7895
8219
|
);
|
|
@@ -7909,7 +8233,7 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7909
8233
|
});
|
|
7910
8234
|
}
|
|
7911
8235
|
for (const circle of circles) {
|
|
7912
|
-
const screenCirclePos =
|
|
8236
|
+
const screenCirclePos = applyToPoint50(
|
|
7913
8237
|
compose9(realToScreenTransform, transformFromSymbolToReal),
|
|
7914
8238
|
circle
|
|
7915
8239
|
);
|
|
@@ -7936,14 +8260,14 @@ var createSvgObjectsFromSchematicComponentWithSymbol = ({
|
|
|
7936
8260
|
import { su as su10 } from "@tscircuit/circuit-json-util";
|
|
7937
8261
|
import "schematic-symbols";
|
|
7938
8262
|
import "svgson";
|
|
7939
|
-
import { applyToPoint as
|
|
8263
|
+
import { applyToPoint as applyToPoint56 } from "transformation-matrix";
|
|
7940
8264
|
|
|
7941
8265
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-port-on-box.ts
|
|
7942
8266
|
import "transformation-matrix";
|
|
7943
8267
|
import "@tscircuit/circuit-json-util";
|
|
7944
8268
|
|
|
7945
8269
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-box-line.ts
|
|
7946
|
-
import { applyToPoint as
|
|
8270
|
+
import { applyToPoint as applyToPoint51 } from "transformation-matrix";
|
|
7947
8271
|
import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
7948
8272
|
var PIN_CIRCLE_RADIUS_MM = 0.02;
|
|
7949
8273
|
var createArrow = (tip, angle, size, color, strokeWidth) => {
|
|
@@ -7996,8 +8320,8 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
7996
8320
|
realEdgePos.y += realPinLineLength;
|
|
7997
8321
|
break;
|
|
7998
8322
|
}
|
|
7999
|
-
const screenSchPortPos =
|
|
8000
|
-
const screenRealEdgePos =
|
|
8323
|
+
const screenSchPortPos = applyToPoint51(transform, schPort.center);
|
|
8324
|
+
const screenRealEdgePos = applyToPoint51(transform, realEdgePos);
|
|
8001
8325
|
const isConnected = isSourcePortConnected(circuitJson, schPort.source_port_id);
|
|
8002
8326
|
const realLineEnd = { ...schPort.center };
|
|
8003
8327
|
if (!isConnected) {
|
|
@@ -8016,7 +8340,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
8016
8340
|
break;
|
|
8017
8341
|
}
|
|
8018
8342
|
}
|
|
8019
|
-
const screenLineEnd =
|
|
8343
|
+
const screenLineEnd = applyToPoint51(transform, realLineEnd);
|
|
8020
8344
|
svgObjects.push({
|
|
8021
8345
|
name: "line",
|
|
8022
8346
|
type: "element",
|
|
@@ -8137,7 +8461,7 @@ var createSvgObjectsForSchPortBoxLine = ({
|
|
|
8137
8461
|
};
|
|
8138
8462
|
|
|
8139
8463
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-number-text.ts
|
|
8140
|
-
import { applyToPoint as
|
|
8464
|
+
import { applyToPoint as applyToPoint52 } from "transformation-matrix";
|
|
8141
8465
|
var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
8142
8466
|
const svgObjects = [];
|
|
8143
8467
|
const { schPort, schComponent, transform, circuitJson } = params;
|
|
@@ -8155,7 +8479,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
8155
8479
|
} else {
|
|
8156
8480
|
realPinNumberPos.y += 0.02;
|
|
8157
8481
|
}
|
|
8158
|
-
const screenPinNumberTextPos =
|
|
8482
|
+
const screenPinNumberTextPos = applyToPoint52(transform, realPinNumberPos);
|
|
8159
8483
|
svgObjects.push({
|
|
8160
8484
|
name: "text",
|
|
8161
8485
|
type: "element",
|
|
@@ -8185,7 +8509,7 @@ var createSvgObjectsForSchPortPinNumberText = (params) => {
|
|
|
8185
8509
|
};
|
|
8186
8510
|
|
|
8187
8511
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-pin-label.ts
|
|
8188
|
-
import { applyToPoint as
|
|
8512
|
+
import { applyToPoint as applyToPoint53 } from "transformation-matrix";
|
|
8189
8513
|
var LABEL_DIST_FROM_EDGE_MM = 0.1;
|
|
8190
8514
|
var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
8191
8515
|
const svgObjects = [];
|
|
@@ -8199,7 +8523,7 @@ var createSvgObjectsForSchPortPinLabel = (params) => {
|
|
|
8199
8523
|
const realPinEdgeDistance = schPort.distance_from_component_edge ?? 0.4;
|
|
8200
8524
|
realPinNumberPos.x += vecToEdge.x * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
8201
8525
|
realPinNumberPos.y += vecToEdge.y * (realPinEdgeDistance + LABEL_DIST_FROM_EDGE_MM);
|
|
8202
|
-
const screenPinNumberTextPos =
|
|
8526
|
+
const screenPinNumberTextPos = applyToPoint53(transform, realPinNumberPos);
|
|
8203
8527
|
const label = schPort.display_pin_label ?? schComponent.port_labels?.[`${schPort.pin_number}`];
|
|
8204
8528
|
if (!label) return [];
|
|
8205
8529
|
const isNegated = label.startsWith("N_");
|
|
@@ -8247,13 +8571,13 @@ var createSvgObjectsFromSchPortOnBox = (params) => {
|
|
|
8247
8571
|
};
|
|
8248
8572
|
|
|
8249
8573
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
|
|
8250
|
-
import { applyToPoint as
|
|
8574
|
+
import { applyToPoint as applyToPoint55 } from "transformation-matrix";
|
|
8251
8575
|
var createSvgSchText = ({
|
|
8252
8576
|
elm,
|
|
8253
8577
|
transform,
|
|
8254
8578
|
colorMap: colorMap2
|
|
8255
8579
|
}) => {
|
|
8256
|
-
const center =
|
|
8580
|
+
const center = applyToPoint55(transform, elm.position);
|
|
8257
8581
|
const textAnchorMap = {
|
|
8258
8582
|
center: "middle",
|
|
8259
8583
|
center_right: "end",
|
|
@@ -8337,11 +8661,11 @@ var createSvgObjectsFromSchematicComponentWithBox = ({
|
|
|
8337
8661
|
colorMap: colorMap2
|
|
8338
8662
|
}) => {
|
|
8339
8663
|
const svgObjects = [];
|
|
8340
|
-
const componentScreenTopLeft =
|
|
8664
|
+
const componentScreenTopLeft = applyToPoint56(transform, {
|
|
8341
8665
|
x: schComponent.center.x - schComponent.size.width / 2,
|
|
8342
8666
|
y: schComponent.center.y + schComponent.size.height / 2
|
|
8343
8667
|
});
|
|
8344
|
-
const componentScreenBottomRight =
|
|
8668
|
+
const componentScreenBottomRight = applyToPoint56(transform, {
|
|
8345
8669
|
x: schComponent.center.x + schComponent.size.width / 2,
|
|
8346
8670
|
y: schComponent.center.y - schComponent.size.height / 2
|
|
8347
8671
|
});
|
|
@@ -8427,13 +8751,13 @@ function createSvgObjectsFromSchematicComponent(params) {
|
|
|
8427
8751
|
}
|
|
8428
8752
|
|
|
8429
8753
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-voltage-probe.ts
|
|
8430
|
-
import { applyToPoint as
|
|
8754
|
+
import { applyToPoint as applyToPoint57 } from "transformation-matrix";
|
|
8431
8755
|
function createSvgObjectsFromSchVoltageProbe({
|
|
8432
8756
|
probe,
|
|
8433
8757
|
transform,
|
|
8434
8758
|
colorMap: colorMap2
|
|
8435
8759
|
}) {
|
|
8436
|
-
const [screenX, screenY] =
|
|
8760
|
+
const [screenX, screenY] = applyToPoint57(transform, [
|
|
8437
8761
|
probe.position.x,
|
|
8438
8762
|
probe.position.y
|
|
8439
8763
|
]);
|
|
@@ -8493,17 +8817,17 @@ function createSvgObjectsFromSchVoltageProbe({
|
|
|
8493
8817
|
}
|
|
8494
8818
|
|
|
8495
8819
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-debug-object.ts
|
|
8496
|
-
import { applyToPoint as
|
|
8820
|
+
import { applyToPoint as applyToPoint58 } from "transformation-matrix";
|
|
8497
8821
|
function createSvgObjectsFromSchDebugObject({
|
|
8498
8822
|
debugObject,
|
|
8499
8823
|
transform
|
|
8500
8824
|
}) {
|
|
8501
8825
|
if (debugObject.shape === "rect") {
|
|
8502
|
-
let [screenLeft, screenTop] =
|
|
8826
|
+
let [screenLeft, screenTop] = applyToPoint58(transform, [
|
|
8503
8827
|
debugObject.center.x - debugObject.size.width / 2,
|
|
8504
8828
|
debugObject.center.y - debugObject.size.height / 2
|
|
8505
8829
|
]);
|
|
8506
|
-
let [screenRight, screenBottom] =
|
|
8830
|
+
let [screenRight, screenBottom] = applyToPoint58(transform, [
|
|
8507
8831
|
debugObject.center.x + debugObject.size.width / 2,
|
|
8508
8832
|
debugObject.center.y + debugObject.size.height / 2
|
|
8509
8833
|
]);
|
|
@@ -8513,7 +8837,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
8513
8837
|
];
|
|
8514
8838
|
const width = Math.abs(screenRight - screenLeft);
|
|
8515
8839
|
const height = Math.abs(screenBottom - screenTop);
|
|
8516
|
-
const [screenCenterX, screenCenterY] =
|
|
8840
|
+
const [screenCenterX, screenCenterY] = applyToPoint58(transform, [
|
|
8517
8841
|
debugObject.center.x,
|
|
8518
8842
|
debugObject.center.y
|
|
8519
8843
|
]);
|
|
@@ -8559,11 +8883,11 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
8559
8883
|
];
|
|
8560
8884
|
}
|
|
8561
8885
|
if (debugObject.shape === "line") {
|
|
8562
|
-
const [screenStartX, screenStartY] =
|
|
8886
|
+
const [screenStartX, screenStartY] = applyToPoint58(transform, [
|
|
8563
8887
|
debugObject.start.x,
|
|
8564
8888
|
debugObject.start.y
|
|
8565
8889
|
]);
|
|
8566
|
-
const [screenEndX, screenEndY] =
|
|
8890
|
+
const [screenEndX, screenEndY] = applyToPoint58(transform, [
|
|
8567
8891
|
debugObject.end.x,
|
|
8568
8892
|
debugObject.end.y
|
|
8569
8893
|
]);
|
|
@@ -8613,7 +8937,7 @@ function createSvgObjectsFromSchDebugObject({
|
|
|
8613
8937
|
}
|
|
8614
8938
|
|
|
8615
8939
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-trace.ts
|
|
8616
|
-
import { applyToPoint as
|
|
8940
|
+
import { applyToPoint as applyToPoint59 } from "transformation-matrix";
|
|
8617
8941
|
function createSchematicTrace({
|
|
8618
8942
|
trace,
|
|
8619
8943
|
transform,
|
|
@@ -8627,11 +8951,11 @@ function createSchematicTrace({
|
|
|
8627
8951
|
for (let edgeIndex = 0; edgeIndex < edges.length; edgeIndex++) {
|
|
8628
8952
|
const edge = edges[edgeIndex];
|
|
8629
8953
|
if (edge.is_crossing) continue;
|
|
8630
|
-
const [screenFromX, screenFromY] =
|
|
8954
|
+
const [screenFromX, screenFromY] = applyToPoint59(transform, [
|
|
8631
8955
|
edge.from.x,
|
|
8632
8956
|
edge.from.y
|
|
8633
8957
|
]);
|
|
8634
|
-
const [screenToX, screenToY] =
|
|
8958
|
+
const [screenToX, screenToY] = applyToPoint59(transform, [
|
|
8635
8959
|
edge.to.x,
|
|
8636
8960
|
edge.to.y
|
|
8637
8961
|
]);
|
|
@@ -8675,11 +8999,11 @@ function createSchematicTrace({
|
|
|
8675
8999
|
}
|
|
8676
9000
|
for (const edge of edges) {
|
|
8677
9001
|
if (!edge.is_crossing) continue;
|
|
8678
|
-
const [screenFromX, screenFromY] =
|
|
9002
|
+
const [screenFromX, screenFromY] = applyToPoint59(transform, [
|
|
8679
9003
|
edge.from.x,
|
|
8680
9004
|
edge.from.y
|
|
8681
9005
|
]);
|
|
8682
|
-
const [screenToX, screenToY] =
|
|
9006
|
+
const [screenToX, screenToY] = applyToPoint59(transform, [
|
|
8683
9007
|
edge.to.x,
|
|
8684
9008
|
edge.to.y
|
|
8685
9009
|
]);
|
|
@@ -8723,7 +9047,7 @@ function createSchematicTrace({
|
|
|
8723
9047
|
}
|
|
8724
9048
|
if (trace.junctions) {
|
|
8725
9049
|
for (const junction of trace.junctions) {
|
|
8726
|
-
const [screenX, screenY] =
|
|
9050
|
+
const [screenX, screenY] = applyToPoint59(transform, [
|
|
8727
9051
|
junction.x,
|
|
8728
9052
|
junction.y
|
|
8729
9053
|
]);
|
|
@@ -8778,7 +9102,7 @@ function createSchematicTrace({
|
|
|
8778
9102
|
|
|
8779
9103
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
|
|
8780
9104
|
import {
|
|
8781
|
-
applyToPoint as
|
|
9105
|
+
applyToPoint as applyToPoint61,
|
|
8782
9106
|
compose as compose11,
|
|
8783
9107
|
rotate as rotate6,
|
|
8784
9108
|
scale as scale6,
|
|
@@ -8787,7 +9111,7 @@ import {
|
|
|
8787
9111
|
|
|
8788
9112
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
|
|
8789
9113
|
import {
|
|
8790
|
-
applyToPoint as
|
|
9114
|
+
applyToPoint as applyToPoint60,
|
|
8791
9115
|
compose as compose10,
|
|
8792
9116
|
rotate as rotate5,
|
|
8793
9117
|
scale as scale5,
|
|
@@ -8862,7 +9186,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8862
9186
|
x: symbolBounds.minX,
|
|
8863
9187
|
y: (symbolBounds.minY + symbolBounds.maxY) / 2
|
|
8864
9188
|
};
|
|
8865
|
-
const rotatedSymbolEnd =
|
|
9189
|
+
const rotatedSymbolEnd = applyToPoint60(rotationMatrix, symbolEndPoint);
|
|
8866
9190
|
const symbolToRealTransform = compose10(
|
|
8867
9191
|
translate10(
|
|
8868
9192
|
realAnchorPosition.x - rotatedSymbolEnd.x,
|
|
@@ -8872,11 +9196,11 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8872
9196
|
scale5(1)
|
|
8873
9197
|
// Use full symbol size
|
|
8874
9198
|
);
|
|
8875
|
-
const [screenMinX, screenMinY] =
|
|
9199
|
+
const [screenMinX, screenMinY] = applyToPoint60(
|
|
8876
9200
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8877
9201
|
[bounds.minX, bounds.minY]
|
|
8878
9202
|
);
|
|
8879
|
-
const [screenMaxX, screenMaxY] =
|
|
9203
|
+
const [screenMaxX, screenMaxY] = applyToPoint60(
|
|
8880
9204
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8881
9205
|
[bounds.maxX, bounds.maxY]
|
|
8882
9206
|
);
|
|
@@ -8900,7 +9224,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8900
9224
|
});
|
|
8901
9225
|
for (const path of symbolPaths) {
|
|
8902
9226
|
const symbolPath = path.points.map((p, i) => {
|
|
8903
|
-
const [x, y] =
|
|
9227
|
+
const [x, y] = applyToPoint60(
|
|
8904
9228
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8905
9229
|
[p.x, p.y]
|
|
8906
9230
|
);
|
|
@@ -8921,7 +9245,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8921
9245
|
});
|
|
8922
9246
|
}
|
|
8923
9247
|
for (const text of symbolTexts) {
|
|
8924
|
-
const screenTextPos =
|
|
9248
|
+
const screenTextPos = applyToPoint60(
|
|
8925
9249
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8926
9250
|
text
|
|
8927
9251
|
);
|
|
@@ -8963,7 +9287,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8963
9287
|
});
|
|
8964
9288
|
}
|
|
8965
9289
|
for (const box of symbolBoxes) {
|
|
8966
|
-
const screenBoxPos =
|
|
9290
|
+
const screenBoxPos = applyToPoint60(
|
|
8967
9291
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8968
9292
|
box
|
|
8969
9293
|
);
|
|
@@ -8986,7 +9310,7 @@ var createSvgObjectsForSchNetLabelWithSymbol = ({
|
|
|
8986
9310
|
});
|
|
8987
9311
|
}
|
|
8988
9312
|
for (const circle of symbolCircles) {
|
|
8989
|
-
const screenCirclePos =
|
|
9313
|
+
const screenCirclePos = applyToPoint60(
|
|
8990
9314
|
compose10(realToScreenTransform, symbolToRealTransform),
|
|
8991
9315
|
circle
|
|
8992
9316
|
);
|
|
@@ -9031,14 +9355,14 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
9031
9355
|
const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
|
|
9032
9356
|
const fontSizeMm = getSchMmFontSize("net_label");
|
|
9033
9357
|
const textWidthFSR = estimateTextWidth(labelText || "");
|
|
9034
|
-
const screenCenter =
|
|
9358
|
+
const screenCenter = applyToPoint61(realToScreenTransform, schNetLabel.center);
|
|
9035
9359
|
const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
|
|
9036
9360
|
schNetLabel.anchor_side
|
|
9037
9361
|
);
|
|
9038
9362
|
const screenTextGrowthVec = { ...realTextGrowthVec };
|
|
9039
9363
|
screenTextGrowthVec.y *= -1;
|
|
9040
9364
|
const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * labelText.length + END_PADDING_FSR;
|
|
9041
|
-
const screenAnchorPosition = schNetLabel.anchor_position ?
|
|
9365
|
+
const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint61(realToScreenTransform, schNetLabel.anchor_position) : {
|
|
9042
9366
|
x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
|
|
9043
9367
|
y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
|
|
9044
9368
|
};
|
|
@@ -9079,7 +9403,7 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
9079
9403
|
y: -0.6
|
|
9080
9404
|
}
|
|
9081
9405
|
].map(
|
|
9082
|
-
(fontRelativePoint) =>
|
|
9406
|
+
(fontRelativePoint) => applyToPoint61(
|
|
9083
9407
|
compose11(
|
|
9084
9408
|
realToScreenTransform,
|
|
9085
9409
|
translate11(realAnchorPosition.x, realAnchorPosition.y),
|
|
@@ -9156,17 +9480,17 @@ var createSvgObjectsForSchNetLabel = ({
|
|
|
9156
9480
|
};
|
|
9157
9481
|
|
|
9158
9482
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-box.ts
|
|
9159
|
-
import { applyToPoint as
|
|
9483
|
+
import { applyToPoint as applyToPoint62 } from "transformation-matrix";
|
|
9160
9484
|
var createSvgObjectsFromSchematicBox = ({
|
|
9161
9485
|
schematicBox,
|
|
9162
9486
|
transform,
|
|
9163
9487
|
colorMap: colorMap2
|
|
9164
9488
|
}) => {
|
|
9165
|
-
const topLeft =
|
|
9489
|
+
const topLeft = applyToPoint62(transform, {
|
|
9166
9490
|
x: schematicBox.x,
|
|
9167
9491
|
y: schematicBox.y
|
|
9168
9492
|
});
|
|
9169
|
-
const bottomRight =
|
|
9493
|
+
const bottomRight = applyToPoint62(transform, {
|
|
9170
9494
|
x: schematicBox.x + schematicBox.width,
|
|
9171
9495
|
y: schematicBox.y + schematicBox.height
|
|
9172
9496
|
});
|
|
@@ -9202,7 +9526,7 @@ var createSvgObjectsFromSchematicBox = ({
|
|
|
9202
9526
|
};
|
|
9203
9527
|
|
|
9204
9528
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-table.ts
|
|
9205
|
-
import { applyToPoint as
|
|
9529
|
+
import { applyToPoint as applyToPoint63 } from "transformation-matrix";
|
|
9206
9530
|
var createSvgObjectsFromSchematicTable = ({
|
|
9207
9531
|
schematicTable,
|
|
9208
9532
|
transform,
|
|
@@ -9235,11 +9559,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
9235
9559
|
const svgObjects = [];
|
|
9236
9560
|
const borderStrokeWidth = border_width * Math.abs(transform.a);
|
|
9237
9561
|
const gridStrokeWidth = getSchStrokeSize(transform);
|
|
9238
|
-
const [screenTopLeftX, screenTopLeftY] =
|
|
9562
|
+
const [screenTopLeftX, screenTopLeftY] = applyToPoint63(transform, [
|
|
9239
9563
|
topLeftX,
|
|
9240
9564
|
topLeftY
|
|
9241
9565
|
]);
|
|
9242
|
-
const [screenBottomRightX, screenBottomRightY] =
|
|
9566
|
+
const [screenBottomRightX, screenBottomRightY] = applyToPoint63(transform, [
|
|
9243
9567
|
topLeftX + totalWidth,
|
|
9244
9568
|
topLeftY - totalHeight
|
|
9245
9569
|
]);
|
|
@@ -9271,8 +9595,8 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
9271
9595
|
(cell) => cell.start_column_index <= i && cell.end_column_index > i && cell.start_row_index <= j && cell.end_row_index >= j
|
|
9272
9596
|
);
|
|
9273
9597
|
if (!isMerged) {
|
|
9274
|
-
const start =
|
|
9275
|
-
const end =
|
|
9598
|
+
const start = applyToPoint63(transform, { x: currentX, y: segmentStartY });
|
|
9599
|
+
const end = applyToPoint63(transform, { x: currentX, y: segmentEndY });
|
|
9276
9600
|
svgObjects.push({
|
|
9277
9601
|
name: "line",
|
|
9278
9602
|
type: "element",
|
|
@@ -9301,11 +9625,11 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
9301
9625
|
(cell) => cell.start_row_index <= i && cell.end_row_index > i && cell.start_column_index <= j && cell.end_column_index >= j
|
|
9302
9626
|
);
|
|
9303
9627
|
if (!isMerged) {
|
|
9304
|
-
const start =
|
|
9628
|
+
const start = applyToPoint63(transform, {
|
|
9305
9629
|
x: segmentStartX,
|
|
9306
9630
|
y: currentY
|
|
9307
9631
|
});
|
|
9308
|
-
const end =
|
|
9632
|
+
const end = applyToPoint63(transform, { x: segmentEndX, y: currentY });
|
|
9309
9633
|
svgObjects.push({
|
|
9310
9634
|
name: "line",
|
|
9311
9635
|
type: "element",
|
|
@@ -9347,7 +9671,7 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
9347
9671
|
} else if (vertical_align === "bottom") {
|
|
9348
9672
|
realTextAnchorPos.y = cellTopLeftY - cellHeight + cell_padding;
|
|
9349
9673
|
}
|
|
9350
|
-
const screenTextAnchorPos =
|
|
9674
|
+
const screenTextAnchorPos = applyToPoint63(transform, realTextAnchorPos);
|
|
9351
9675
|
const fontSize = getSchScreenFontSize(
|
|
9352
9676
|
transform,
|
|
9353
9677
|
"reference_designator",
|
|
@@ -9403,13 +9727,13 @@ var createSvgObjectsFromSchematicTable = ({
|
|
|
9403
9727
|
|
|
9404
9728
|
// lib/sch/svg-object-fns/create-svg-objects-for-sch-port-hover.ts
|
|
9405
9729
|
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
9406
|
-
import { applyToPoint as
|
|
9730
|
+
import { applyToPoint as applyToPoint64 } from "transformation-matrix";
|
|
9407
9731
|
var PIN_CIRCLE_RADIUS_MM2 = 0.02;
|
|
9408
9732
|
var createSvgObjectsForSchPortHover = ({
|
|
9409
9733
|
schPort,
|
|
9410
9734
|
transform
|
|
9411
9735
|
}) => {
|
|
9412
|
-
const screenSchPortPos =
|
|
9736
|
+
const screenSchPortPos = applyToPoint64(transform, schPort.center);
|
|
9413
9737
|
const pinRadiusPx = Math.abs(transform.a) * PIN_CIRCLE_RADIUS_MM2 * 2;
|
|
9414
9738
|
return [
|
|
9415
9739
|
{
|
|
@@ -9454,14 +9778,14 @@ var createSvgObjectsForSchComponentPortHovers = ({
|
|
|
9454
9778
|
};
|
|
9455
9779
|
|
|
9456
9780
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-line.ts
|
|
9457
|
-
import { applyToPoint as
|
|
9781
|
+
import { applyToPoint as applyToPoint65 } from "transformation-matrix";
|
|
9458
9782
|
function createSvgObjectsFromSchematicLine({
|
|
9459
9783
|
schLine,
|
|
9460
9784
|
transform,
|
|
9461
9785
|
colorMap: colorMap2
|
|
9462
9786
|
}) {
|
|
9463
|
-
const p1 =
|
|
9464
|
-
const p2 =
|
|
9787
|
+
const p1 = applyToPoint65(transform, { x: schLine.x1, y: schLine.y1 });
|
|
9788
|
+
const p2 = applyToPoint65(transform, { x: schLine.x2, y: schLine.y2 });
|
|
9465
9789
|
const strokeWidth = schLine.stroke_width ?? 0.02;
|
|
9466
9790
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
9467
9791
|
return [
|
|
@@ -9490,13 +9814,13 @@ function createSvgObjectsFromSchematicLine({
|
|
|
9490
9814
|
}
|
|
9491
9815
|
|
|
9492
9816
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-circle.ts
|
|
9493
|
-
import { applyToPoint as
|
|
9817
|
+
import { applyToPoint as applyToPoint66 } from "transformation-matrix";
|
|
9494
9818
|
function createSvgObjectsFromSchematicCircle({
|
|
9495
9819
|
schCircle,
|
|
9496
9820
|
transform,
|
|
9497
9821
|
colorMap: colorMap2
|
|
9498
9822
|
}) {
|
|
9499
|
-
const center =
|
|
9823
|
+
const center = applyToPoint66(transform, schCircle.center);
|
|
9500
9824
|
const transformedRadius = Math.abs(transform.a) * schCircle.radius;
|
|
9501
9825
|
const strokeWidth = schCircle.stroke_width ?? 0.02;
|
|
9502
9826
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -9526,13 +9850,13 @@ function createSvgObjectsFromSchematicCircle({
|
|
|
9526
9850
|
}
|
|
9527
9851
|
|
|
9528
9852
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-rect.ts
|
|
9529
|
-
import { applyToPoint as
|
|
9853
|
+
import { applyToPoint as applyToPoint67 } from "transformation-matrix";
|
|
9530
9854
|
function createSvgObjectsFromSchematicRect({
|
|
9531
9855
|
schRect,
|
|
9532
9856
|
transform,
|
|
9533
9857
|
colorMap: colorMap2
|
|
9534
9858
|
}) {
|
|
9535
|
-
const center =
|
|
9859
|
+
const center = applyToPoint67(transform, schRect.center);
|
|
9536
9860
|
const transformedWidth = Math.abs(transform.a) * schRect.width;
|
|
9537
9861
|
const transformedHeight = Math.abs(transform.d) * schRect.height;
|
|
9538
9862
|
const strokeWidth = schRect.stroke_width ?? 0.02;
|
|
@@ -9568,13 +9892,13 @@ function createSvgObjectsFromSchematicRect({
|
|
|
9568
9892
|
}
|
|
9569
9893
|
|
|
9570
9894
|
// lib/sch/svg-object-fns/create-svg-objects-from-sch-arc.ts
|
|
9571
|
-
import { applyToPoint as
|
|
9895
|
+
import { applyToPoint as applyToPoint68 } from "transformation-matrix";
|
|
9572
9896
|
function createSvgObjectsFromSchematicArc({
|
|
9573
9897
|
schArc,
|
|
9574
9898
|
transform,
|
|
9575
9899
|
colorMap: colorMap2
|
|
9576
9900
|
}) {
|
|
9577
|
-
const center =
|
|
9901
|
+
const center = applyToPoint68(transform, schArc.center);
|
|
9578
9902
|
const transformedRadius = Math.abs(transform.a) * schArc.radius;
|
|
9579
9903
|
const strokeWidth = schArc.stroke_width ?? 0.02;
|
|
9580
9904
|
const transformedStrokeWidth = Math.abs(transform.a) * strokeWidth;
|
|
@@ -10659,18 +10983,18 @@ function formatNumber2(value) {
|
|
|
10659
10983
|
import { distance as distance2 } from "circuit-json";
|
|
10660
10984
|
import { stringify as stringify7 } from "svgson";
|
|
10661
10985
|
import {
|
|
10662
|
-
applyToPoint as
|
|
10986
|
+
applyToPoint as applyToPoint71,
|
|
10663
10987
|
compose as compose14,
|
|
10664
10988
|
scale as scale8,
|
|
10665
10989
|
translate as translate14
|
|
10666
10990
|
} from "transformation-matrix";
|
|
10667
10991
|
|
|
10668
10992
|
// lib/pcb/svg-object-fns/convert-circuit-json-to-solder-paste-mask.ts
|
|
10669
|
-
import { applyToPoint as
|
|
10993
|
+
import { applyToPoint as applyToPoint70 } from "transformation-matrix";
|
|
10670
10994
|
function createSvgObjectsFromSolderPaste(solderPaste, ctx) {
|
|
10671
10995
|
const { transform, layer: layerFilter } = ctx;
|
|
10672
10996
|
if (layerFilter && solderPaste.layer !== layerFilter) return [];
|
|
10673
|
-
const [x, y] =
|
|
10997
|
+
const [x, y] = applyToPoint70(transform, [solderPaste.x, solderPaste.y]);
|
|
10674
10998
|
if (solderPaste.shape === "rect" || solderPaste.shape === "rotated_rect") {
|
|
10675
10999
|
const width = solderPaste.width * Math.abs(transform.a);
|
|
10676
11000
|
const height = solderPaste.height * Math.abs(transform.d);
|
|
@@ -10895,8 +11219,8 @@ function createSvgObjects4({ elm, ctx }) {
|
|
|
10895
11219
|
}
|
|
10896
11220
|
}
|
|
10897
11221
|
function createSvgObjectFromPcbBoundary2(transform, minX, minY, maxX, maxY) {
|
|
10898
|
-
const [x1, y1] =
|
|
10899
|
-
const [x2, y2] =
|
|
11222
|
+
const [x1, y1] = applyToPoint71(transform, [minX, minY]);
|
|
11223
|
+
const [x2, y2] = applyToPoint71(transform, [maxX, maxY]);
|
|
10900
11224
|
const width = Math.abs(x2 - x1);
|
|
10901
11225
|
const height = Math.abs(y2 - y1);
|
|
10902
11226
|
const x = Math.min(x1, x2);
|