BrU32

JS Canvas Cam Cover Up

Dec 18th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. ​
  2. <center>
  3. <body onmousemove="setInterval(Load_Img('http://www.w3schools.com/graphics/pic_the_scream.jpg'),34)" background-color="white">
  4. <video id="video" autoplay hidden>
  5. </video>
  6. <canvas id="canvas" width="1000" height="1000" 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: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,1000,1000)},100);
  18. }, false);
  19. });
  20.  
  21. function Load_Img(path){
  22. var h,w;
  23. h=('500');
  24. w=('500')
  25. var canvas = document.getElementById("canvas");
  26. var ctx = canvas.getContext("2d");
  27. var img = new Image();
  28. img.src=(path);
  29. ctx.drawImage(img, 1, 1,h+2,w*2);
  30. }
  31. </script>
  32.  
  33. </body>
  34. </html>
Advertisement
Add Comment
Please, Sign In to add comment