Badel2 / slime_seed_finder

https://badel2.github.io/slime_seed_finder
GNU General Public License v3.0
49 stars 4 forks source link

Download Map button returns empty image if the rendered biome map is too large #19

Closed Badel2 closed 12 months ago

Badel2 commented 2 years ago

In the biome viewer: https://badel2.github.io/slime_seed_finder/biomes.html

The "DOWNLOAD MAP" button uses an off-screen canvas to generate a high resolution image. However if that canvas is too large, an empty image is downloaded instead. This behavior is explained in the documentation of canvas.toDataUrl:

https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL#return_value

If the height or width of the canvas is 0 or larger than the maximum canvas size, the string "data:," is returned.

So the best solution would be to create an image directly, instead of using a canvas there.

Badel2 commented 12 months ago

Fixed in a0a7a27550f17ca74d9c66d4741a8b45237f6ea7

Now when the canvas is too big for javascript, we copy all the data to Rust and create the huge PNG there. It's very slow and the entire app freezes while waiting for the screenshot to generate, but it works.