Saturday, August 27, 2011

Html5 Tip: How Can I Reset a Canvas

  
Changing the width or height of a canvas element will remove its contents and reset all the properties (like fillstyle) of its drawing context to their default values. You don’t even need to change the width; you can simply set it to its current value, like this:
var canvas = document.getElementById("mycanvas");
canvas.width = canvas.width;

See Also:

1 comment: