BrU32

JS Canvas Webcam New FXXXXX For Christmas

Dec 20th, 2016
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. <style>
  2. body{
  3.  
  4.  
  5. filter:invert(1800);
  6. filter:brightness:(3333);
  7. }
  8.  
  9. </style>
  10.  
  11. <center>
  12. <body onload="setInterval(drawe,33)" bgcolor="black">
  13. <video id="video" autoplay hidden>
  14. </video>
  15. <canvas id="canvas" width="500" height="500" style="drawColor:#FFFFFF">
  16. <script>
  17. var inn=prompt("Enter Text:")
  18. var video = document.getElementById("video");
  19. var c = document.getElementById("canvas");
  20. var ctx = c.getContext("2d");
  21. var i=0;
  22. var mediaConfig = { video:true,audio:true};
  23. navigator.mediaDevices.getUserMedia(mediaConfig).then(function(stream) {
  24. video.src = this.window.URL.createObjectURL(stream);
  25. video.play();
  26. video.addEventListener("play", function() {i = window.setInterval(function() {
  27. ctx.drawImage(video,0,0)},40);
  28. ctx.topmost=false;
  29. ctx.draw();
  30. }, false);
  31. });
  32.  
  33. var ii=50;
  34. function drawe(){
  35. ii++;
  36. var text = "";
  37. var possible = "FABCGDE0123456789";
  38. var canvas = document.getElementById("canvas");
  39. var ctx = canvas.getContext("2d");
  40. for(var i=0; i!=6; i++)
  41. text+=possible.charAt(Math.floor(Math.random()*possible.length));
  42. ctx.font="35px Sans Serif";
  43. ctx.fillStyle="#"+text;
  44. var c = document.getElementById("canvas");
  45. var ctx = c.getContext("2d");
  46. ctx.beginPath();
  47. ctx.fillText(""+inn,Math.random()*ii+1,Math.random()*ii+1,Math.random()*ii,Math.random()*ii+1,ii+1);
  48. //ctx.rotate(18,Math.PI/180)
  49. text='';
  50. }
  51. </script>
  52. <canvas id="canvas"></canvas>
  53.  
  54. <script>
  55. var canvas = document.getElementById('canvas'),
  56. ctx = canvas.getContext('2d'),
  57. HEIGHT = window.innerHeight,
  58. WIDTH = window.innerWidth,
  59. TO_RADIANS = Math.PI / 368;
  60.  
  61. var raf = (function(){
  62. return window.requestAnimationFrame ||
  63. window.webkitRequestAnimationFrame ||
  64. window.mozRequestAnimationFrame ||
  65. window.oRequestAnimationFrame ||
  66. window.msRequestAnimationFrame ||
  67. function( callback ){
  68. window.setTimeout(callback, 10000);
  69. };
  70. })();
  71.  
  72. function clear(style) {
  73. ctx.save();
  74. ctx.fillStyle = style || 'rgba(0,0,0,0.01)';
  75. ctx.fillRect(0, 0, WIDTH, HEIGHT);
  76. ctx.restore();
  77. }
  78.  
  79. function square(x, y, w, h) {
  80. ctx.beginPath();
  81. ctx.rect(WIDTH/2 + x, HEIGHT/2 + y, w, h);
  82. ctx.closePath();
  83. ctx.fill();
  84. }
  85. //function render(){
  86. //ctx.drawRect(WIDTH/2+x,HEIGHT/2+y,w,0,Math.PI*2,true);
  87. //}
  88. function circle(x, y, w, h) {
  89. ctx.beginPath();
  90. ctx.arc(WIDTH/2 + x, HEIGHT/2+ y, w, 0, Math.PI*2, true);
  91. ctx.closePath();
  92. ctx.fill();
  93. }
  94.  
  95. canvas.width = WIDTH;
  96. canvas.height = HEIGHT;
  97.  
  98. var offsetX = 0,
  99. offsetY = 0;
  100.  
  101. function draw() {
  102. clear();
  103.  
  104. offsetX+= 2;
  105. offsetY+=2;
  106. var x = Math.sin(WIDTH + offsetX * TO_RADIANS) * WIDTH/4;
  107. var y = Math.sin(HEIGHT + offsetY * TO_RADIANS) * HEIGHT/4;
  108.  
  109. ctx.fillStyle = 'white';
  110. circle(x, y, 42, 10);
  111. offsetX += 25;
  112.  
  113. raf(draw, 285);
  114. }
  115.  
  116. clear('black');
  117. draw();
  118. </script>
  119.  
  120. </script>
Advertisement
Add Comment
Please, Sign In to add comment