I'm using canvas.getContext('2d', {alpha: false}); (wiki info) to remove canvas opacity and improve performance of animation. Unfortunately after that, canvas element gain white background. Is there an option to change the default color of canvas background/color?
I tried drawImage() to fill whole area, but (because of animation) I think it is not the best solution:
var canvas = document.querySelector('#mycanvas'),
ctx = canvas.getContext('2d', {alpha: false});
function run() {
ctx.clearRect(0, 0, size.width, size.height);
ctx.drawImage(bg, 0, 0, size.width, size.height);
draw();
update();
requestAnimationFrame(run);
}
I really care about performance, so it would be useful to change the color only once.
Any ideas?