Georg Fischer 7c02eeeffc add canvas helper file
add request animation frame
2013-06-27 15:21:32 +02:00

38 lines
570 B
JavaScript

/*global define*/
define(
function()
{
var update = false;
function resize( canvas, size )
{
if ( canvas.width !== size.width )
{
canvas.width = size.width;
update = true;
}
if ( canvas.height !== size.height )
{
canvas.height = size.height;
update = true;
}
if ( update )
{
canvas.width = size.width;
canvas.height = size.height;
}
update = false;
}
function clear( canvas, ctx )
{
ctx.clearRect( ctx, 0, 0, canvas.width, canvas.height );
}
return { resize: resize, clear: clear };
}
);