circuit-json-to-kicad 0.0.11 → 0.0.13

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.
Files changed (2) hide show
  1. package/dist/index.js +16 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -432,13 +432,23 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
432
432
  }
433
433
  const scaleMatrix = createScaleMatrix(symbolScale, symbolScale);
434
434
  const scaled = applyToPoint(scaleMatrix, { x: dx, y: dy });
435
+ let isHorizontalPin;
436
+ if (isChip && size) {
437
+ const halfWidth = size.width / 2;
438
+ const halfHeight = size.height / 2;
439
+ const normalizedDx = Math.abs(dx) / halfWidth;
440
+ const normalizedDy = Math.abs(dy) / halfHeight;
441
+ isHorizontalPin = normalizedDx > normalizedDy;
442
+ } else {
443
+ isHorizontalPin = Math.abs(dx) > Math.abs(dy);
444
+ }
435
445
  let x = scaled.x;
436
446
  let y = scaled.y;
437
447
  const chipPinLength = 6;
438
448
  if (isChip && size) {
439
449
  const halfWidth = size.width / 2 * symbolScale;
440
450
  const halfHeight = size.height / 2 * symbolScale;
441
- if (Math.abs(dx) > Math.abs(dy)) {
451
+ if (isHorizontalPin) {
442
452
  x = dx > 0 ? halfWidth : -halfWidth;
443
453
  y = dy * symbolScale;
444
454
  } else {
@@ -447,7 +457,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
447
457
  }
448
458
  }
449
459
  let angle = 0;
450
- if (Math.abs(dx) > Math.abs(dy)) {
460
+ if (isHorizontalPin) {
451
461
  if (dx > 0) {
452
462
  if (isChip) {
453
463
  angle = 180;
@@ -655,12 +665,14 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
655
665
  }
656
666
  }
657
667
  const symbolCenter = symbol.center || { x: 0, y: 0 };
668
+ const isVertical = symbolName.includes("_down") || symbolName.includes("_up");
669
+ const horizontalTextOffset = isVertical ? 0.15 : 0;
658
670
  const refTextPos = refTextPrimitive && this.ctx.c2kMatSch ? applyToPoint2(this.ctx.c2kMatSch, {
659
- x: schematicComponent.center.x + (refTextPrimitive.x - symbolCenter.x),
671
+ x: schematicComponent.center.x + (refTextPrimitive.x - symbolCenter.x) + horizontalTextOffset,
660
672
  y: schematicComponent.center.y + (refTextPrimitive.y - symbolCenter.y)
661
673
  }) : { x: symbolKicadPos.x, y: symbolKicadPos.y - 6 };
662
674
  const valTextPos = valTextPrimitive && this.ctx.c2kMatSch ? applyToPoint2(this.ctx.c2kMatSch, {
663
- x: schematicComponent.center.x + (valTextPrimitive.x - symbolCenter.x),
675
+ x: schematicComponent.center.x + (valTextPrimitive.x - symbolCenter.x) + horizontalTextOffset,
664
676
  y: schematicComponent.center.y + (valTextPrimitive.y - symbolCenter.y)
665
677
  }) : { x: symbolKicadPos.x, y: symbolKicadPos.y + 6 };
666
678
  return { refTextPos, valTextPos };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "circuit-json-to-kicad",
3
3
  "main": "dist/index.js",
4
- "version": "0.0.11",
4
+ "version": "0.0.13",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"