diff --git a/web/src/lib/registry-new/filters.ts b/web/src/lib/registry-new/filters.ts index 96fe2e1..d9af300 100644 --- a/web/src/lib/registry-new/filters.ts +++ b/web/src/lib/registry-new/filters.ts @@ -1,9 +1,71 @@ import type { ToolEntry } from "./types"; import { field, toolSchema } from "../registry-schema"; -import { addNoise, pixelate, shuffleBlocks } from "../core/pixel-fx"; +import { + addNoise, + pixelate, + shuffleBlocks, + silhouette, +} from "../core/pixel-fx"; +import { gaussianBlur, sharpen as sharpenImage } from "../core/convolution"; import { vignette } from "../core/effects"; import { jpegRoundtrip } from "../core/io"; +interface BlurParams { + radius: number; +} + +export const blurSchema = toolSchema({ + radius: field.slider({ min: 1, max: 32, step: 1, default: 4 }), +}); + +const blurTool: ToolEntry = { + id: "blur-png", + title: "Blur PNG", + description: + "Gaussian blur: three passes of separable box blur — fast at any radius. Transparent edges do not darken.", + category: "filters", + schema: blurSchema, + run: (img, p) => gaussianBlur(img, p.radius), +}; + +interface SharpenParams { + strength: number; +} + +export const sharpenSchema = toolSchema({ + strength: field.slider({ min: 0, max: 100, step: 1, default: 50 }), +}); + +const sharpenTool: ToolEntry = { + id: "sharpen-png", + title: "Sharpen PNG", + description: + "Emphasizes edges with a sharpening kernel; strength sets the blend with the original. 0% means no change.", + category: "filters", + schema: sharpenSchema, + run: (img, p) => sharpenImage(img, p.strength), +}; + +interface SilhouetteParams { + color: string; + threshold: number; +} + +export const silhouetteSchema = toolSchema({ + color: field.color({ default: "#111318" }), + threshold: field.slider({ min: 0, max: 100, step: 1, default: 10 }), +}); + +const silhouetteTool: ToolEntry = { + id: "silhouette-png", + title: "Silhouette PNG", + description: + "Turns all visible pixels into a single solid color while keeping their transparency — instant silhouette.", + category: "filters", + schema: silhouetteSchema, + run: (img, p) => silhouette(img, p.color, p.threshold * 2.55), +}; + interface VignetteParams { strength: number; } @@ -129,4 +191,7 @@ export const filtersEntries = [ randomizePixels, addNoiseTool, jpegArtifacts, + blurTool, + sharpenTool, + silhouetteTool, ];