Advertisement
BrU32

JS Canvas Webcam Picture Mask Overlay SRC

Sep 23rd, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. <center>
  2. <body onmousemove="setInterval(Load_Img('http://www.w3schools.com/graphics/pic_the_scream.jpg'),34)" 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. var mediaConfig = { video:true,audio:false};
  12. navigator.mediaDevices.getUserMedia(mediaConfig).then(function(stream) {
  13. video.src = this.window.URL.createObjectURL(stream);
  14. video.play();
  15. video.addEventListener("play", function() {i = window.setInterval(function() {
  16. ctx.drawImage(video,0,0,500,500)},100);
  17. }, false);
  18. });
  19.  
  20. function Load_Img(path){
  21. var h,w;
  22. h=('500');
  23. w=('500')
  24. var canvas = document.getElementById("canvas");
  25. var ctx = canvas.getContext("2d");
  26. var img = new Image();
  27. img.src=(path);
  28. ctx.drawImage(img, 1, 1,h,w);
  29. }
  30. </script>
  31.  
  32. </body>
  33. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement