about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--js/pixel-art/pixel/app.js42
1 files changed, 26 insertions, 16 deletions
diff --git a/js/pixel-art/pixel/app.js b/js/pixel-art/pixel/app.js
index 8fae18b..4bf953b 100644
--- a/js/pixel-art/pixel/app.js
+++ b/js/pixel-art/pixel/app.js
@@ -60,18 +60,13 @@ function addNewCanvas() {
     canvases.push({
         grid: Array(gridWidth).fill().map(() => Array(gridHeight).fill(null)),
         offsetX: 0,
-        offsetY: 0
+        offsetY: 0,
+        hasPixels: false
     });
     currentCanvasIndex = canvases.length - 1;
     centerGrid();
     drawGrid();
     saveToLocalStorage();
-    
-    // Disable width/height inputs after first canvas is created
-    if (canvases.length > 0) {
-        document.getElementById('gridWidth').disabled = true;
-        document.getElementById('gridHeight').disabled = true;
-    }
 }
 
 function initializeGrid() {
@@ -166,21 +161,29 @@ function handleReset() {
     const confirmReset = confirm("Are you sure you want to reset? This will clear your drawing and settings.");
     
     if (confirmReset) {
+        // Reset to defaults
         gridWidth = defaultGridWidth;
         gridHeight = defaultGridHeight;
-        initializeGrid();
-        centerGrid();
-        drawGrid();
-        localStorage.removeItem('pixelArtConfig');
+        cellSize = 16;
+        globalOffsetX = 0;
+        globalOffsetY = 0;
         colorHistory = [];
         renderColorHistory();
-        canvases = [];  // Clear canvases array
-        document.getElementById('gridWidth').value = gridWidth;
-        document.getElementById('gridHeight').value = gridHeight;
-        // Re-enable inputs after reset
+        
+        // Clear canvases and add a fresh one
+        canvases = [];
+        addNewCanvas();
+        
+        // Enable inputs for the fresh canvas
         document.getElementById('gridWidth').disabled = false;
         document.getElementById('gridHeight').disabled = false;
-        alert("Grid reset, color history cleared, and local storage cleared.");
+        document.getElementById('gridWidth').value = gridWidth;
+        document.getElementById('gridHeight').value = gridHeight;
+        
+        // Clear localStorage
+        localStorage.removeItem('pixelArtConfig');
+        
+        alert("Reset complete. You can now adjust the grid size until you place your first pixel.");
     }
 }
 
@@ -292,6 +295,13 @@ function handleInputStart(e) {
     if (cell) {
         lastCell = cell;
         currentCanvasIndex = cell.canvasIndex;
+        
+        // Lock grid size on first pixel placement
+        if (!document.getElementById('gridWidth').disabled) {
+            document.getElementById('gridWidth').disabled = true;
+            document.getElementById('gridHeight').disabled = true;
+        }
+        
         if (canvases[currentCanvasIndex].grid[cell.x][cell.y]) {
             canvases[currentCanvasIndex].grid[cell.x][cell.y] = null;
         } else {