Download button

This commit is contained in:
Candifloss 2026-08-08 16:33:53 +05:30
parent 4c5067072f
commit b2cf7a26d7
2 changed files with 18 additions and 1 deletions

15
app.js
View File

@ -89,3 +89,18 @@ brushInput.addEventListener("input", () => {
resizeButton.addEventListener("click", resize); resizeButton.addEventListener("click", resize);
resize(); 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");
});

View File

@ -33,6 +33,8 @@
Brush Brush
<input id="brush" type="number" min="1" value="32"> <input id="brush" type="number" min="1" value="32">
</label> </label>
<button id="download">Download</button>
</div> </div>
<script src="app.js"></script> <script src="app.js"></script>