diff options
| author | Maze Winther <mazewinther@gmail.com> | 2026-03-25 16:47:22 +0100 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2026-03-29 15:48:22 +0200 |
| commit | 8db3bead13441a5882d8689dfc6a9f09c82375d9 (patch) | |
| tree | e9d0cafa93904ffcbec3188c37961bcc16c6422d /apps/web/src/lib/masks/registry.ts | |
| parent | 39ea298a9ccba3104c549c0ca079c231981811f5 (diff) | |
| download | opencut-8db3bead13441a5882d8689dfc6a9f09c82375d9.tar.gz | |
feat: masks, properties refactor, shaders, storage migrations, and more
Diffstat (limited to 'apps/web/src/lib/masks/registry.ts')
| -rw-r--r-- | apps/web/src/lib/masks/registry.ts | 70 |
1 files changed, 70 insertions, 0 deletions
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<BaseMaskParams> & { + icon: MaskIconProps; +}; + +export class MasksRegistry extends DefinitionRegistry< + MaskType, + RegisteredMaskDefinition +> { + constructor() { + super("mask"); + } + + registerMask<TParams extends BaseMaskParams>({ + definition, + icon, + }: { + definition: MaskDefinition<TParams>; + 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(); |
