Files
image-studio/editor/tools.ts
2026-07-03 17:49:00 +02:00

30 lines
850 B
TypeScript

export const availableToolIds = ["select", "crop", "brush", "eraser", "pan"] as const;
export type ToolId = (typeof availableToolIds)[number];
export type InteractionMode =
| { type: "tool"; tool: ToolId }
| { type: "temporary-pan"; previousTool: ToolId };
export type BrushSettings = {
color: string;
size: number;
hardness: number;
};
export type ToolState = {
activeTool: ToolId;
interactionMode: InteractionMode;
brush: BrushSettings;
};
export const initialToolState: ToolState = {
activeTool: "select",
interactionMode: { type: "tool", tool: "select" },
brush: { color: "#111827", size: 8, hardness: 100 },
};
export function isPanInteractionMode(interactionMode: InteractionMode): boolean {
return interactionMode.type === "temporary-pan" || (interactionMode.type === "tool" && interactionMode.tool === "pan");
}