Advertisement
BrU32

JS Canvas Random Rainbow Flashing Webcam SRC

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