Reputation: 2661
I have a canvas with white background. So when I want to clear it, is there a difference between using
clearRect();
fillStyle="#FFFFFF";
fillRect();
and
fillStyle="#FFFFFF";
fillRect();
Is using any of them considered a better practice or has an effect on the outcome of getImageData()
?
Upvotes: 3
Views: 1522
Reputation: 607
If you don't clear it first, you'll be drawing on top of what was previously there. If you not using any transparencies, maybe this is OK.
Another difference is that clearRect() doesn't use a white background. it uses a transparent one.
Upvotes: 2