mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Reformat code and add comment about clearRect dimensions.
This commit is contained in:
parent
f9346a3b7a
commit
5d680b1987
1 changed files with 3 additions and 1 deletions
|
@ -10,11 +10,13 @@ CanvasProvider = {
|
||||||
var canvas = this.canvases.pop();
|
var canvas = this.canvases.pop();
|
||||||
// If they are not the same size, we don't need to clear them
|
// If they are not the same size, we don't need to clear them
|
||||||
// using clearRect and visa versa.
|
// 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.width = size.width;
|
||||||
canvas.height = size.height;
|
canvas.height = size.height;
|
||||||
} else {
|
} else {
|
||||||
var context = canvas.getContext('2d');
|
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);
|
context.clearRect(0, 0, size.width + 1, size.height + 1);
|
||||||
}
|
}
|
||||||
return canvas;
|
return canvas;
|
||||||
|
|
Loading…
Reference in a new issue