BrU32

JS Canvas Random Rect/Random Color Drawing SRC

Aug 18th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <html>
  2. <body onload="setInterval(drawe,100)" background-color="white">
  3. <canvas id="myCanvas" width="1000" height="1000" style="background:black;">
  4. </canvas>
  5. <script>
  6. function drawe(){
  7. var text = "";
  8. var possible = "FABCGDE0123456789";
  9. var canvas = document.getElementById("myCanvas");
  10. var ctx = canvas.getContext("2d");
  11. for(var i=0; i!=6; i++)
  12. text+=possible.charAt(Math.floor(Math.random()*possible.length));
  13. ctx.strokeStyle='#'+text;
  14. ctx.fillStyle="#"+text;
  15. ctx.beginPath();
  16. ctx.fillRect(0,0,Math.random()*1000,Math.random()*1000);
  17. ctx.fill();
  18. text='';
  19. }
  20. </script>
  21. </body>
  22. </html>
Advertisement
Add Comment
Please, Sign In to add comment