Question

Is it possible to go back after I use drawImage?

Example:

I draw an image and them overdraw another. I want to delete the first image and, on the clear surface, draw a new image.

Is it possible?

Was it helpful?

Solution

if you want to undo drawImage changes, you must save canvas data before doing drawImage like:

tmp = canvas.getContext("2d").getImageData(0, 0, with, height);
//do changes here
canvas.getContext("2d").putImageData(tmp , 0, 0);
//here changes will be lost

this is unswer to the title, question content was not clear for me

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top