Advertisement
Guest User

Untitled

a guest
Jul 25th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <canvas id="c" width="600" height="600"></canvas>
  2.  
  3. <script type="text/javascript">
  4. /*
  5. // c is defined by browser since canvas has id c
  6. t=c.getContext('2d')
  7. s=600 // square canvas size
  8. p=80 // number of points, lines and margins!
  9. g=(s-2*p)/p // gap between each point and line
  10. for(i=0;i<p;i++){
  11. for(k=0;k<p;k++){
  12. u=Math.pow(2*( // upper limit
  13. k<p/2 // detect half way point on each line
  14. ?k // from 0 to 0.5
  15. :p-k // from 0.5 to 1
  16. ),3)/p/700 // power it up to spike at halfway point, and divide by magic number to keep it within range
  17. l=u/1.5 // lower limit, slightly below upper limit
  18. t[k?'lineTo':'moveTo']( // first node in line do a move to, otherwise line to.
  19. p+k*g, // x
  20. p+(i-(l+Math.random()*(u-l)))*g // y
  21. )
  22. }
  23. }
  24. t.fillRect(0,0,s,s)
  25. t.strokeStyle='#fff'
  26. t.fill()
  27. t.stroke()
  28. */
  29. t=c.getContext('2d'),s=600,p=80,g=(s-2*p)/p;for(i=0;i<p;i++){for(k=0;k<p;k++){u=Math.pow(2*(k<p/2?k:p-k),3)/p/700,l=u/1.5;t[k?'lineTo':'moveTo'](p+k*g,p+(i-(l+Math.random()*(u-l)))*g)}};t.fillRect(0,0,s,s);t.strokeStyle='#fff';t.fill();t.stroke();
  30. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement