BrU32

Untitled

Apr 9th, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. <style>
  2. body{
  3. filter:contrast(9780%);
  4. filter:brightness(555%)
  5. }
  6. </style>
  7. <center>
  8.  
  9. <div id="container">
  10. <video autoplay id="video">
  11. </div>
  12.  
  13.  
  14. <canvas id="canvas" width="500" height="500"></canvas>
  15. <p>
  16.  
  17. <input type="button" value="Move Mouse Here!!" id="save" />
  18.  
  19.  
  20.  
  21. <script>
  22. var video = document.querySelector("#video");
  23.  
  24. // check for getUserMedia support
  25. navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia || navigator.oGetUserMedia;
  26.  
  27. if (navigator.getUserMedia) {
  28. // get webcam feed if available
  29. navigator.getUserMedia({video: true}, handleVideo, videoError);
  30. }
  31.  
  32. function handleVideo(stream) {
  33. // if found attach feed to video element
  34. video.src = window.URL.createObjectURL(stream);
  35. }
  36.  
  37. function videoError(e) {
  38. // no webcam found - do something
  39. }
  40. var v,canvas,context,w,h;
  41. var imgtag = document.getElementById('imgtag'); // get reference to img tag
  42. var select = document.getElementById('fileselect'); // get reference to file select input element
  43.  
  44. document.addEventListener('mousemove', function(){
  45. // when DOM loaded, get canvas 2D context and store width and height of element
  46. v = document.getElementById('video');
  47. canvas = document.getElementById('canvas');
  48. context = canvas.getContext('2d');
  49. w = canvas.width++;
  50. h = canvas.height++;
  51.  
  52. },777);
  53.  
  54. function draw(v,c,w,h) {
  55.  
  56. if(v.paused || v.ended) {
  57. return 0; // if no video, exit here52*3529
  58. }
  59. context.drawImage(v,120,50,w,h); // draw video feed to canvas
  60.  
  61. var uri = canvas.toDataURL("image/png").length; // convert canvas to data URI
  62.  
  63. if(uri<352000){ // uncomment line to log URI for testing52*3526
  64. alert('Fully Covered From Light!!');
  65. imgtag.src = uri; // add URI to IMG tag src
  66. }else{
  67. alert('Not Covered From Light!!');
  68. imgtag.src = uri; // add URI to IMG tag src
  69. }
  70. }
  71. document.addEventListener('mouseup',function(e){
  72.  
  73. draw(v,context,w,h); // when save button is clicked, draw video feed to canvas
  74.  
  75. });
  76.  
  77. </script>
Advertisement
Add Comment
Please, Sign In to add comment