- Refactor LayersSheet component to support mask editing state and improve layer visibility handling. - Introduce functions to collect mask layer IDs and count display layers excluding masks. - Update BrushControls to include mask view mode options and a Done button for exiting mask editing. - Modify brush session handling to support brush previews when editing masks. - Implement a new BrushPreviewRenderer for rendering brush strokes with visual feedback. - Add document geometry utilities for transforming points and resolving layer bounds. - Ensure proper cleanup of brush preview on pointer leave and other interactions.
34 lines
715 B
TypeScript
34 lines
715 B
TypeScript
import type { AppState, EditorState } from "./state";
|
|
import { initialToolState } from "./tools";
|
|
|
|
export const initialEditorState: EditorState = {
|
|
viewport: {
|
|
center: { x: 0, y: 0 },
|
|
zoom: 1,
|
|
rotation: 0,
|
|
size: { w: 0, h: 0 },
|
|
},
|
|
selection: {
|
|
layerIds: [],
|
|
},
|
|
tools: initialToolState,
|
|
transformSession: undefined,
|
|
maskEdit: undefined,
|
|
brushPreview: undefined,
|
|
brushStrokePreview: undefined,
|
|
};
|
|
|
|
export function createInitialAppState(name = "Untitled"): AppState {
|
|
return {
|
|
document: {
|
|
id: crypto.randomUUID(),
|
|
name,
|
|
version: 1,
|
|
artboards: [],
|
|
assets: [],
|
|
},
|
|
editor: initialEditorState,
|
|
history: { past: [], future: [] },
|
|
};
|
|
}
|