mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-22 20:11:24 +01:00
Reuse existing image element on conversion.
This commit is contained in:
parent
16f6557e69
commit
d01e2faa75
1 changed files with 8 additions and 4 deletions
|
|
@ -1006,10 +1006,14 @@ function editHeightmap() {
|
|||
this.value = ""; // reset input value to get triggered if the file is re-uploaded
|
||||
const reader = new FileReader();
|
||||
|
||||
const img = new Image();
|
||||
img.id = "imageToConvert";
|
||||
const imgId = "imageToConvert";
|
||||
let img = document.getElementById(imgId);
|
||||
if (!img) {
|
||||
img = new Image();
|
||||
img.id = imgId;
|
||||
img.style.display = "none";
|
||||
document.body.appendChild(img);
|
||||
}
|
||||
|
||||
img.onload = function () {
|
||||
const ctx = document.getElementById("canvas").getContext("2d");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue