Advertisement
BrU32

JS Canvas Random Rainbow Webcam SRC V2

Oct 28th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. <center>
  2. <body onload="Test()">
  3. <video id="video" autoplay hidden>
  4. </video>
  5. <canvas id="canvas" width="500" height="500" style="border:0px solid"/>
  6.  
  7. <script>
  8. function Test(){
  9. setInterval("Gen()",10);
  10. }
  11. var video = document.getElementById("video");
  12. var c = document.getElementById("canvas");
  13. var ctx = c.getContext("2d");
  14. var i=0;
  15. var canvas = document.getElementById('canvas');
  16. var context = canvas.getContext('2d');
  17. var video = document.getElementById('video');
  18. var mediaConfig = {video:true,audio:true};
  19. navigator.mediaDevices.getUserMedia(mediaConfig).then(function(stream) {
  20. video.src = this.window.URL.createObjectURL(stream);
  21. video.play();
  22. video.addEventListener("play", function() {i = window.setInterval(function() {
  23. ctx.drawImage(video,0,0,500,500)},1);
  24.  
  25. }, false);
  26. });
  27. function Gen()
  28. {
  29. var text = "";
  30. var possible = "FABCGDEG01234567";
  31. for(var i=0; i!=6; i++)
  32. text+=possible.charAt(Math.floor(Math.random()*possible.length));
  33. document.body.style.backgroundColor=(text);
  34.  
  35. }
  36. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement