Reformat code and add comment about clearRect dimensions.

This commit is contained in:
Jürg Lehni 2011-03-02 16:07:44 +00:00
parent f9346a3b7a
commit 5d680b1987

View file

@ -10,11 +10,13 @@ CanvasProvider = {
var canvas = this.canvases.pop();
// If they are not the same size, we don't need to clear them
// using clearRect and visa versa.
if ((canvas.width != size.width) || (canvas.height != size.height)) {
if ((canvas.width != size.width)
|| (canvas.height != size.height)) {
canvas.width = size.width;
canvas.height = size.height;
} else {
var context = canvas.getContext('2d');
// +1 is needed on some browsers to really clear the borders
context.clearRect(0, 0, size.width + 1, size.height + 1);
}
return canvas;