circuit-to-svg 0.0.92 → 0.0.93

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 CHANGED
@@ -2577,11 +2577,11 @@ function createSchematicTrace(trace, transform) {
2577
2577
 
2578
2578
  // lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
2579
2579
  import {
2580
- applyToPoint as applyToPoint29,
2581
- compose as compose7,
2582
- rotate as rotate3,
2583
- scale as scale4,
2584
- translate as translate7
2580
+ applyToPoint as applyToPoint30,
2581
+ compose as compose8,
2582
+ rotate as rotate4,
2583
+ scale as scale5,
2584
+ translate as translate8
2585
2585
  } from "transformation-matrix";
2586
2586
 
2587
2587
  // lib/sch/arial-text-metrics.ts
@@ -3363,193 +3363,22 @@ var estimateTextWidth = (text) => {
3363
3363
  return totalWidth / 27;
3364
3364
  };
3365
3365
 
3366
- // lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
3367
- var ARROW_POINT_WIDTH_FSR = 0.3;
3368
- var END_PADDING_FSR = 0.3;
3369
- var END_PADDING_EXTRA_PER_CHARACTER_FSR = 0.06;
3370
- var createSvgObjectsForSchNetLabel = (schNetLabel, realToScreenTransform) => {
3371
- if (!schNetLabel.text) return [];
3372
- const svgObjects = [];
3373
- const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
3374
- const fontSizeMm = getSchMmFontSize("net_label");
3375
- const textWidthFSR = estimateTextWidth(schNetLabel.text || "");
3376
- const screenCenter = applyToPoint29(realToScreenTransform, schNetLabel.center);
3377
- const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
3378
- schNetLabel.anchor_side
3379
- );
3380
- const screenTextGrowthVec = { ...realTextGrowthVec };
3381
- screenTextGrowthVec.y *= -1;
3382
- const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + END_PADDING_FSR;
3383
- const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint29(realToScreenTransform, schNetLabel.anchor_position) : {
3384
- x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
3385
- y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
3386
- };
3387
- const realAnchorPosition = schNetLabel.anchor_position ?? {
3388
- x: schNetLabel.center.x - realTextGrowthVec.x * fullWidthFsr * fontSizeMm / 2,
3389
- y: schNetLabel.center.y - realTextGrowthVec.y * fullWidthFsr * fontSizeMm / 2
3390
- };
3391
- const pathRotation = {
3392
- left: 0,
3393
- top: -90,
3394
- bottom: 90,
3395
- right: 180
3396
- }[schNetLabel.anchor_side];
3397
- const screenOutlinePoints = [
3398
- // Arrow point in font-relative coordinates
3399
- {
3400
- x: 0,
3401
- y: 0
3402
- },
3403
- // Top left corner in font-relative coordinates
3404
- {
3405
- x: ARROW_POINT_WIDTH_FSR,
3406
- y: 0.6
3407
- },
3408
- // Top right corner in font-relative coordinates
3409
- {
3410
- x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + textWidthFSR,
3411
- y: 0.6
3412
- },
3413
- // Bottom right corner in font-relative coordinates
3414
- {
3415
- x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + textWidthFSR,
3416
- y: -0.6
3417
- },
3418
- // Bottom left corner in font-relative coordinates
3419
- {
3420
- x: ARROW_POINT_WIDTH_FSR,
3421
- y: -0.6
3422
- }
3423
- ].map(
3424
- (fontRelativePoint) => applyToPoint29(
3425
- compose7(
3426
- realToScreenTransform,
3427
- translate7(realAnchorPosition.x, realAnchorPosition.y),
3428
- scale4(fontSizeMm),
3429
- rotate3(pathRotation / 180 * Math.PI)
3430
- ),
3431
- fontRelativePoint
3432
- )
3433
- );
3434
- const pathD = `
3435
- M ${screenOutlinePoints[0].x},${screenOutlinePoints[0].y}
3436
- L ${screenOutlinePoints[1].x},${screenOutlinePoints[1].y}
3437
- L ${screenOutlinePoints[2].x},${screenOutlinePoints[2].y}
3438
- L ${screenOutlinePoints[3].x},${screenOutlinePoints[3].y}
3439
- L ${screenOutlinePoints[4].x},${screenOutlinePoints[4].y}
3440
- Z
3441
- `;
3442
- svgObjects.push({
3443
- name: "path",
3444
- type: "element",
3445
- attributes: {
3446
- class: "net-label",
3447
- d: pathD,
3448
- fill: "white",
3449
- stroke: colorMap.schematic.label_global,
3450
- "stroke-width": `${getSchStrokeSize(realToScreenTransform)}px`
3451
- },
3452
- value: "",
3453
- children: []
3454
- });
3455
- const screenTextPos = {
3456
- x: screenAnchorPosition.x + screenTextGrowthVec.x * fontSizePx * 0.5,
3457
- y: screenAnchorPosition.y + screenTextGrowthVec.y * fontSizePx * 0.5
3458
- };
3459
- const textAnchor = {
3460
- left: "start",
3461
- top: "start",
3462
- bottom: "start",
3463
- right: "end"
3464
- }[schNetLabel.anchor_side];
3465
- const textTransformString = {
3466
- left: "",
3467
- right: "",
3468
- top: `rotate(90 ${screenTextPos.x} ${screenTextPos.y})`,
3469
- bottom: `rotate(-90 ${screenTextPos.x} ${screenTextPos.y})`
3470
- }[schNetLabel.anchor_side];
3471
- svgObjects.push({
3472
- name: "text",
3473
- type: "element",
3474
- attributes: {
3475
- class: "net-label-text",
3476
- x: screenTextPos.x.toString(),
3477
- y: screenTextPos.y.toString(),
3478
- fill: colorMap.schematic.label_global,
3479
- "text-anchor": textAnchor,
3480
- "dominant-baseline": "central",
3481
- "font-family": "sans-serif",
3482
- "font-variant-numeric": "tabular-nums",
3483
- "font-size": `${fontSizePx}px`,
3484
- transform: textTransformString
3485
- },
3486
- children: [
3487
- {
3488
- type: "text",
3489
- value: schNetLabel.text || "",
3490
- name: "",
3491
- attributes: {},
3492
- children: []
3493
- }
3494
- ],
3495
- value: ""
3496
- });
3497
- return svgObjects;
3498
- };
3499
-
3500
- // lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
3501
- import { applyToPoint as applyToPoint30 } from "transformation-matrix";
3502
- var createSvgSchText = (elm, transform) => {
3503
- const center = applyToPoint30(transform, elm.position);
3504
- const textAnchorMap = {
3505
- center: "middle",
3506
- left: "start",
3507
- right: "end",
3508
- top: "middle",
3509
- bottom: "middle"
3510
- };
3511
- const dominantBaselineMap = {
3512
- center: "middle",
3513
- left: "middle",
3514
- right: "middle",
3515
- top: "hanging",
3516
- bottom: "ideographic"
3517
- };
3518
- return {
3519
- type: "element",
3520
- name: "text",
3521
- value: "",
3522
- attributes: {
3523
- x: center.x.toString(),
3524
- y: center.y.toString(),
3525
- fill: elm.color ?? colorMap.schematic.sheet_label,
3526
- "text-anchor": textAnchorMap[elm.anchor],
3527
- "dominant-baseline": dominantBaselineMap[elm.anchor],
3528
- "font-family": "sans-serif",
3529
- "font-size": `${getSchScreenFontSize(transform, "reference_designator")}px`,
3530
- transform: `rotate(${elm.rotation}, ${center.x}, ${center.y})`
3531
- },
3532
- children: [
3533
- {
3534
- type: "text",
3535
- value: elm.text,
3536
- name: elm.schematic_text_id,
3537
- attributes: {},
3538
- children: []
3539
- }
3540
- ]
3541
- };
3542
- };
3543
-
3544
- // lib/sch/svg-object-fns/create-svg-objects-for-sch-net-symbol.ts
3366
+ // lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
3545
3367
  import {
3546
- applyToPoint as applyToPoint31,
3547
- compose as compose8,
3548
- rotate as rotate4,
3549
- scale as scale5,
3550
- translate as translate8
3368
+ applyToPoint as applyToPoint29,
3369
+ compose as compose7,
3370
+ rotate as rotate3,
3371
+ scale as scale4,
3372
+ translate as translate7
3551
3373
  } from "transformation-matrix";
