circuit-to-svg 0.0.115 → 0.0.116

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
@@ -1362,7 +1362,7 @@ function createSvgObjectsFromAssemblyComponent(component, transform, firstPin, n
1362
1362
  type: "element",
1363
1363
  value: "",
1364
1364
  attributes: {
1365
- transform: `translate(${x}, ${y}) rotate(${-rotation}) scale(1, -1)`
1365
+ transform: `translate(${x}, ${y}) scale(1, -1)`
1366
1366
  },
1367
1367
  children: [
1368
1368
  createComponentPath(
@@ -1384,33 +1384,43 @@ function createComponentPath(scaledWidth, scaledHeight, centerX, centerY, pinX,
1384
1384
  const cornerSize = Math.min(w, h) * 0.3;
1385
1385
  const isTop = pinY > centerY;
1386
1386
  const isLeft = pinX < centerX;
1387
+ const strokeWidth = 0.8;
1387
1388
  const path = getComponentPathData(w, h, cornerSize, isTop, isLeft, rotation);
1388
1389
  return {
1389
1390
  name: "path",
1390
1391
  type: "element",
1391
1392
  attributes: {
1392
1393
  class: "assembly-component",
1393
- d: path
1394
+ d: path,
1395
+ "stroke-width": strokeWidth.toFixed(2),
1396
+ transform: `rotate(${-rotation})`
1394
1397
  },
1395
1398
  value: "",
1396
1399
  children: []
1397
1400
  };
1398
1401
  }
1399
1402
  function createComponentLabel(scaledWidth, scaledHeight, name, transform) {
1400
- const scale8 = Math.min(scaledWidth, scaledHeight) * 0.4;
1401
- const fontSize = getSchScreenFontSize(transform, "net_label") * (scale8 / 2.5);
1402
- const scaledFontSize = scale8 < 25 ? fontSize : fontSize * 0.6;
1403
+ const size = Math.min(scaledWidth, scaledHeight);
1404
+ const minFontSize = 3;
1405
+ const maxFontSize = 58;
1406
+ const fontScale = 0.8;
1407
+ const fontSize = Math.min(
1408
+ maxFontSize,
1409
+ Math.max(minFontSize, size * fontScale)
1410
+ );
1411
+ const isTall = scaledHeight > scaledWidth;
1403
1412
  return {
1404
1413
  name: "text",
1405
1414
  type: "element",
1406
1415
  attributes: {
1407
1416
  x: "0",
1408
- y: `${0 + scaledFontSize / 8}`,
1417
+ y: "0",
1409
1418
  class: "assembly-component-label",
1410
1419
  "text-anchor": "middle",
1411
- "dominant-baseline": "middle",
1412
- "font-size": `${scaledFontSize}px`,
1413
- transform: "scale(1, -1)"
1420
+ dy: ".10em",
1421
+ style: "pointer-events: none",
1422
+ "font-size": `${fontSize.toFixed(1)}px`,
1423
+ transform: isTall ? "rotate(90) scale(1, -1)" : "scale(1, -1)"
1414
1424
  },
1415
1425
  children: [
1416
1426
  {
@@ -1466,7 +1476,7 @@ function getComponentPathData(w, h, cornerSize, isTop, isLeft, rotation) {
1466
1476
  ];
1467
1477
  }
1468
1478
  const rotatedCorners = corners.map(([x, y]) => rotatePoint(x, y, rotation));
1469
- const path = rotatedCorners.map(([x, y], index) => index === 0 ? `M${x},${y}` : `L${x},${y}`).join(" ");
1479
+ const path = rotatedCorners.map(([x, y], i) => i === 0 ? `M${x},${y}` : `L${x},${y}`).join(" ");
1470
1480
  return `${path} Z`;
1471
1481
  }
1472
1482
 
@@ -1526,14 +1536,27 @@ function convertCircuitJsonToAssemblySvg(soup, options) {
1526
1536
  {
1527
1537
  type: "text",
1528
1538
  value: `
1529
- .assembly-component { fill: #fff; stroke: #000; stroke-width: 3; }
1530
- .assembly-board { fill: #f2f2f2; stroke: rgb(0,0,0); stroke-opacity: 0.8; }
1539
+ .assembly-component {
1540
+ fill: #fff;
1541
+ stroke: #000;
1542
+ }
1543
+ .assembly-board {
1544
+ fill: #f2f2f2;
1545
+ stroke: rgb(0,0,0);
1546
+ stroke-opacity: 0.8;
1547
+ }
1531
1548
  .assembly-component-label {
1532
1549
  fill: #000;
1533
1550
  font-family: Arial, serif;
1534
1551
  font-weight: bold;
1552
+ dominant-baseline: middle;
1553
+ text-anchor: middle;
1554
+ }
1555
+ .assembly-boundary {
1556
+ fill: none;
1557
+ stroke: #fff;
1558
+ stroke-width: 0.2;
1535
1559
  }
1536
- .assembly-boundary { fill: none; stroke: #fff; stroke-width: 0.3; }
1537
1560
  `,
1538
1561
  name: "",
1539
1562
  attributes: {},