From b2cf7a26d7cac13fa34b630a7da11e6bcbe7bb96 Mon Sep 17 00:00:00 2001 From: candifloss Date: Sat, 8 Aug 2026 16:33:53 +0530 Subject: [PATCH] Download button --- app.js | 17 ++++++++++++++++- index.html | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 627cc88..e1a0920 100644 --- a/app.js +++ b/app.js @@ -88,4 +88,19 @@ brushInput.addEventListener("input", () => { resizeButton.addEventListener("click", resize); -resize(); \ No newline at end of file +resize(); + +const downloadButton = document.getElementById("download"); + +downloadButton.addEventListener("click", () => { + canvas.toBlob(blob => { + const url = URL.createObjectURL(blob); + const link = document.createElement("a"); + + link.href = url; + link.download = "tile_image.png"; + link.click(); + + URL.revokeObjectURL(url); + }, "image/png"); +}); \ No newline at end of file diff --git a/index.html b/index.html index 9ab817f..c863b8f 100644 --- a/index.html +++ b/index.html @@ -33,6 +33,8 @@ Brush + +