30 lines
842 B
TypeScript
30 lines
842 B
TypeScript
export const availableToolIds = ["select", "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");
|
|
}
|