From 8db3bead13441a5882d8689dfc6a9f09c82375d9 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Wed, 25 Mar 2026 16:47:22 +0100 Subject: feat: masks, properties refactor, shaders, storage migrations, and more --- apps/web/src/lib/masks/registry.ts | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 apps/web/src/lib/masks/registry.ts (limited to 'apps/web/src/lib/masks/registry.ts') diff --git a/apps/web/src/lib/masks/registry.ts b/apps/web/src/lib/masks/registry.ts new file mode 100644 index 00000000..5a98cb41 --- /dev/null +++ b/apps/web/src/lib/masks/registry.ts @@ -0,0 +1,70 @@ +import { MAX_FEATHER } from "@/constants/mask-constants"; +import type { ParamDefinition } from "@/lib/params"; +import type { BaseMaskParams, MaskDefinition, MaskType } from "@/lib/masks/types"; +import type { HugeiconsIconProps } from "@hugeicons/react"; +import { DefinitionRegistry } from "@/lib/registry"; + +export type MaskIconProps = { + icon: HugeiconsIconProps["icon"]; + strokeWidth?: number; +}; + +const BASE_MASK_PARAM_DEFINITIONS: ParamDefinition< + keyof BaseMaskParams & string +>[] = [ + { + key: "feather", + label: "Feather", + type: "number", + default: 0, + min: 0, + max: MAX_FEATHER, + step: 1, + unit: "percent", + }, + { + key: "strokeWidth", + label: "Stroke width", + type: "number", + default: 0, + min: 0, + max: 100, + step: 1, + }, + { + key: "strokeColor", + label: "Stroke color", + type: "color", + default: "#ffffff", + }, +]; + +export type RegisteredMaskDefinition = MaskDefinition & { + icon: MaskIconProps; +}; + +export class MasksRegistry extends DefinitionRegistry< + MaskType, + RegisteredMaskDefinition +> { + constructor() { + super("mask"); + } + + registerMask({ + definition, + icon, + }: { + definition: MaskDefinition; + icon: MaskIconProps; + }): void { + const withBaseParams: RegisteredMaskDefinition = { + ...definition, + params: [...definition.params, ...BASE_MASK_PARAM_DEFINITIONS], + icon, + }; + this.register(definition.type, withBaseParams); + } +} + +export const masksRegistry = new MasksRegistry(); -- cgit v1.3.1