Joe Honton
Sep 3, 2022

--

My variation on capturing and downloading the current <canvas> :

```

canvas.toBlob((myBlob) => {

var anchor = document.createElement('a');

anchor.download = destFilename;

anchor.href = URL.createObjectURL(myBlob);

anchor.click();

URL.revokeObjectURL(anchor.href);

// provide visual delay to user to signal

setTimeout(() => {

elDownload.disabled = false;

}, 1000);

}, 'image/webp');

```

It happens in the blink of an eye, so I introduced a 1 second timeout to the UI feedback, giving the user some sense that real work was performed. Otherwise they might press the elDownload button twice.

--

--

Joe Honton
Joe Honton

Written by Joe Honton

Princeps geographus, Read Write Tools

No responses yet