about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2024-12-24 19:47:36 -0500
committerelioat <elioat@tilde.institute>2024-12-24 19:47:36 -0500
commit8d8903405dc8963c71452fa4d834b0731dd4d8b9 (patch)
tree63d4b9f4b9b78ba010645d94a99ef80e7b6fbb89
parent763b54d830b67eefaac38fd0e333281df068805d (diff)
downloadtour-8d8903405dc8963c71452fa4d834b0731dd4d8b9.tar.gz
*
-rw-r--r--js/pixel-art/pixel/app.js12
1 files changed, 11 insertions, 1 deletions
diff --git a/js/pixel-art/pixel/app.js b/js/pixel-art/pixel/app.js
index 4bf953b..33b1952 100644
--- a/js/pixel-art/pixel/app.js
+++ b/js/pixel-art/pixel/app.js
@@ -264,6 +264,10 @@ function loadFromLocalStorage() {
 }
 
 function exportToPNG() {
+    // Prompt for filename
+    const filename = prompt("Enter a name for your file(s)", "pixel-art");
+    if (!filename) return; // User cancelled
+    
     canvases.forEach((canvasData, index) => {
         const tempCanvas = document.createElement('canvas');
         const tempCtx = tempCanvas.getContext('2d');
@@ -277,10 +281,16 @@ function exportToPNG() {
             }
         }
 
+        // Create padded number for multiple files
+        const paddedNumber = String(index + 1).padStart(2, '0');
+        const finalFilename = canvases.length > 1 
+            ? `${filename}-${paddedNumber}.png`
+            : `${filename}.png`;
+
         tempCanvas.toBlob(blob => {
             const link = document.createElement('a');
             link.href = URL.createObjectURL(blob);
-            link.download = `pixel-art-${index + 1}.png`;
+            link.download = finalFilename;
             link.click();
         });
     });