circuit-to-svg 0.0.192 → 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
@@ -345,6 +345,9 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
345
345
  const innerRadiusX = scaledHoleWidth / 2;
346
346
  const innerRadiusY = scaledHoleHeight / 2;
347
347
  const straightLength = scaledOuterHeight - scaledOuterWidth;
348
+ const rotation = hole.ccw_rotation || 0;
349
+ const outerTransform = rotation ? `translate(${x} ${y}) rotate(${-rotation})` : `translate(${x} ${y})`;
350
+ const innerTransform = rotation ? `translate(${x} ${y}) rotate(${-rotation})` : `translate(${x} ${y})`;
348
351
  return [
349
352
  {
350
353
  name: "g",
@@ -357,7 +360,8 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
357
360
  attributes: {
358
361
  class: "pcb-hole-outer",
359
362
  fill: colorMap2.copper.top,
360
- d: `M${x - outerRadiusX},${y - straightLength / 2} v${straightLength} a${outerRadiusX},${outerRadiusX} 0 0 0 ${scaledOuterWidth},0 v-${straightLength} a${outerRadiusX},${outerRadiusX} 0 0 0 -${scaledOuterWidth},0 z`
363
+ d: `M${-outerRadiusX},${-straightLength / 2} v${straightLength} a${outerRadiusX},${outerRadiusX} 0 0 0 ${scaledOuterWidth},0 v-${straightLength} a${outerRadiusX},${outerRadiusX} 0 0 0 -${scaledOuterWidth},0 z`,
364
+ transform: outerTransform
361
365
  },
362
366
  value: "",
363
367
  children: []
@@ -369,7 +373,8 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
369
373
  attributes: {
370
374
  class: "pcb-hole-inner",
371
375
  fill: colorMap2.drill,
372
- d: `M${x - innerRadiusX},${y - (scaledHoleHeight - scaledHoleWidth) / 2} v${scaledHoleHeight - scaledHoleWidth} a${innerRadiusX},${innerRadiusX} 0 0 0 ${scaledHoleWidth},0 v-${scaledHoleHeight - scaledHoleWidth} a${innerRadiusX},${innerRadiusX} 0 0 0 -${scaledHoleWidth},0 z`
376
+ d: `M${-innerRadiusX},${-(scaledHoleHeight - scaledHoleWidth) / 2} v${scaledHoleHeight - scaledHoleWidth} a${innerRadiusX},${innerRadiusX} 0 0 0 ${scaledHoleWidth},0 v-${scaledHoleHeight - scaledHoleWidth} a${innerRadiusX},${innerRadiusX} 0 0 0 -${scaledHoleWidth},0 z`,
377
+ transform: innerTransform
373
378
  },
374
379
  value: "",
375
380
  children: []
@@ -480,11 +485,19 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
480
485
  ];
481
486
  }
482
487
  if (hole.shape === "pill_hole_with_rect_pad") {
483
- const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
484
- const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
485
- const scaledRectBorderRadius = (hole.rect_border_radius ?? 0) * Math.abs(transform.a);
486
- const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
487
- 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
+ ]);
488
501
  const holeRadius = Math.min(scaledHoleHeight, scaledHoleWidth) / 2;
489
502
  return [
490
503
  {
@@ -517,8 +530,8 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
517
530
  attributes: {
518
531
  class: "pcb-hole-inner",
519
532
  fill: colorMap2.drill,
520
- x: (x - scaledHoleWidth / 2).toString(),
521
- y: (y - scaledHoleHeight / 2).toString(),
533
+ x: (holeCenterX - scaledHoleWidth / 2).toString(),
534
+ y: (holeCenterY - scaledHoleHeight / 2).toString(),
522
535
  width: scaledHoleWidth.toString(),
523
536
  height: scaledHoleHeight.toString(),
524
537
  rx: holeRadius.toString(),
@@ -534,11 +547,19 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
534
547
  ];
535
548
  }
536
549
  if (hole.shape === "rotated_pill_hole_with_rect_pad") {
537
- const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
538
- const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
539
- const scaledRectBorderRadius = (hole.rect_border_radius ?? 0) * Math.abs(transform.a);
540
- const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
541
- 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
+ ]);
542
563
  const holeRadius = Math.min(scaledHoleHeight, scaledHoleWidth) / 2;
