Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. <canvas></canvas>
  2.  
  3. <script>
  4.  
  5. var t = 10;
  6. var c = document.querySelector("canvas");
  7. var $ = c.getContext('2d');
  8. c.width = window.innerWidth;
  9. c.height = window.innerHeight;
  10. $.fillStyle = 'hsla(0,0%,0%,1)';
  11.  
  12. window.addEventListener('resize', function() {
  13. c.width = window.innerWidth;
  14. c.height = window.innerHeight;
  15. }, false);
  16.  
  17. function draw() {
  18. $.globalCompositeOperation = 'source-over';
  19. $.fillStyle = 'hsla(0,0%,0%,.1)';
  20. $.fillRect(0, 0, c.width, c.height);
  21. var foo, i, j, r;
  22. foo = Math.sin(t) * 3 * Math.PI;
  23. for (i=0; i<200; ++i) {
  24. r = 150 * Math.sin(i * foo);
  25. $.globalCompositeOperation = '';
  26. $.fillStyle = 'hsla(' + i + 15 + ',100%, 60%,1)';
  27. $.beginPath();
  28. $.arc(Math.sin(i) * r + (c.width / 2),
  29. Math.cos(i) * r + (c.height / 2),
  30. 1.5, 0, Math.PI * 3);
  31. $.fill();
  32.  
  33. }
  34. t += 0.000030;
  35. return t %= 3 * Math.PI;
  36.  
  37. };
  38.  
  39. function run() {
  40. window.requestAnimationFrame(run);
  41. draw();
  42. }
  43. run()
  44. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement