Advertisement
BrU32

JS Canvas Webcam Slow Size Increase W\ Bubbles SRC

Nov 22nd, 2016
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. <center>
  2. <body onload="setInterval(drawe,200)" background-color="white">
  3. <video id="video" autoplay hidden>
  4. </video>
  5. <canvas id="canvas" width="500" height="500" style="drawColor:#FFFFFF">
  6. <script>
  7. var video = document.getElementById("video");
  8. var c = document.getElementById("canvas");
  9. var ctx = c.getContext("2d");
  10. var i=0;
  11. function dd(){
  12. var mediaConfig = { video:true,audio:false};
  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,i,i)},0.1);
  18. i++;
  19. },true);
  20. });
  21. }
  22.  
  23. var ii=500;
  24. function drawe(){
  25. dd()
  26. ii--;
  27. var text = "";
  28. var possible = "FABCGDE0123456789";
  29. var canvas = document.getElementById("canvas");
  30. var ctx = canvas.getContext("2d");
  31. for(var i=0; i!=6; i++)
  32. text+=possible.charAt(Math.floor(Math.random()*possible.length));
  33. ctx.strokeStyle='#'+text;
  34. ctx.fillStyle="#"+text;
  35. var c = document.getElementById("canvas");
  36. var ctx = c.getContext("2d");
  37. ctx.beginPath();
  38. ctx.arc(Math.random()*ii,Math.random()*ii,Math.random()*ii,Math.random()/ii,ii);
  39. ctx.fill();
  40. text='';
  41. }
  42. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement