Guest User

Untitled

a guest
Dec 16th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. var canvas = document.body.appendChild( document.createElement( 'canvas' ) ),
  2. context = canvas.getContext( '2d' ),
  3. t = 0,
  4. w, h;
  5.  
  6. context.globalCompositeOperation = 'lighter';
  7. window.addEventListener( 'resize', resize, false );
  8.  
  9. resize();
  10. animate();
  11.  
  12. function resize() {
  13. w = canvas.width = window.innerWidth;
  14. h = canvas.height = window.innerHeight;
  15. }
  16.  
  17. function animate() {
  18. context.clearRect( 0, 0, w, h );
  19.  
  20. t += 0.1;
  21.  
  22. for( var i = 0; i < 5000; i++ ) {
  23. var f = 0.05 + ( ( Math.sin(t*0.00002) / Math.PI ) * 0.2 );
  24. var r = ( Math.min( w, h ) ) * ( Math.cos( (t+i)*f ) / Math.PI * 1.5 );
  25.  
  26. var x = Math.sin(i) * r + (canvas.width/2);
  27. var y = Math.cos(i) * r + (canvas.height/2);
  28.  
  29. context.fillStyle = 'rgba(0,255,255,0.5)';
  30. context.fillRect( x, y, 1.5, 1.5 );
  31. }
  32.  
  33. setTimeout( animate, 16 );
  34. }
Add Comment
Please, Sign In to add comment