Advertisement
BrU32

JS Canvas Laser Pen Simulator SRC

Nov 3rd, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body onload="setInterval(doit,31);" bgcolor="black">
  4.  
  5. <canvas id="myCanvas" width="1000" height="1000" style="border:1px solid #black;">
  6. Your browser does not support the HTML5 canvas tag.</canvas>
  7.  
  8. <script>
  9. function doit(){
  10. var c = document.getElementById("myCanvas");
  11. var ctx = c.getContext("2d");
  12.  
  13. var gradient = ctx.createLinearGradient(0, 0, Math.random()*170, 0);
  14. gradient.addColorStop("0", "black");
  15. gradient.addColorStop("0.5", "red");
  16. gradient.addColorStop("1.0", "black");
  17.  
  18. ctx.fillStyle = gradient;
  19. ctx.lineWidth = 10;
  20. ctx.fillRect(0, 0, 500,250);
  21. }
  22. </script>
  23. </body>
  24. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement