about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2024-12-24 19:34:41 -0500
committerelioat <elioat@tilde.institute>2024-12-24 19:34:41 -0500
commit763b54d830b67eefaac38fd0e333281df068805d (patch)
tree3b1bb3f60d29cbe6b5f2df5306842c0c6a31dbd5
parent9ec48fa5f463fcae13c518f978a91e2bf5942479 (diff)
downloadtour-763b54d830b67eefaac38fd0e333281df068805d.tar.gz
*
-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 {