diff --git a/lib/schematic/stages/AddLibrarySymbolsStage.ts b/lib/schematic/stages/AddLibrarySymbolsStage.ts index 22e77e4..62a9036 100644 --- a/lib/schematic/stages/AddLibrarySymbolsStage.ts +++ b/lib/schematic/stages/AddLibrarySymbolsStage.ts @@ -303,6 +303,7 @@ export class AddLibrarySymbolsStage extends ConverterStage< const polyline = this.createPolylineFromPoints( primitive.points, symbolScale, + symbolData.center, fillType, ) drawingSymbol.polylines.push(polyline) @@ -319,12 +320,17 @@ export class AddLibrarySymbolsStage extends ConverterStage< private createPolylineFromPoints( points: Array<{ x: number; y: number }>, scale: number, + center: { x: number; y: number } | undefined, fillType: "none" | "background" = "none", ): SymbolPolyline { const polyline = new SymbolPolyline() // Scale points to match the c2kMatSch transformation scale - const xyPoints = points.map((p) => new Xy(p.x * scale, p.y * scale)) + const cx = center?.x ?? 0 + const cy = center?.y ?? 0 + const xyPoints = points.map( + (p) => new Xy((p.x - cx) * scale, (p.y - cy) * scale), + ) const pts = new Pts(xyPoints) polyline.points = pts @@ -409,11 +415,14 @@ export class AddLibrarySymbolsStage extends ConverterStage< const symbolScale = this.ctx.c2kMatSch?.a || 15 // Calculate position relative to center - const dx = port.x - center.x - const dy = port.y - center.y + const cx = center?.x ?? 0 + const cy = center?.y ?? 0 - let x = port.x * symbolScale - let y = port.y * symbolScale + const dx = (port.x ?? 0) - cx + const dy = (port.y ?? 0) - cy + + let x = dx * symbolScale + let y = dy * symbolScale // Pin length for chips const chipPinLength = 6.0 diff --git a/tests/sch/basics/__snapshots__/basics01.snap.png b/tests/sch/basics/__snapshots__/basics01.snap.png index 43ba49f..6bc41a6 100644 Binary files a/tests/sch/basics/__snapshots__/basics01.snap.png and b/tests/sch/basics/__snapshots__/basics01.snap.png differ diff --git a/tests/sch/basics/__snapshots__/basics02.snap.png b/tests/sch/basics/__snapshots__/basics02.snap.png index a210c64..6a3e29e 100644 Binary files a/tests/sch/basics/__snapshots__/basics02.snap.png and b/tests/sch/basics/__snapshots__/basics02.snap.png differ diff --git a/tests/sch/basics/__snapshots__/basics03.snap.png b/tests/sch/basics/__snapshots__/basics03.snap.png index c13b0b6..781b72a 100644 Binary files a/tests/sch/basics/__snapshots__/basics03.snap.png and b/tests/sch/basics/__snapshots__/basics03.snap.png differ diff --git a/tests/sch/basics/__snapshots__/basics04-arduino-shield-sch.snap.png b/tests/sch/basics/__snapshots__/basics04-arduino-shield-sch.snap.png index 643c5cb..e5b0bd3 100644 Binary files a/tests/sch/basics/__snapshots__/basics04-arduino-shield-sch.snap.png and b/tests/sch/basics/__snapshots__/basics04-arduino-shield-sch.snap.png differ diff --git a/tests/sch/repros/__snapshots__/repro01-led-water-accelerometer-sch.snap.png b/tests/sch/repros/__snapshots__/repro01-led-water-accelerometer-sch.snap.png index fde2ea8..300848a 100644 Binary files a/tests/sch/repros/__snapshots__/repro01-led-water-accelerometer-sch.snap.png and b/tests/sch/repros/__snapshots__/repro01-led-water-accelerometer-sch.snap.png differ diff --git a/tests/sch/repros/__snapshots__/repro02-555-timer-circuit-sch.snap.png b/tests/sch/repros/__snapshots__/repro02-555-timer-circuit-sch.snap.png index f676163..0c1b300 100644 Binary files a/tests/sch/repros/__snapshots__/repro02-555-timer-circuit-sch.snap.png and b/tests/sch/repros/__snapshots__/repro02-555-timer-circuit-sch.snap.png differ