543
564
  return [
544
565
  {
@@ -555,7 +576,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
555
576
  y: (-scaledRectPadHeight / 2).toString(),
556
577
  width: scaledRectPadWidth.toString(),
557
578
  height: scaledRectPadHeight.toString(),
558
- transform: `translate(${x} ${y}) rotate(${-hole.rect_ccw_rotation})`,
579
+ transform: `translate(${x} ${y}) rotate(${-rotatedHole.rect_ccw_rotation})`,
559
580
  ...scaledRectBorderRadius ? {
560
581
  rx: scaledRectBorderRadius.toString(),
561
582
  ry: scaledRectBorderRadius.toString()
@@ -576,7 +597,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
576
597
  height: scaledHoleHeight.toString(),
577
598
  rx: holeRadius.toString(),
578
599
  ry: holeRadius.toString(),
579
- transform: `translate(${x} ${y}) rotate(${-hole.hole_ccw_rotation})`
600
+ transform: `translate(${holeCenterX} ${holeCenterY}) rotate(${-rotatedHole.hole_ccw_rotation})`
580
601
  },
581
602
  value: "",
582
603
  children: []
@@ -1645,7 +1666,7 @@ function getSoftwareUsedString(circuitJson) {
1645
1666
  var package_default = {
1646
1667
  name: "circuit-to-svg",
1647
1668
  type: "module",
1648
- version: "0.0.191",
1669
+ version: "0.0.193",
1649
1670
  description: "Convert Circuit JSON to SVG",
1650
1671
  main: "dist/index.js",
1651
1672
  files: [
@@ -1669,11 +1690,12 @@ var package_default = {
1669
1690
  "bun-match-svg": "^0.0.12",
1670
1691
  esbuild: "^0.20.2",
1671
1692
  "performance-now": "^2.1.0",
1693
+ "circuit-json": "^0.0.257",
1672
1694
  react: "19.1.0",
1673
1695
  "react-cosmos": "7.0.0",
1674
1696
  "react-cosmos-plugin-vite": "7.0.0",
1675
1697
  "react-dom": "19.1.0",
1676
- tscircuit: "^0.0.632",
1698
+ tscircuit: "^0.0.648",
1677
1699
  tsup: "^8.0.2",
1678
1700
  typescript: "^5.4.5",
1679
1701
  "vite-tsconfig-paths": "^5.0.1"
@@ -2489,10 +2511,16 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2489
2511
  ];
2490
2512
  }
2491
2513
  if (hole.shape === "circular_hole_with_rect_pad") {
2492
- const scaledHoleDiameter = hole.hole_diameter * Math.abs(transform.a);
2493
- const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
2494
- 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);
2495
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
+ ]);
2496
2524
  return [
2497
2525
  {
2498
2526
  name: "g",
@@ -2508,7 +2536,11 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2508
2536
  x: (x - scaledRectPadWidth / 2).toString(),
2509
2537
  y: (y - scaledRectPadHeight / 2).toString(),
2510
2538
  width: scaledRectPadWidth.toString(),
2511
- height: scaledRectPadHeight.toString()
2539
+ height: scaledRectPadHeight.toString(),
2540
+ ...scaledRectBorderRadius ? {
2541
+ rx: scaledRectBorderRadius.toString(),
2542
+ ry: scaledRectBorderRadius.toString()
2543
+ } : {}
2512
2544
  },
2513
2545
  value: "",
2514
2546
  children: []
@@ -2520,8 +2552,8 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2520
2552
  attributes: {
2521
2553
  class: "assembly-hole-inner",
2522
2554
  fill: HOLE_COLOR3,
2523
- cx: x.toString(),
2524
- cy: y.toString(),
2555
+ cx: holeCx.toString(),
2556
+ cy: holeCy.toString(),
2525
2557
  r: holeRadius.toString()
2526
2558
  },
2527
2559
  value: "",
@@ -2534,10 +2566,19 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2534
2566
  ];
2535
2567
  }
2536
2568
  if (hole.shape === "pill_hole_with_rect_pad") {
2537
- const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
2538
- const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
2539
- const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
2540
- 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
+ ]);
2541
2582
  const holeRadius = Math.min(scaledHoleHeight, scaledHoleWidth) / 2;
2542
2583
  return [
2543
2584
  {
@@ -2554,7 +2595,11 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2554
2595
  x: (x - scaledRectPadWidth / 2).toString(),
2555
2596
  y: (y - scaledRectPadHeight / 2).toString(),
2556
2597
  width: scaledRectPadWidth.toString(),
2557
- height: scaledRectPadHeight.toString()
2598
+ height: scaledRectPadHeight.toString(),
2599
+ ...scaledRectBorderRadius ? {
2600
+ rx: scaledRectBorderRadius.toString(),
2601
+ ry: scaledRectBorderRadius.toString()
2602
+ } : {}
2558
2603
  },
2559
2604
  value: "",
2560
2605
  children: []
@@ -2566,8 +2611,8 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2566
2611
  attributes: {
2567
2612
  class: "assembly-hole-inner",
2568
2613
  fill: HOLE_COLOR3,
2569
- x: (x - scaledHoleWidth / 2).toString(),
2570
- y: (y - scaledHoleHeight / 2).toString(),
2614
+ x: (holeCenterX - scaledHoleWidth / 2).toString(),
2615
+ y: (holeCenterY - scaledHoleHeight / 2).toString(),
2571
2616
  width: scaledHoleWidth.toString(),
2572
2617
  height: scaledHoleHeight.toString(),
2573
2618
  rx: holeRadius.toString(),
@@ -2583,10 +2628,19 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2583
2628
  ];
2584
2629
  }
2585
2630
  if (hole.shape === "rotated_pill_hole_with_rect_pad") {
2586
- const scaledRectPadWidth = hole.rect_pad_width * Math.abs(transform.a);
2587
- const scaledRectPadHeight = hole.rect_pad_height * Math.abs(transform.a);
2588
- const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
2589
- 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
+ ]);
2590
2644
  const holeRadius = Math.min(scaledHoleHeight, scaledHoleWidth) / 2;
2591
2645
  return [
2592
2646
  {
@@ -2603,7 +2657,11 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2603
2657
  y: (-scaledRectPadHeight / 2).toString(),
2604
2658
  width: scaledRectPadWidth.toString(),
2605
2659
  height: scaledRectPadHeight.toString(),
2606
- 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
+ } : {}
2607
2665
  },
2608
2666
  value: "",
2609
2667
  children: []
@@ -2620,7 +2678,7 @@ function createSvgObjectsFromAssemblyPlatedHole(hole, ctx) {
2620
2678
  height: scaledHoleHeight.toString(),
2621
2679
  rx: holeRadius.toString(),
2622
2680
  ry: holeRadius.toString(),
2623
- transform: `translate(${x} ${y}) rotate(${-hole.hole_ccw_rotation})`
2681
+ transform: `translate(${holeCenterX} ${holeCenterY}) rotate(${-rotatedHole.hole_ccw_rotation})`
2624
2682
  },
2625
2683
  value: "",
2626
2684
  children: []