Guest User

Untitled

a guest
Apr 24th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. function drawCircle() {
  2.  
  3. // color in the background
  4. context.fillStyle = "#EEEEEE";
  5. context.fillRect(0, 0, canvas.width, canvas.height);
  6.  
  7. // draw the circle
  8. context.beginPath();
  9.  
  10. var radius = 25 + 20 * Math.abs(Math.cos(angle)); //radius of circle
  11. context.arc(25, 25, radius, 0, Math.PI * 2, false); //position on canvas
  12. context.closePath();
  13.  
  14. // color in the circle
  15. context.fillStyle = "#006699";
  16. context.fill();
  17.  
  18. //'pulse'
  19. angle += Math.PI / 220;
  20.  
  21. requestAnimationFrame(drawCircle);
  22. }
  23. drawCircle();
  24.  
  25. function drawTriangle() {
  26.  
  27. // draw the triangle
  28. context.beginPath();
  29. context.moveTo(75, 50);
  30. context.lineTo(100, 75);
  31. context.lineTo(100, 25);
  32. context.fill();
  33.  
  34. context.rect(215, 100, Math.PI * 2, false); //position on canvas
  35. context.closePath();
  36.  
  37. // color in the triangle
  38. context.fillStyle = "#3f007f";
  39. context.fill();
  40.  
  41. //'pulse'
  42. angle += Math.PI / 280;
  43.  
  44. requestAnimationFrame(drawTriangle);
  45. }
  46. drawTriangle();
Add Comment
Please, Sign In to add comment