Download button
This commit is contained in:
parent
4c5067072f
commit
b2cf7a26d7
15
app.js
15
app.js
@ -89,3 +89,18 @@ brushInput.addEventListener("input", () => {
|
||||
resizeButton.addEventListener("click", 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");
|
||||
});
|
||||
@ -33,6 +33,8 @@
|
||||
Brush
|
||||
<input id="brush" type="number" min="1" value="32">
|
||||
</label>
|
||||
|
||||
<button id="download">Download</button>
|
||||
</div>
|
||||
|
||||
<script src="app.js"></script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user