lundi 4 juillet 2016

Canvas - how to fill all circles at once, not one by one


I have while loop drawing circles one by one:

actx.shadowColor = 'rgba(0, 0, 0, 1)';
while (len--) {
   var point = data[len];

   actx.beginPath();
   actx.arc(point[0] - 15000, point[1] - 15000, 10, 0, Math.PI * 2);
   actx.closePath();
   actx.fill();
}

It seems a little bit slow for me, so I am thinking how it could be optimized. I have found that the fill() function takes the longest, so I have tried put it after the loop, but it draws only the last circle.

  1. Is there any way how to fill all the circles at once?
  2. Or is there any other, faster method?

Aucun commentaire:

Enregistrer un commentaire