-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new test showing broken pad positioning
- Loading branch information
Showing
9 changed files
with
366 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
node_modules | ||
.aider* | ||
dist | ||
*.raweasy.json | ||
/*.raweasy.json | ||
*.bettereasy.json | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import type { z } from "zod" | ||
import type { EasyEdaJson } from "./schemas/easy-eda-json-schema" | ||
import type { PadSchema } from "./schemas/package-detail-shape-schema" | ||
|
||
export const computeCenterOffset = (easyeda: EasyEdaJson) => { | ||
const pads = easyeda.packageDetail.dataStr.shape.filter( | ||
(shape): shape is z.infer<typeof PadSchema> => shape.type === "PAD" | ||
) | ||
|
||
const minX = Math.min(...pads.map((pad) => pad.center.x)) | ||
const maxX = Math.max(...pads.map((pad) => pad.center.x)) | ||
const minY = Math.min(...pads.map((pad) => pad.center.y)) | ||
const maxY = Math.max(...pads.map((pad) => pad.center.y)) | ||
|
||
const centerX = (minX + maxX) / 2 | ||
const centerY = (minY + maxY) / 2 | ||
|
||
return { | ||
x: centerX, | ||
y: centerY, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { it, expect } from "bun:test" | ||
import { logSoup } from "@tscircuit/log-soup" | ||
import c88224RawEasy from "../assets/C88224.raweasy.json" | ||
import { EasyEdaJsonSchema } from "lib/schemas/easy-eda-json-schema" | ||
import { convertEasyEdaJsonToTscircuitSoupJson } from "lib/convert-easyeda-json-to-tscircuit-soup-json" | ||
import { su } from "@tscircuit/soup-util" | ||
import type { AnySoupElement } from "@tscircuit/soup" | ||
|
||
it("should parse easyeda json for a c88224 and convert to tscircuit soup", async () => { | ||
const parsedJson = EasyEdaJsonSchema.parse(c88224RawEasy) | ||
const soupElements = convertEasyEdaJsonToTscircuitSoupJson(parsedJson).concat( | ||
[ | ||
{ | ||
type: "pcb_board", | ||
center: { x: 0, y: 0 }, | ||
width: 20, | ||
height: 20, | ||
}, | ||
] | ||
) | ||
|
||
await logSoup("easyeda c88224 to soup", soupElements as AnySoupElement[]) | ||
}) |