From 41cf384197ca1a40abffaf11266e927c6133d718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartolome=20=F0=9F=A6=B4=20=28DoctorBot=29?= Date: Thu, 19 Feb 2026 11:22:00 +0000 Subject: [PATCH] feat(props): Add texture property schema for PCB components --- lib/common/pcbStyle.ts | 36 +++++++++++++++++++++--------------- lib/common/texture.ts | 22 ++++++++++++++++++++++ 2 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 lib/common/texture.ts diff --git a/lib/common/pcbStyle.ts b/lib/common/pcbStyle.ts index 8691399..ed704ea 100644 --- a/lib/common/pcbStyle.ts +++ b/lib/common/pcbStyle.ts @@ -1,6 +1,7 @@ import { distance } from "circuit-json" import { expectTypesMatch } from "lib/typecheck" import { z } from "zod" +import { textureSchema } from "./texture" export interface PcbStyle { silkscreenFontSize?: string | number @@ -15,22 +16,27 @@ export interface PcbStyle { offsetY: number } silkscreenTextVisibility?: "hidden" | "visible" | "inherit" + texture?: z.infer } -export const pcbStyle = z.object({ - silkscreenFontSize: distance.optional(), - viaPadDiameter: distance.optional(), - viaHoleDiameter: distance.optional(), - silkscreenTextPosition: z - .union([ - z.enum(["centered", "outside", "none"]), - z.object({ - offsetX: z.number(), - offsetY: z.number(), - }), - ]) - .optional(), - silkscreenTextVisibility: z.enum(["hidden", "visible", "inherit"]).optional(), -}) +export const pcbStyle = z + .object({ + silkscreenFontSize: distance.optional(), + viaPadDiameter: distance.optional(), + viaHoleDiameter: distance.optional(), + silkscreenTextPosition: z + .union([ + z.enum(["centered", "outside", "none"]), + z.object({ + offsetX: z.number(), + offsetY: z.number(), + }), + ]) + .optional(), + silkscreenTextVisibility: z + .enum(["hidden", "visible", "inherit"]) + .optional(), + }) + .and(z.object({ texture: textureSchema.optional() })) expectTypesMatch>(true) diff --git a/lib/common/texture.ts b/lib/common/texture.ts new file mode 100644 index 0000000..44425e3 --- /dev/null +++ b/lib/common/texture.ts @@ -0,0 +1,22 @@ + +import { z } from "zod"; + +export const textureUrlSchema = z.object({ + type: z.literal("url"), + url: z.string().url(), + scale: z.number().optional().default(1), + rotation: z.number().optional().default(0), +}); + +export const proceduralTextureSchema = z.object({ + type: z.literal("procedural"), + pattern: z.enum(["noise", "stripes"]), + // ... other procedural options could go here +}); + +export const textureSchema = z.union([ + textureUrlSchema, + proceduralTextureSchema, +]); + +export type Texture = z.infer;