Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions lib/schematic/stages/AddLibrarySymbolsStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ export class AddLibrarySymbolsStage extends ConverterStage<
const polyline = this.createPolylineFromPoints(
primitive.points,
symbolScale,
symbolData.center,
fillType,
)
drawingSymbol.polylines.push(polyline)
Expand All @@ -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",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have a 2 parameter rule, if there's more than 2 parameters you must switch to named parameters

): 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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use transformation-matrix to perform any operations on points, e.g. the applyToPoint method. Never do point math with multiplication without a transformation-matrix

)
const pts = new Pts(xyPoints)
polyline.points = pts

Expand Down Expand Up @@ -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
Expand Down
Binary file modified tests/sch/basics/__snapshots__/basics01.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/sch/basics/__snapshots__/basics02.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/sch/basics/__snapshots__/basics03.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.