diff --git a/lib/convert-easyeda-json-to-tscircuit-soup-json.ts b/lib/convert-easyeda-json-to-tscircuit-soup-json.ts index 092ddba..cd46a48 100644 --- a/lib/convert-easyeda-json-to-tscircuit-soup-json.ts +++ b/lib/convert-easyeda-json-to-tscircuit-soup-json.ts @@ -216,9 +216,6 @@ export const convertEasyEdaJsonToCircuitJson = ( } }) - // easyeda uses a flipped Y axis ( tscircuit = y+ is up, easyeda = y- is up ) - transformPCBElements(soupElements, scale(1, -1)) - // TODO Change pcb_component width & height // TODO compute pcb center based on all elements and transform elements such @@ -262,8 +259,9 @@ export const convertEasyEdaJsonToCircuitJson = ( ) transformPCBElements( soupElements, - compose(translate(-bounds.center.x, bounds.center.y)), + compose(translate(-bounds.center.x, bounds.center.y), scale(1, -1)), ) + pcb_component.center = { x: 0, y: 0 } } return soupElements diff --git a/tests/convert-to-soup-tests/c5184526.test.ts b/tests/convert-to-soup-tests/c5184526.test.ts index 4561ea1..7ca49c9 100644 --- a/tests/convert-to-soup-tests/c5184526.test.ts +++ b/tests/convert-to-soup-tests/c5184526.test.ts @@ -12,4 +12,22 @@ test("C5184526 should have two holes", () => { expect(convertCircuitJsonToPcbSvg(circuitJson)).toMatchSvgSnapshot( import.meta.path, ) + + const coords = circuitJson + .map((e: any) => ({ + type: e.type, + x: e.x ?? e.center?.x, + y: e.y ?? e.center?.y, + })) + .filter((e) => e.x !== undefined && e.y !== undefined) + + const maxX = Math.max(...coords.map((e) => e.x)) + const minX = Math.min(...coords.map((e) => e.x)) + const maxY = Math.max(...coords.map((e) => e.y)) + const minY = Math.min(...coords.map((e) => e.y)) + + expect(maxX).toBeLessThan(10) + expect(minX).toBeGreaterThan(-10) + expect(maxY).toBeLessThan(10) + expect(minY).toBeGreaterThan(-10) })