42 lines
1.2 KiB
JavaScript
42 lines
1.2 KiB
JavaScript
/**
|
|
* State management for the roto editor
|
|
*/
|
|
|
|
import { generateUUID } from "../utils/uuid.js";
|
|
|
|
/**
|
|
* Initialize the editor state
|
|
* @returns {Object} Initial state object
|
|
*/
|
|
export function createState() {
|
|
const shapeId = generateUUID();
|
|
return {
|
|
currentFrame: 1,
|
|
activeShapeId: shapeId,
|
|
shapes: {
|
|
[shapeId]: {
|
|
name: "Shape 1",
|
|
frames: {}
|
|
}
|
|
},
|
|
selectedCurves: new Set(),
|
|
selectedPoints: new Set(), // Format: "curveId:pointIndex"
|
|
dragging: false,
|
|
dragStart: null,
|
|
mode: "draw", // "draw" or "edit"
|
|
addPointMode: false, // true when user clicked "Add Point" button and is ready to click on edge
|
|
canvasWidth: 512,
|
|
canvasHeight: 512,
|
|
previewImage: null,
|
|
previewSourceId: null,
|
|
frameImages: [],
|
|
frameImageCache: new Map(),
|
|
updatingFrame: false,
|
|
featherAmount: 0.0,
|
|
backgroundColor: "#000000",
|
|
maskColor: "#ffffff",
|
|
maskOpacity: 10, // 0-100 integer
|
|
selectionBox: null // { start: {x, y}, end: {x, y}, shiftKey: boolean } or null
|
|
};
|
|
}
|