3552
3374
  import { symbols as symbols3 } from "schematic-symbols";
3375
+
3376
+ // lib/utils/net-label-utils.ts
3377
+ import "transformation-matrix";
3378
+ import "schematic-symbols";
3379
+ var ARROW_POINT_WIDTH_FSR = 0.3;
3380
+ var END_PADDING_FSR = 0.3;
3381
+ var END_PADDING_EXTRA_PER_CHARACTER_FSR = 0.06;
3553
3382
  var ninePointAnchorToTextAnchor2 = {
3554
3383
  top_left: "start",
3555
3384
  top_right: "end",
@@ -3572,13 +3401,27 @@ var ninePointAnchorToDominantBaseline2 = {
3572
3401
  middle_top: "auto",
3573
3402
  middle_bottom: "hanging"
3574
3403
  };
3575
- var ARROW_POINT_WIDTH_FSR2 = 0.3;
3576
- var END_PADDING_FSR2 = 0.3;
3577
- var END_PADDING_EXTRA_PER_CHARACTER_FSR2 = 0.06;
3578
- var createSvgObjectsForSchNetSymbol = (schNetLabel, realToScreenTransform) => {
3404
+ function getTextOffsets(pathRotation, transform) {
3405
+ const scale7 = Math.abs(transform.a);
3406
+ const baseOffset = scale7 * 0.1;
3407
+ const rotationOffsetMap = {
3408
+ "0": { x: baseOffset * 0.8, y: -baseOffset },
3409
+ // Left
3410
+ "-90": { x: baseOffset * 3.3, y: baseOffset * 2.8 },
3411
+ // Top
3412
+ "90": { x: -baseOffset * 3.55, y: -baseOffset * 4.2 },
3413
+ // Bottom
3414
+ "180": { x: -baseOffset * 0.85, y: -baseOffset * 0.2 }
3415
+ // Right
3416
+ };
3417
+ return rotationOffsetMap[pathRotation.toString()] || { x: 0, y: 0 };
3418
+ }
3419
+
3420
+ // lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label-with-symbol.ts
3421
+ var createSvgObjectsForSchNetLabelWithSymbol = (schNetLabel, realToScreenTransform) => {
3579
3422
  if (!schNetLabel.text) return [];
3580
3423
  const svgObjects = [];
3581
- const symbol = symbols3["ground_horz"];
3424
+ const symbol = symbols3[schNetLabel.symbol_name];
3582
3425
  if (!symbol) {
3583
3426
  svgObjects.push(
3584
3427
  createSvgSchErrorText({
@@ -3601,7 +3444,7 @@ var createSvgObjectsForSchNetSymbol = (schNetLabel, realToScreenTransform) => {
3601
3444
  };
3602
3445
  const fontSizeMm = getSchMmFontSize("net_label");
3603
3446
  const textWidthFSR = estimateTextWidth(schNetLabel.text || "");
3604
- const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR2 * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR2 * schNetLabel.text.length + END_PADDING_FSR2;
3447
+ const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + END_PADDING_FSR;
3605
3448
  const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
3606
3449
  schNetLabel.anchor_side
3607
3450
  );
@@ -3615,7 +3458,7 @@ var createSvgObjectsForSchNetSymbol = (schNetLabel, realToScreenTransform) => {
3615
3458
  bottom: 90,
3616
3459
  right: 180
3617
3460
  }[schNetLabel.anchor_side];
3618
- const rotationMatrix = rotate4(pathRotation / 180 * Math.PI);
3461
+ const rotationMatrix = rotate3(pathRotation / 180 * Math.PI);
3619
3462
  const symbolBounds = {
3620
3463
  minX: Math.min(
3621
3464
  ...symbol.primitives.flatMap(
@@ -3642,22 +3485,22 @@ var createSvgObjectsForSchNetSymbol = (schNetLabel, realToScreenTransform) => {
3642
3485
  x: symbolBounds.minX,
3643
3486
  y: (symbolBounds.minY + symbolBounds.maxY) / 2
3644
3487
  };
3645
- const rotatedSymbolEnd = applyToPoint31(rotationMatrix, symbolEndPoint);
3646
- const symbolToRealTransform = compose8(
3647
- translate8(
3488
+ const rotatedSymbolEnd = applyToPoint29(rotationMatrix, symbolEndPoint);
3489
+ const symbolToRealTransform = compose7(
3490
+ translate7(
3648
3491
  realAnchorPosition.x - rotatedSymbolEnd.x,
3649
3492
  realAnchorPosition.y - rotatedSymbolEnd.y
3650
3493
  ),
3651
3494
  rotationMatrix,
3652
- scale5(1)
3495
+ scale4(1)
3653
3496
  // Use full symbol size
3654
3497
  );
3655
- const [screenMinX, screenMinY] = applyToPoint31(
3656
- compose8(realToScreenTransform, symbolToRealTransform),
3498
+ const [screenMinX, screenMinY] = applyToPoint29(
3499
+ compose7(realToScreenTransform, symbolToRealTransform),
3657
3500
  [bounds.minX, bounds.minY]
3658
3501
  );
3659
- const [screenMaxX, screenMaxY] = applyToPoint31(
3660
- compose8(realToScreenTransform, symbolToRealTransform),
3502
+ const [screenMaxX, screenMaxY] = applyToPoint29(
3503
+ compose7(realToScreenTransform, symbolToRealTransform),
3661
3504
  [bounds.maxX, bounds.maxY]
3662
3505
  );
3663
3506
  const rectHeight = Math.abs(screenMaxY - screenMinY);
@@ -3680,8 +3523,8 @@ var createSvgObjectsForSchNetSymbol = (schNetLabel, realToScreenTransform) => {
3680
3523
  });
3681
3524
  for (const path of symbolPaths) {
3682
3525
  const symbolPath = path.points.map((p, i) => {
3683
- const [x, y] = applyToPoint31(
3684
- compose8(realToScreenTransform, symbolToRealTransform),
3526
+ const [x, y] = applyToPoint29(
3527
+ compose7(realToScreenTransform, symbolToRealTransform),
3685
3528
  [p.x, p.y]
3686
3529
  );
3687
3530
  return `${i === 0 ? "M" : "L"} ${x} ${y}`;
@@ -3700,8 +3543,8 @@ var createSvgObjectsForSchNetSymbol = (schNetLabel, realToScreenTransform) => {
3700
3543
  });
3701
3544
  }
3702
3545
  for (const text of symbolTexts) {
3703
- const screenTextPos = applyToPoint31(
3704
- compose8(realToScreenTransform, symbolToRealTransform),
3546
+ const screenTextPos = applyToPoint29(
3547
+ compose7(realToScreenTransform, symbolToRealTransform),
3705
3548
  text
3706
3549
  );
3707
3550
  let textValue = text.text;
@@ -3710,18 +3553,9 @@ var createSvgObjectsForSchNetSymbol = (schNetLabel, realToScreenTransform) => {
3710
3553
  } else if (textValue === "{VAL}") {
3711
3554
  textValue = "";
3712
3555
  }
3713
- const rotationOffsetMap = {
3714
- "0": { x: 8, y: -10 },
3715
- // Left
3716
- "-90": { x: 33, y: 28 },
3717
- // Top
3718
- "90": { x: -32.5, y: -38 },
3719
- // Bottom
3720
- "180": { x: -8.5, y: -2 }
3721
- // Right
3722
- };
3723
- const currentRotation = pathRotation.toString();
3724
- const rotationOffset = rotationOffsetMap[currentRotation] || { x: 0, y: 0 };
3556
+ const scale7 = Math.abs(realToScreenTransform.a);
3557
+ const baseOffset = scale7 * 0.1;
3558
+ const rotationOffset = getTextOffsets(pathRotation, realToScreenTransform);
3725
3559
  const offsetScreenPos = {
3726
3560
  x: screenTextPos.x + rotationOffset.x,
3727
3561
  y: screenTextPos.y + rotationOffset.y
@@ -3732,7 +3566,7 @@ var createSvgObjectsForSchNetSymbol = (schNetLabel, realToScreenTransform) => {
3732
3566
  attributes: {
3733
3567
  x: offsetScreenPos.x.toString(),
3734
3568
  y: offsetScreenPos.y.toString(),
3735
- fill: colorMap.schematic.label_global,
3569
+ fill: colorMap.schematic.label_local,
3736
3570
  "font-family": "sans-serif",
3737
3571
  "text-anchor": ninePointAnchorToTextAnchor2[text.anchor],
3738
3572
  "dominant-baseline": ninePointAnchorToDominantBaseline2[text.anchor],
@@ -3751,11 +3585,11 @@ var createSvgObjectsForSchNetSymbol = (schNetLabel, realToScreenTransform) => {
3751
3585
  });
3752
3586
  }
3753
3587
  for (const box of symbolBoxes) {
3754
- const screenBoxPos = applyToPoint31(
3755
- compose8(realToScreenTransform, symbolToRealTransform),
3588
+ const screenBoxPos = applyToPoint29(
3589
+ compose7(realToScreenTransform, symbolToRealTransform),
3756
3590
  box
3757
3591
  );
3758
- const symbolToScreenScale = compose8(
3592
+ const symbolToScreenScale = compose7(
3759
3593
  realToScreenTransform,
3760
3594
  symbolToRealTransform
3761
3595
  ).a;
@@ -3774,11 +3608,11 @@ var createSvgObjectsForSchNetSymbol = (schNetLabel, realToScreenTransform) => {
3774
3608
  });
3775
3609
  }
3776
3610
  for (const circle of symbolCircles) {
3777
- const screenCirclePos = applyToPoint31(
3778
- compose8(realToScreenTransform, symbolToRealTransform),
3611
+ const screenCirclePos = applyToPoint29(
3612
+ compose7(realToScreenTransform, symbolToRealTransform),
3779
3613
  circle
3780
3614
  );
3781
- const symbolToScreenScale = compose8(
3615
+ const symbolToScreenScale = compose7(
3782
3616
  realToScreenTransform,
3783
3617
  symbolToRealTransform
3784
3618
  ).a;
@@ -3800,6 +3634,187 @@ var createSvgObjectsForSchNetSymbol = (schNetLabel, realToScreenTransform) => {
3800
3634
  return svgObjects;
3801
3635
  };
3802
3636
 
3637
+ // lib/sch/svg-object-fns/create-svg-objects-for-sch-net-label.ts
3638
+ var createSvgObjectsForSchNetLabel = (schNetLabel, realToScreenTransform) => {
3639
+ if (!schNetLabel.text) return [];
3640
+ if (schNetLabel.symbol_name) {
3641
+ return createSvgObjectsForSchNetLabelWithSymbol(
3642
+ schNetLabel,
3643
+ realToScreenTransform
3644
+ );
3645
+ }
3646
+ const svgObjects = [];
3647
+ const fontSizePx = getSchScreenFontSize(realToScreenTransform, "net_label");
3648
+ const fontSizeMm = getSchMmFontSize("net_label");
3649
+ const textWidthFSR = estimateTextWidth(schNetLabel.text || "");
3650
+ const screenCenter = applyToPoint30(realToScreenTransform, schNetLabel.center);
3651
+ const realTextGrowthVec = getUnitVectorFromOutsideToEdge(
3652
+ schNetLabel.anchor_side
3653
+ );
3654
+ const screenTextGrowthVec = { ...realTextGrowthVec };
3655
+ screenTextGrowthVec.y *= -1;
3656
+ const fullWidthFsr = textWidthFSR + ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + END_PADDING_FSR;
3657
+ const screenAnchorPosition = schNetLabel.anchor_position ? applyToPoint30(realToScreenTransform, schNetLabel.anchor_position) : {
3658
+ x: screenCenter.x - screenTextGrowthVec.x * fullWidthFsr * fontSizePx / 2,
3659
+ y: screenCenter.y - screenTextGrowthVec.y * fullWidthFsr * fontSizePx / 2
3660
+ };
3661
+ const realAnchorPosition = schNetLabel.anchor_position ?? {
3662
+ x: schNetLabel.center.x - realTextGrowthVec.x * fullWidthFsr * fontSizeMm / 2,
3663
+ y: schNetLabel.center.y - realTextGrowthVec.y * fullWidthFsr * fontSizeMm / 2
3664
+ };
3665
+ const pathRotation = {
3666
+ left: 0,
3667
+ top: -90,
3668
+ bottom: 90,
3669
+ right: 180
3670
+ }[schNetLabel.anchor_side];
3671
+ const screenOutlinePoints = [
3672
+ // Arrow point in font-relative coordinates
3673
+ {
3674
+ x: 0,
3675
+ y: 0
3676
+ },
3677
+ // Top left corner in font-relative coordinates
3678
+ {
3679
+ x: ARROW_POINT_WIDTH_FSR,
3680
+ y: 0.6
3681
+ },
3682
+ // Top right corner in font-relative coordinates
3683
+ {
3684
+ x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + textWidthFSR,
3685
+ y: 0.6
3686
+ },
3687
+ // Bottom right corner in font-relative coordinates
3688
+ {
3689
+ x: ARROW_POINT_WIDTH_FSR * 2 + END_PADDING_FSR + END_PADDING_EXTRA_PER_CHARACTER_FSR * schNetLabel.text.length + textWidthFSR,
3690
+ y: -0.6
3691
+ },
3692
+ // Bottom left corner in font-relative coordinates
3693
+ {
3694
+ x: ARROW_POINT_WIDTH_FSR,
3695
+ y: -0.6
3696
+ }
3697
+ ].map(
3698
+ (fontRelativePoint) => applyToPoint30(
3699
+ compose8(
3700
+ realToScreenTransform,
3701
+ translate8(realAnchorPosition.x, realAnchorPosition.y),
3702
+ scale5(fontSizeMm),
3703
+ rotate4(pathRotation / 180 * Math.PI)
3704
+ ),
3705
+ fontRelativePoint
3706
+ )
3707
+ );
3708
+ const pathD = `
3709
+ M ${screenOutlinePoints[0].x},${screenOutlinePoints[0].y}
3710
+ L ${screenOutlinePoints[1].x},${screenOutlinePoints[1].y}
3711
+ L ${screenOutlinePoints[2].x},${screenOutlinePoints[2].y}
3712
+ L ${screenOutlinePoints[3].x},${screenOutlinePoints[3].y}
3713
+ L ${screenOutlinePoints[4].x},${screenOutlinePoints[4].y}
3714
+ Z
3715
+ `;
3716
+ svgObjects.push({
3717
+ name: "path",
3718
+ type: "element",
3719
+ attributes: {
3720
+ class: "net-label",
3721
+ d: pathD,
3722
+ fill: "white",
3723
+ stroke: colorMap.schematic.label_global,
3724
+ "stroke-width": `${getSchStrokeSize(realToScreenTransform)}px`
3725
+ },
3726
+ value: "",
3727
+ children: []
3728
+ });
3729
+ const screenTextPos = {
3730
+ x: screenAnchorPosition.x + screenTextGrowthVec.x * fontSizePx * 0.5,
3731
+ y: screenAnchorPosition.y + screenTextGrowthVec.y * fontSizePx * 0.5
3732
+ };
3733
+ const textAnchor = {
3734
+ left: "start",
3735
+ top: "start",
3736
+ bottom: "start",
3737
+ right: "end"
3738
+ }[schNetLabel.anchor_side];
3739
+ const textTransformString = {
3740
+ left: "",
3741
+ right: "",
3742
+ top: `rotate(90 ${screenTextPos.x} ${screenTextPos.y})`,
3743
+ bottom: `rotate(-90 ${screenTextPos.x} ${screenTextPos.y})`
3744
+ }[schNetLabel.anchor_side];
3745
+ svgObjects.push({
3746
+ name: "text",
3747
+ type: "element",
3748
+ attributes: {
3749
+ class: "net-label-text",
3750
+ x: screenTextPos.x.toString(),
3751
+ y: screenTextPos.y.toString(),
3752
+ fill: colorMap.schematic.label_global,
3753
+ "text-anchor": textAnchor,
3754
+ "dominant-baseline": "central",
3755
+ "font-family": "sans-serif",
3756
+ "font-variant-numeric": "tabular-nums",
3757
+ "font-size": `${fontSizePx}px`,
3758
+ transform: textTransformString
3759
+ },
3760
+ children: [
3761
+ {
3762
+ type: "text",
3763
+ value: schNetLabel.text || "",
3764
+ name: "",
3765
+ attributes: {},
3766
+ children: []
3767
+ }
3768
+ ],
3769
+ value: ""
3770
+ });
3771
+ return svgObjects;
3772
+ };
3773
+
3774
+ // lib/sch/svg-object-fns/create-svg-objects-for-sch-text.ts
3775
+ import { applyToPoint as applyToPoint31 } from "transformation-matrix";
3776
+ var createSvgSchText = (elm, transform) => {
3777
+ const center = applyToPoint31(transform, elm.position);
3778
+ const textAnchorMap = {
3779
+ center: "middle",
3780
+ left: "start",
3781
+ right: "end",
3782
+ top: "middle",
3783
+ bottom: "middle"
3784
+ };
3785
+ const dominantBaselineMap = {
3786
+ center: "middle",
3787
+ left: "middle",
3788
+ right: "middle",
3789
+ top: "hanging",
3790
+ bottom: "ideographic"
3791
+ };
3792
+ return {
3793
+ type: "element",
3794
+ name: "text",
3795
+ value: "",
3796
+ attributes: {
3797
+ x: center.x.toString(),
3798
+ y: center.y.toString(),
3799
+ fill: elm.color ?? colorMap.schematic.sheet_label,
3800
+ "text-anchor": textAnchorMap[elm.anchor],
3801
+ "dominant-baseline": dominantBaselineMap[elm.anchor],
3802
+ "font-family": "sans-serif",
3803
+ "font-size": `${getSchScreenFontSize(transform, "reference_designator")}px`,
3804
+ transform: `rotate(${elm.rotation}, ${center.x}, ${center.y})`
3805
+ },
3806
+ children: [
3807
+ {
3808
+ type: "text",
3809
+ value: elm.text,
3810
+ name: elm.schematic_text_id,
3811
+ attributes: {},
3812
+ children: []
3813
+ }
3814
+ ]
3815
+ };
3816
+ };
3817
+
3803
3818
  // lib/sch/convert-circuit-json-to-schematic-svg.ts
3804
3819
  function convertCircuitJsonToSchematicSvg(circuitJson, options) {
3805
3820
  const realBounds = getSchematicBoundsFromCircuitJson(circuitJson);
@@ -3877,7 +3892,7 @@ function convertCircuitJsonToSchematicSvg(circuitJson, options) {
3877
3892
  } else if (elm.type === "schematic_trace") {
3878
3893
  schTraceSvgs.push(...createSchematicTrace(elm, transform));
3879
3894
  } else if (elm.type === "schematic_net_label") {
3880
- elm.symbol_name ? schNetLabel.push(...createSvgObjectsForSchNetSymbol(elm, transform)) : schNetLabel.push(...createSvgObjectsForSchNetLabel(elm, transform));
3895
+ schNetLabel.push(...createSvgObjectsForSchNetLabel(elm, transform));
3881
3896
  } else if (elm.type === "schematic_text") {
3882
3897
  schText.push(createSvgSchText(elm, transform));
3883
3898
  } else if (elm.type === "schematic_voltage_probe") {