BrU32

Untitled

Jan 2nd, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. context.save();
  2. context.fillStyle = BACKGROUND_COLOR;
  3. context.fillRect(0, 0, screenWidth, screenHeight);
  4. context.fillStyle = grad;
  5. context.fillRect(0, 0, screenWidth, screenHeight);
  6. context.restore();
  7.  
  8. for (i = 0, len = gravities.length; i < len; i++) {
  9. g = gravities[i];
  10. if (g.dragging) g.drag(mouse);
  11. g.render(context);
  12. if (g.destroyed) {
  13. gravities.splice(i, 1);
  14. len--;
  15. i--;
  16. }
  17. }
  18.  
  19. bufferCtx.save();
  20. bufferCtx.globalCompositeOperation = 'destination-out';
  21. bufferCtx.globalAlpha = 0.35;
  22. bufferCtx.fillRect(0, 0, screenWidth, screenHeight);
  23. bufferCtx.restore();
  24.  
  25.  
  26. // for (i = 0, len = particles.length; i < len; i++) {
  27. // particles[i].render(bufferCtx);
  28. // }
  29. len = particles.length;
  30. bufferCtx.save();
  31. bufferCtx.fillStyle = bufferCtx.strokeStyle = '#fff';
  32. bufferCtx.lineCap = bufferCtx.lineJoin = 'round';
  33. bufferCtx.lineWidth = PARTICLE_RADIUS * 2;
  34. bufferCtx.beginPath();
  35. for (i = 0; i < len; i++) {
  36. p = particles[i];
  37. p.update();
  38. bufferCtx.moveTo(p.x, p.y);
  39. bufferCtx.lineTo(p._latest.x, p._latest.y);
  40. }
  41. bufferCtx.stroke();
  42. bufferCtx.beginPath();
  43. for (i = 0; i < len; i++) {
  44. p = particles[i];
  45. bufferCtx.moveTo(p.x, p.y);
  46. bufferCtx.arc(p.x, p.y, p.radius, 0, Math.PI * 2, false);
  47. }
  48. bufferCtx.fill();
  49. bufferCtx.restore();
  50.  
  51.  
  52. context.drawImage(bufferCvs, 0, 0);
  53.  
  54. requestAnimationFrame(loop);
  55. };
  56. loop();
  57.  
  58. })();
Advertisement
Add Comment
Please, Sign In to add comment