Advertisement
BrU32

JS Canvas Webcam Rainbow Circle Takeoff Effect SRC

Sep 23rd, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1.  
  2. <center>
  3. <body onload="setInterval(drawe,.01)" background-color="white">
  4. <video id="video" autoplay hidden>
  5. </video>
  6. <canvas id="canvas" width="500" height="500" style="drawColor:#FFFFFF">
  7. <script>
  8. var video = document.getElementById("video");
  9. var c = document.getElementById("canvas");
  10. var ctx = c.getContext("2d");
  11. var i=0;
  12. var mediaConfig = { video:true,audio:true};
  13. navigator.mediaDevices.getUserMedia(mediaConfig).then(function(stream) {
  14. video.src = this.window.URL.createObjectURL(stream);
  15. video.play();
  16. video.addEventListener("play", function() {i = window.setInterval(function() {
  17. ctx.drawImage(video,0,0,500,500)},0.1);
  18. }, false);
  19. });
  20.  
  21. var ii=250;
  22. function drawe(){
  23. ii++;
  24. var text = "";
  25. var possible = "FABCGDE0123456789";
  26. var canvas = document.getElementById("canvas");
  27. var ctx = canvas.getContext("2d");
  28. for(var i=0; i!=6; i++)
  29. text+=possible.charAt(Math.floor(Math.random()*possible.length));
  30. ctx.strokeStyle='#'+text;
  31. ctx.fillStyle="#"+text;
  32. var c = document.getElementById("canvas");
  33. var ctx = c.getContext("2d");
  34. ctx.beginPath();
  35. ctx.arc(ii--,ii,ii,ii--,ii*Math.PI);
  36. ctx.fill();
  37. text='';
  38. }
  39. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement