BrU32

JS Canvas 2D Pipes Drawing SRC W/ Custom Speed Control V2

Sep 7th, 2016
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <html>
  2. <center>
  3. <body onload="var speed=prompt('Enter Speed To Render At In Millisecond format:(IE 0.1-2000)');
  4. if(speed<0.1||speed==''){
  5. alert('Speed Was Invalid Try Again!!');
  6. return false;
  7. }
  8. setInterval(drawe,speed)" onclick="alert('Paused Canvas Drawing!!\n\nPress OK To Resume!!');" background-color="black">
  9. <canvas id="myCanvas" width="1000" height="1000" style="background:black;">
  10. </canvas>
  11. <script>
  12. function drawe(){
  13. var text = "";
  14. var possible = "FABCGDE0123456789";
  15. var canvas = document.getElementById("myCanvas");
  16. var ctx = canvas.getContext("2d");
  17. for(var i=0; i!=6; i++)
  18. text+=possible.charAt(Math.floor(Math.random()*possible.length));
  19. ctx.strokeStyle='#'+text;
  20. ctx.strokeRect(Math.random()*1000,Math.random()*1000,Math.random()*1000,Math.random()*10000);
  21. ctx.stroke();
  22. text='';
  23. }
  24. </script>
  25. </body>
  26. </html>
Advertisement
Add Comment
Please, Sign In to add comment