diff --git a/bun.lock b/bun.lock index 94f0b94..749eb99 100644 --- a/bun.lock +++ b/bun.lock @@ -24,7 +24,7 @@ "peerDependencies": { "@jscad/modeling": "^2.12.5", "@tscircuit/alphabet": "^0.0.24", - "@tscircuit/footprinter": "*", + "@tscircuit/footprinter": "^0.0.393", "circuit-json": "^0.0.426", "jscad-fiber": "^0.0.85", "react": "19.1.0", diff --git a/examples/led5050.example.tsx b/examples/led5050.example.tsx new file mode 100644 index 0000000..1d3a0c3 --- /dev/null +++ b/examples/led5050.example.tsx @@ -0,0 +1,9 @@ +import { JsCadView } from "jscad-fiber" +import { ExtrudedPads, Led5050 } from "../lib" + +export default () => ( + + + + +) diff --git a/lib/Footprinter3d.tsx b/lib/Footprinter3d.tsx index 60bf6b6..2edfeb9 100644 --- a/lib/Footprinter3d.tsx +++ b/lib/Footprinter3d.tsx @@ -59,6 +59,7 @@ import SOD723 from "./SOD723" import { JSTZH1_5mm } from "./JSTZH1_5mm" import { FPC } from "./FPC" import { SmdPinHeader } from "./SmdPinHeader" +import { Led5050 } from "./Led5050" import { RJ45 } from "./RJ45" /** @@ -133,6 +134,9 @@ export const Footprinter3d = ({ footprint }: { footprint: string }) => { bodyy?: number } + const colorMatch = footprint.match(/_color\(([^)]+)\)/) + const color = colorMatch ? colorMatch[1] : undefined + switch (fpJson.fn) { case "dip": return ( @@ -267,6 +271,8 @@ export const Footprinter3d = ({ footprint }: { footprint: string }) => { bodyWidth={fpJson.bh} /> ) + case "led5050": + return case "cap": { switch (fpJson.imperial) { @@ -486,9 +492,6 @@ export const Footprinter3d = ({ footprint }: { footprint: string }) => { } } - const colorMatch = footprint.match(/_color\(([^)]+)\)/) - const color = colorMatch ? colorMatch[1] : undefined - switch (fpJson.imperial) { case "0402": return diff --git a/lib/Led5050.tsx b/lib/Led5050.tsx new file mode 100644 index 0000000..f238658 --- /dev/null +++ b/lib/Led5050.tsx @@ -0,0 +1,93 @@ +import { + Colorize, + Cuboid, + Cylinder, + Rotate, + Subtract, + Translate, +} from "jscad-fiber" +import { ChipBody } from "./ChipBody" + +export interface Led5050Props { + color?: string + bodyColor?: string + leadColor?: string +} + +export const Led5050 = ({ + color = "#ffff00", + bodyColor = "#ffffff", + leadColor = "#dedede", +}: Led5050Props) => { + const bodySize = 5 + const leadSpan = 5.4 + const bodyBottom = 0.2 + const bodyHeight = 1.3 + const bodyTop = bodyBottom + bodyHeight + const leadLength = 1.4 + const leadWidth = 1 + const leadThickness = 0.2 + const leadCenterX = leadSpan / 2 - leadLength / 2 + const lensRadius = 2 + const lensHeight = 0.25 + const lensTop = 1.55 + const cornerCutDepth = 0.3 + const leadYPositions = [-1.7, 0, 1.7] + const leadSides = [-1, 1] + + return ( + <> + {leadYPositions.flatMap((y) => + leadSides.map((side) => ( + + )), + )} + + + + + + + + + + + + + + + + ) +} + +export default Led5050 diff --git a/lib/index.ts b/lib/index.ts index a30e911..4fdc865 100644 --- a/lib/index.ts +++ b/lib/index.ts @@ -72,4 +72,5 @@ export * from "./MountedPcbModule" export * from "./Screen" export * from "./JSTZH1_5mm" export * from "./FPC" +export * from "./Led5050" export * from "./RJ45" diff --git a/tests/snapshots/__snapshots__/led5050.snap.png b/tests/snapshots/__snapshots__/led5050.snap.png new file mode 100644 index 0000000..9e85bfd Binary files /dev/null and b/tests/snapshots/__snapshots__/led5050.snap.png differ diff --git a/tests/snapshots/led5050.test.ts b/tests/snapshots/led5050.test.ts new file mode 100644 index 0000000..1f95d3f --- /dev/null +++ b/tests/snapshots/led5050.test.ts @@ -0,0 +1,8 @@ +import { expect, test } from "bun:test" +import "../fixtures/png-matcher" +import { renderFootprint } from "../helpers/render-footprint" + +test("led5050", async () => { + const pngBuffer = await renderFootprint("led5050") + await expect(pngBuffer).toMatchPngSnapshot(import.meta.path) +})