I can draw an image to the canvas but if i want to remove it and draw another one instead how can I do that?
Currently I store the base64 encoded image in a variable. If I unset the variable then the image disappears but if i click to redraw it again i get the following warning:
"Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true."
As you can see in the code below I am already setting 'willReadFrequently' to true which should prevent this warning but I think that somehow the canvas is hanging around in memory somewhere.
I can draw an image to the canvas but if i want to remove it and draw another one instead how can I do that? Currently I store the base64 encoded image in a variable. If I unset the variable then the image disappears but if i click to redraw it again i get the following warning:
"Multiple readback operations using getImageData are faster with the willReadFrequently attribute set to true."
As you can see in the code below I am already setting 'willReadFrequently' to true which should prevent this warning but I think that somehow the canvas is hanging around in memory somewhere.
const elementToCapture = document.body; const canvas = await html2canvas(elementToCapture); canvas.getContext('2d', { willReadFrequently: true, // => faster multiple readback operations }); const thumbnail = canvas.toDataURL('image/png');