circuit-to-svg 0.0.193 → 0.0.194

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
@@ -485,11 +485,19 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
485
485
  ];
486
486
  }
487
487
  if (hole.shape === "pill_hole_with_rect_pad") {
488
- const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
489
- const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
490
- const scaledRectBorderRadius = (hole.rect_border_radius ?? 0) * Math.abs(transform.a);
491
- const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
492
- const scaledHoleWidth = hole.hole_width * Math.abs(transform.a);
488
+ const pillHole = hole;
489
+ const scaledRectPadWidth = pillHole.rect_pad_width * Math.abs(transform.a);
490
+ const scaledRectPadHeight = pillHole.rect_pad_height * Math.abs(transform.a);
491
+ const scaledRectBorderRadius = (pillHole.rect_border_radius ?? 0) * Math.abs(transform.a);
492
+ const scaledHoleHeight = pillHole.hole_height * Math.abs(transform.a);
493
+ const scaledHoleWidth = pillHole.hole_width * Math.abs(transform.a);
494
+ const pillHoleWithOffsets = pillHole;
495
+ const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
496
+ const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
497
+ const [holeCenterX, holeCenterY] = applyToPoint4(transform, [
498
+ pillHole.x + holeOffsetX,
499
+ pillHole.y + holeOffsetY
500
+ ]);
493
501
  const holeRadius = Math.min(scaledHoleHeight, scaledHoleWidth) / 2;
494
502
  return [
495
503
  {
@@ -522,8 +530,8 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
522
530
  attributes: {
523
531
  class: "pcb-hole-inner",
524
532
  fill: colorMap2.drill,
525
- x: (x - scaledHoleWidth / 2).toString(),
526
- y: (y - scaledHoleHeight / 2).toString(),
533
+ x: (holeCenterX - scaledHoleWidth / 2).toString(),
534
+ y: (holeCenterY - scaledHoleHeight / 2).toString(),
527
535
  width: scaledHoleWidth.toString(),
528
536
  height: scaledHoleHeight.toString(),
529
537
  rx: holeRadius.toString(),
@@ -539,11 +547,19 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
539
547
  ];
540
548
  }
541
549
  if (hole.shape === "rotated_pill_hole_with_rect_pad") {
542
- const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
543
- const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
544
- const scaledRectBorderRadius = (hole.rect_border_radius ?? 0) * Math.abs(transform.a);
545
- const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
546
- const scaledHoleWidth = hole.hole_width * Math.abs(transform.a);
550
+ const rotatedHole = hole;
551
+ const scaledRectPadWidth = rotatedHole.rect_pad_width * Math.abs(transform.a);
552
+ const scaledRectPadHeight = rotatedHole.rect_pad_height * Math.abs(transform.a);
553
+ const scaledRectBorderRadius = (rotatedHole.rect_border_radius ?? 0) * Math.abs(transform.a);
554
+ const scaledHoleHeight = rotatedHole.hole_height * Math.abs(transform.a);
555
+ const scaledHoleWidth = rotatedHole.hole_width * Math.abs(transform.a);
556
+ const rotatedHoleWithOffsets = rotatedHole;
557
+ const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
558
+ const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
559
+ const [holeCenterX, holeCenterY] = applyToPoint4(transform, [
560
+ rotatedHole.x + holeOffsetX,
561
+ rotatedHole.y + holeOffsetY
562
+ ]);
547
563
  const holeRadius = Math.min(scaledHoleHeight, scaledHoleWidth) / 2;
548
564
  return [
549
565
  {
@@ -560,7 +576,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
560
576
  y: (-scaledRectPadHeight / 2).toString(),
561
577
  width: scaledRectPadWidth.toString(),
562
578
  height: scaledRectPadHeight.toString(),
563
- transform: `translate(${x} ${y}) rotate(${-hole.rect_ccw_rotation})`,
579
+ transform: `translate(${x} ${y}) rotate(${-rotatedHole.rect_ccw_rotation})`,
564
580
  ...scaledRectBorderRadius ? {
565
581
  rx: scaledRectBorderRadius.toString(),
566
582
  ry: scaledRectBorderRadius.toString()
@@ -581,7 +597,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
581
597
  height: scaledHoleHeight.toString(),
582
598
  rx: holeRadius.toString(),
583
599
  ry: holeRadius.toString(),
584
- transform: `translate(${x} ${y}) rotate(${-hole.hole_ccw_rotation})`
600
+ transform: `translate(${holeCenterX} ${holeCenterY}) rotate(${-rotatedHole.hole_ccw_rotation})`
585
601
  },
586
602
  value: "",
587
603
  children: []
@@ -1650,7 +1666,7 @@ function getSoftwareUsedString(circuitJson) {
1650
1666
  var package_default = {
1651
1667
  name: "circuit-to-svg",
1652
1668
  type: "module",
1653
- version: "0.0.192",
1669
+ version: "0.0.193",
1654
1670
  description: "Convert Circuit JSON to SVG",
1655
1671
  main: "dist/index.js",
1656
1672
  files: [
@@ -1674,6 +1690,7 @@ var package_default = {
1674
1690
  "bun-match-svg": "^0.0.12",
1675
1691
  esbuild: "^0.20.2",
1676
1692
  "performance-now": "^2.1.0",
1693
+ "circuit-json": "^0.0.257",
1677
1694
  react: "19.1.0",
1678
1695
  "react-cosmos": "7.0.0",
1679
1696
  "react-cosmos-plugin-vite": "7.0.0",
@@ -2494,10 +2511,16 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2494
2511
  ];
2495
2512
  }
2496
2513
  if (hole.shape === "circular_hole_with_rect_pad") {
2497
- const scaledHoleDiameter = hole.hole_diameter * Math.abs(transform.a);
2498
- const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
2499
- const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
2514
+ const circularHole = hole;
2515
+ const scaledHoleDiameter = circularHole.hole_diameter * Math.abs(transform.a);
2516
+ const scaledRectPadWidth = circularHole.rect_pad_width * Math.abs(transform.a);
2517
+ const scaledRectPadHeight = circularHole.rect_pad_height * Math.abs(transform.a);
2518
+ const scaledRectBorderRadius = (circularHole.rect_border_radius ?? 0) * Math.abs(transform.a);
2500
2519
  const holeRadius = scaledHoleDiameter / 2;
2520
+ const [holeCx, holeCy] = applyToPoint25(transform, [
2521
+ circularHole.x + circularHole.hole_offset_x,
2522
+ circularHole.y + circularHole.hole_offset_y
2523
+ ]);
2501
2524
  return [
2502
2525
  {
2503
2526
  name: "g",
@@ -2513,7 +2536,11 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2513
2536
  x: (x - scaledRectPadWidth / 2).toString(),
2514
2537
  y: (y - scaledRectPadHeight / 2).toString(),
2515
2538
  width: scaledRectPadWidth.toString(),
2516
- height: scaledRectPadHeight.toString()
2539
+ height: scaledRectPadHeight.toString(),
2540
+ ...scaledRectBorderRadius ? {
2541
+ rx: scaledRectBorderRadius.toString(),
2542
+ ry: scaledRectBorderRadius.toString()
2543
+ } : {}
2517
2544
  },
2518
2545
  value: "",
2519
2546
  children: []
@@ -2525,8 +2552,8 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2525
2552
  attributes: {
2526
2553
  class: "assembly-hole-inner",
2527
2554
  fill: HOLE_COLOR3,
2528
- cx: x.toString(),
2529
- cy: y.toString(),
2555
+ cx: holeCx.toString(),
2556
+ cy: holeCy.toString(),
2530
2557
  r: holeRadius.toString()
2531
2558
  },
2532
2559
  value: "",
@@ -2539,10 +2566,19 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2539
2566
  ];
2540
2567
  }
2541
2568
  if (hole.shape === "pill_hole_with_rect_pad") {
2542
- const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
2543
- const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
2544
- const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
2545
- const scaledHoleWidth = hole.hole_width * Math.abs(transform.a);
2569
+ const pillHole = hole;
2570
+ const scaledRectPadWidth = pillHole.rect_pad_width * Math.abs(transform.a);
2571
+ const scaledRectPadHeight = pillHole.rect_pad_height * Math.abs(transform.a);
2572
+ const scaledRectBorderRadius = (pillHole.rect_border_radius ?? 0) * Math.abs(transform.a);
2573
+ const scaledHoleHeight = pillHole.hole_height * Math.abs(transform.a);
2574
+ const scaledHoleWidth = pillHole.hole_width * Math.abs(transform.a);
2575
+ const pillHoleWithOffsets = pillHole;
2576
+ const holeOffsetX = pillHoleWithOffsets.hole_offset_x ?? 0;
2577
+ const holeOffsetY = pillHoleWithOffsets.hole_offset_y ?? 0;
2578
+ const [holeCenterX, holeCenterY] = applyToPoint25(transform, [
2579
+ pillHole.x + holeOffsetX,
2580
+ pillHole.y + holeOffsetY
2581
+ ]);
2546
2582
  const holeRadius = Math.min(scaledHoleHeight, scaledHoleWidth) / 2;
2547
2583
  return [
2548
2584
  {
@@ -2559,7 +2595,11 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2559
2595
  x: (x - scaledRectPadWidth / 2).toString(),
2560
2596
  y: (y - scaledRectPadHeight / 2).toString(),
2561
2597
  width: scaledRectPadWidth.toString(),
2562
- height: scaledRectPadHeight.toString()
2598
+ height: scaledRectPadHeight.toString(),
2599
+ ...scaledRectBorderRadius ? {
2600
+ rx: scaledRectBorderRadius.toString(),
2601
+ ry: scaledRectBorderRadius.toString()
2602
+ } : {}
2563
2603
  },
2564
2604
  value: "",
2565
2605
  children: []
@@ -2571,8 +2611,8 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2571
2611
  attributes: {
2572
2612
  class: "assembly-hole-inner",
2573
2613
  fill: HOLE_COLOR3,
2574
- x: (x - scaledHoleWidth / 2).toString(),
2575
- y: (y - scaledHoleHeight / 2).toString(),
2614
+ x: (holeCenterX - scaledHoleWidth / 2).toString(),
2615
+ y: (holeCenterY - scaledHoleHeight / 2).toString(),
2576
2616
  width: scaledHoleWidth.toString(),
2577
2617
  height: scaledHoleHeight.toString(),
2578
2618
  rx: holeRadius.toString(),
@@ -2588,10 +2628,19 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2588
2628
  ];
2589
2629
  }
2590
2630
  if (hole.shape === "rotated_pill_hole_with_rect_pad") {
2591
- const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
2592
- const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
2593
- const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
2594
- const scaledHoleWidth = hole.hole_width * Math.abs(transform.a);
2631
+ const rotatedHole = hole;
2632
+ const scaledRectPadWidth = rotatedHole.rect_pad_width * Math.abs(transform.a);
2633
+ const scaledRectPadHeight = rotatedHole.rect_pad_height * Math.abs(transform.a);
2634
+ const scaledRectBorderRadius = (rotatedHole.rect_border_radius ?? 0) * Math.abs(transform.a);
2635
+ const scaledHoleHeight = rotatedHole.hole_height * Math.abs(transform.a);
2636
+ const scaledHoleWidth = rotatedHole.hole_width * Math.abs(transform.a);
2637
+ const rotatedHoleWithOffsets = rotatedHole;
2638
+ const holeOffsetX = rotatedHoleWithOffsets.hole_offset_x ?? 0;
2639
+ const holeOffsetY = rotatedHoleWithOffsets.hole_offset_y ?? 0;
2640
+ const [holeCenterX, holeCenterY] = applyToPoint25(transform, [
2641
+ rotatedHole.x + holeOffsetX,
2642
+ rotatedHole.y + holeOffsetY
2643
+ ]);
2595
2644
  const holeRadius = Math.min(scaledHoleHeight, scaledHoleWidth) / 2;
2596
2645
  return [
2597
2646
  {
@@ -2608,7 +2657,11 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2608
2657
  y: (-scaledRectPadHeight / 2).toString(),
2609
2658
  width: scaledRectPadWidth.toString(),
2610
2659
  height: scaledRectPadHeight.toString(),
2611
- transform: `translate(${x} ${y}) rotate(${-hole.rect_ccw_rotation})`
2660
+ transform: `translate(${x} ${y}) rotate(${-rotatedHole.rect_ccw_rotation})`,
2661
+ ...scaledRectBorderRadius ? {
2662
+ rx: scaledRectBorderRadius.toString(),
2663
+ ry: scaledRectBorderRadius.toString()
2664
+ } : {}
2612
2665
  },
2613
2666
  value: "",
2614
2667
  children: []
@@ -2625,7 +2678,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2625
2678
  height: scaledHoleHeight.toString(),
2626
2679
  rx: holeRadius.toString(),
2627
2680
  ry: holeRadius.toString(),
2628
- transform: `translate(${x} ${y}) rotate(${-hole.hole_ccw_rotation})`
2681
+ transform: `translate(${holeCenterX} ${holeCenterY}) rotate(${-rotatedHole.hole_ccw_rotation})`
2629
2682
  },
2630
2683
  value: "",
2631
2684
  children: []