5 ms·
> re-use your gradients as much as possible, and try to avoid creating them in loops. If you have one gradient that fills several figures you should be making i
by p0nce 14y ago
> re-use your gradients as much as possible, and try to avoid creating them in loops. If you have one gradient that fills several figures you should be making it only once. The function createLinearGradient(x0, y0, x1, y1) goes from one point to another, but you can make your gradient at the origin createLinearGradient(0, 0, toX, toY) and then translate it into the correct location for each figure made in the for loop.
Very true, I did exactly that for http://www.gamesfrommars.fr/demojsv2/ http://www.gamesfrommars.fr/demojsv2/