diff --git a/bun.lock b/bun.lock index 50bf881..6f72f97 100644 --- a/bun.lock +++ b/bun.lock @@ -6,7 +6,7 @@ "name": "jscad-electronics", "devDependencies": { "@biomejs/biome": "^1.9.3", - "@tscircuit/footprinter": "^0.0.374", + "@tscircuit/footprinter": "^0.0.391", "@types/react": "19", "@types/react-dom": "19", "@types/three": "^0.179.0", @@ -179,7 +179,7 @@ "@tscircuit/alphabet": ["@tscircuit/alphabet@0.0.24", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-vYYLwDwpTULFDwuqB5+U4RlTiHJ3Ez4Sf5OEv7rB1oVbhmh8p3Xl7h3vsi5eD4SE+x+0e8eSXKSlwSLCN94vZA=="], - "@tscircuit/footprinter": ["@tscircuit/footprinter@0.0.374", "", { "dependencies": { "@tscircuit/mm": "^0.0.8", "zod": "^3.23.8" }, "peerDependencies": { "circuit-json": "*" } }, "sha512-TqcB8fBoquEWCOIttNSvq3OD+g3j9INFn0Zn//Jmje8U42TW7SpxW5vF+N04zoCmIQ3WkMpeC2032zD4uYbg5Q=="], + "@tscircuit/footprinter": ["@tscircuit/footprinter@0.0.391", "", { "dependencies": { "@tscircuit/mm": "^0.0.8", "zod": "^3.23.8" }, "peerDependencies": { "circuit-json": "*" } }, "sha512-6sUm5uyUJjk0U19Fy1J6w5lfxdB1kQe8lMTtWjjnSTP2dCKmcoBS1Hy5bWhvRuWllYwZkAwztsHYI9DnYDoj6w=="], "@tscircuit/mm": ["@tscircuit/mm@0.0.8", "", { "peerDependencies": { "typescript": "^5.0.0" } }, "sha512-nl7nxE7AhARbKuobflI0LUzoir7+wJyvwfPw6bzA/O0Q3YTcH3vBkU/Of+V/fp6ht+AofiCXj7YAH9E446138Q=="], diff --git a/examples/footprinter3d/fp-crystal4.example.tsx b/examples/footprinter3d/fp-crystal4.example.tsx new file mode 100644 index 0000000..5e6687f --- /dev/null +++ b/examples/footprinter3d/fp-crystal4.example.tsx @@ -0,0 +1,12 @@ +import { JsCadView } from "jscad-fiber" +import { ExtrudedPads } from "lib/ExtrudedPads" +import { Footprinter3d } from "lib/Footprinter3d" + +const footprint = "crystal4" + +export default () => ( + + + + +) diff --git a/lib/Crystal.tsx b/lib/Crystal.tsx new file mode 100644 index 0000000..21fd7d0 --- /dev/null +++ b/lib/Crystal.tsx @@ -0,0 +1,51 @@ +import { Cuboid, Cylinder, RoundedCuboid } from "jscad-fiber" + +export interface CrystalProps { + padPitchX?: number + padPitchY?: number + padWidth?: number + padHeight?: number + bodyHeight?: number +} + +export const Crystal = ({ + padPitchX = 2.2, + padPitchY = 1.7, + padWidth = 1.4, + padHeight = 1.2, + bodyHeight = 0.8, +}: CrystalProps) => { + const bodyWidth = Math.max(padPitchX + padWidth - 0.4, 1.6) + const bodyLength = Math.max(padPitchY + padHeight - 0.4, 1.2) + const baseHeight = 0.12 + const canWidth = Math.max(bodyWidth - 0.12, 0.8) + const canLength = Math.max(bodyLength - 0.12, 0.8) + const canHeight = Math.max(bodyHeight - baseHeight, 0.25) + const cornerRadius = Math.min(0.24, canWidth / 4, canLength / 4) + + return ( + <> + + + + + ) +} diff --git a/lib/Footprinter3d.tsx b/lib/Footprinter3d.tsx index a32c152..8a5f0a4 100644 --- a/lib/Footprinter3d.tsx +++ b/lib/Footprinter3d.tsx @@ -57,6 +57,7 @@ import { StampBoard } from "./stampboard" import { MountedPcbModule } from "./MountedPcbModule" import SOD723 from "./SOD723" import { JSTZH1_5mm } from "./JSTZH1_5mm" +import { Crystal } from "./Crystal" /** * Outputs a 3d model for any [footprinter string](https://github.com/tscircuit/footprinter) @@ -103,6 +104,9 @@ export const Footprinter3d = ({ footprint }: { footprint: string }) => { screenheight?: number screencenteroffsetx?: number screencenteroffsety?: number + px?: number + py?: number + ph?: number } switch (fpJson.fn) { @@ -325,6 +329,15 @@ export const Footprinter3d = ({ footprint }: { footprint: string }) => { return case "hc49": return + case "crystal": + return ( + + ) case "micromelf": return case "minimelf": diff --git a/lib/index.ts b/lib/index.ts index c3ad613..facc857 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -70,3 +70,4 @@ export * from "./TO92" export * from "./MountedPcbModule" export * from "./Screen" export * from "./JSTZH1_5mm" +export * from "./Crystal" diff --git a/package.json b/package.json index 6b6f4d0..767d7c0 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ }, "devDependencies": { "@biomejs/biome": "^1.9.3", - "@tscircuit/footprinter": "^0.0.374", + "@tscircuit/footprinter": "^0.0.391", "@types/react": "19", "@types/react-dom": "19", "@types/three": "^0.179.0", diff --git a/tests/snapshots/__snapshots__/crystal.snap.png b/tests/snapshots/__snapshots__/crystal.snap.png new file mode 100644 index 0000000..d45d62e Binary files /dev/null and b/tests/snapshots/__snapshots__/crystal.snap.png differ diff --git a/tests/snapshots/crystal.test.ts b/tests/snapshots/crystal.test.ts new file mode 100644 index 0000000..cf4dc88 --- /dev/null +++ b/tests/snapshots/crystal.test.ts @@ -0,0 +1,8 @@ +import { expect, test } from "bun:test" +import "../fixtures/png-matcher" +import { renderFootprint } from "../helpers/render-footprint" + +test("Crystal-4 package", async () => { + const pngBuffer = await renderFootprint("crystal4") + await expect(pngBuffer).toMatchPngSnapshot(import.meta.path) +})