import * as PIXI from "pixi.js-legacy"; /** * Costume Editor - A comprehensive sprite/costume editor * Supports drawing, shapes, text, and editing existing costumes */ let editorApp = null; let editorContainer = null; let editorCanvas = null; let currentTool = 'pen'; let fillColor = '#000000'; let outlineColor = '#000000'; let outlineSize = 2; let fillEnabled = true; let penSize = 2; let isDrawing = false; let objects = []; // All drawable objects on canvas let selectedObject = null; let dragOffset = { x: 0, y: 0 }; let isDragging = false; let tempGraphics = null; let startPoint = null; let resizeHandles = []; let isResizing = false; let resizeHandle = null; let shiftPressed = false; let snapToGrid = false; let currentStroke = null; let lastDrawPoint = null; let undoStack = []; let redoStack = []; const MAX_UNDO_STEPS = 50; const GRID_SIZE = 20; let penGraphics = null; let isPenActive = false; const SNAP_THRESHOLD = 10; let initialSize = { width: 0, height: 0 }; let initialPosition = { x: 0, y: 0 }; const CANVAS_WIDTH = 720; const CANVAS_HEIGHT = 480; export function openCostumeEditor(existingCostume = null, onSave) { closeCostumeEditor(); // Close any existing editor // Create editor container editorContainer = document.createElement('div'); editorContainer.className = 'costume-editor-overlay'; editorContainer.innerHTML = `