views:

340

answers:

1

I have a very large html canvas element covering a solid background. I would assume that a lot of cpu could be saved when scrolling/panning if the browser did not blend the canvas to elements behind it (in this case, a solid color).

Is it possible to remove the canvas alpha channel? Should this be left up to browsers to detect and optimize for? Or would speed gains be insignificant?

A: 

Yep, just put a rectangle without alpha :)

var context = document.getElementById("id of your canvas).getContext('2d');

context .fillStyle = "rgba(0,0,0,1)";//(red, green, blue, alpha from 0 to 255); //or just context .fillStyle = "rgb(0,0,0)";//without alpha context .fillRect(0,0,your canvas width, your canvas height);

canvas