circuit-to-svg 0.0.253 → 0.0.254

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
@@ -1444,14 +1444,23 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
1444
1444
  const scaledOuterHeight = hole.outer_height * Math.abs(transform.a);
1445
1445
  const scaledHoleWidth = hole.hole_width * Math.abs(transform.a);
1446
1446
  const scaledHoleHeight = hole.hole_height * Math.abs(transform.a);
1447
- const outerRadiusX = scaledOuterWidth / 2;
1448
- const outerRadiusY = scaledOuterHeight / 2;
1449
- const innerRadiusX = scaledHoleWidth / 2;
1450
- const innerRadiusY = scaledHoleHeight / 2;
1451
- const straightLength = scaledOuterHeight - scaledOuterWidth;
1452
1447
  const rotation = hole.ccw_rotation || 0;
1453
1448
  const outerTransform = rotation ? `translate(${x} ${y}) rotate(${-rotation})` : `translate(${x} ${y})`;
1454
1449
  const innerTransform = rotation ? `translate(${x} ${y}) rotate(${-rotation})` : `translate(${x} ${y})`;
1450
+ const createPillPath = (width, height) => {
1451
+ if (width > height) {
1452
+ const radius = height / 2;
1453
+ const straightLength = width - 2 * radius;
1454
+ return `M${-width / 2 + radius},${-radius} h${straightLength} a${radius},${radius} 0 0 1 0,${height} h${-straightLength} a${radius},${radius} 0 0 1 0,${-height} z`;
1455
+ } else if (height > width) {
1456
+ const radius = width / 2;
1457
+ const straightLength = height - 2 * radius;
1458
+ return `M${radius},${-height / 2 + radius} v${straightLength} a${radius},${radius} 0 0 1 ${-width},0 v${-straightLength} a${radius},${radius} 0 0 1 ${width},0 z`;
1459
+ } else {
1460
+ const radius = width / 2;
1461
+ return `M${-radius},0 a${radius},${radius} 0 0 1 ${width},0 a${radius},${radius} 0 0 1 ${-width},0 z`;
1462
+ }
1463
+ };
1455
1464
  return [
1456
1465
  {
1457
1466
  name: "g",
@@ -1468,7 +1477,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
1468
1477
  attributes: {
1469
1478
  class: "pcb-hole-outer",
1470
1479
  fill: colorMap2.copper.top,
1471
- 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`,
1480
+ d: createPillPath(scaledOuterWidth, scaledOuterHeight),
1472
1481
  transform: outerTransform,
1473
1482
  "data-type": "pcb_plated_hole",
1474
1483
  "data-pcb-layer": copperLayer
@@ -1483,7 +1492,7 @@ function createSvgObjectsFromPcbPlatedHole(hole, ctx) {
1483
1492
  attributes: {
1484
1493
  class: "pcb-hole-inner",
1485
1494
  fill: colorMap2.drill,
1486
- 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`,
1495
+ d: createPillPath(scaledHoleWidth, scaledHoleHeight),
1487
1496
  transform: innerTransform,
1488
1497
  "data-type": "pcb_plated_hole_drill",
1489
1498
  "data-pcb-layer": "drill"
@@ -3339,7 +3348,7 @@ function getSoftwareUsedString(circuitJson) {
3339
3348
  var package_default = {
3340
3349
  name: "circuit-to-svg",
3341
3350
  type: "module",
3342
- version: "0.0.252",
3351
+ version: "0.0.253",
3343
3352
  description: "Convert Circuit JSON to SVG",
3344
3353
  main: "dist/index.js",
3345
3354
  files: [