Advertisement
BrU32

JS Webcam Osc Canvas SRC V5 Fun

Nov 16th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.91 KB | None | 0 0
  1. <script>
  2. var context = new AudioContext();
  3. var lfo = context.createOscillator();
  4. lfo.frequency.value = 12.0;
  5. var hfo = context.createOscillator();
  6. hfo.frequency.value = prompt('enter');
  7. var modulationGain = context.createGain();
  8. modulationGain.gain.value = 50;
  9. lfo.connect(modulationGain);
  10. modulationGain.connect(hfo.detune);
  11. hfo.connect(context.destination);
  12. hfo.start(0);
  13. lfo.start(0);
  14. </script>
  15. <center>
  16. <canvas id="canvas" width='1000' height='1000'></canvas>
  17.  
  18. <body bgcolor="white" onmousemove="drawe();" onmousedown="drawe" onchange="drawe" ondoubleclick="drawe;">
  19. <video id="video" autoplay hidden>
  20. </video><center>
  21. <canvas id="myCanvas" left="2240" width="2240" height="1220" style="border:22px solid grea;">
  22. Your browser does not support the HTML5 canvas tag.</canvas>
  23. <script>
  24. var c = document.getElementById("myCanvas");
  25. var ctx = c.getContext("2d");
  26. ctx.shadowBlur = 20;
  27. ctx.fillStyle = "red";
  28. ctx.shadowColor = "blue";
  29. ctx.shadowColor = "blue";
  30. ctx.fillRect(Math.random()*50, Math.random()*20, Math.random)*500, Math.random()*1000));
  31.  
  32. </script>
  33. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
  34. <script>
  35. $(document).mousemove(function(e){
  36. $('p').css("font-size", "10px");
  37. $('p').css("color", "red");
  38. $("canvas").slideToggle(Math.random()*3000);
  39. ctx.fillRect(event.x, event.y, Math.random()*100, 80);
  40. });
  41. </script>
  42. </head>
  43. <body>
  44. </html>
  45. <canvas id="canvas" width="10000" height="10000"style="opacity:1.0;fillColor:white;">
  46. <script>
  47. var ii=1;
  48.  
  49. var video = document.getElementById("video");
  50. var c = document.getElementById("canvas");
  51. var ctx = c.getContext("2d");
  52. var canvas = document.getElementById('canvas');
  53. var context = canvas.getContext('2d');
  54. var video = document.getElementById('video');
  55. var mediaConfig = { video: true,audio:false};
  56. function drawe(){
  57. }
  58. navigator.mediaDevices.getUserMedia(mediaConfig).then(function(stream) {
  59. video.src = this.window.URL.createObjectURL(stream);
  60. video.play();
  61. video.addEventListener("play", function() {i = window.setInterval(function() {
  62. canvas.style.opacity+=1.2;
  63. ctx.drawImage(video,1,1,522,522)},1);
  64. ctx.draw();
  65. drawe();
  66. }, false);
  67. });
  68. </script>
  69. </center>
  70. <center>
  71. <body bgcolor="black">
  72. <video id="video" width="640" height="480" autoplay></video>
  73. <canvas id="canvas" width="640" height="480"></canvas>
  74. <script>
  75. window.addEventListener("DOMContentLoaded", function() {
  76. var canvas = document.getElementById('canvas');
  77. var context = canvas.getContext('2d');
  78. var video = document.getElementById('video');
  79. var mediaConfig = { video: false,audio:true};
  80. var errBack = function(e) {
  81. console.log('An error has occurred!', e)
  82. };
  83. if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
  84. navigator.mediaDevices.getUserMedia(mediaConfig).then(function(stream) {
  85. video.src = window.URL.createObjectURL(stream);
  86. video.play();
  87. });
  88. }
  89. else if(navigator.getUserMedia) {
  90. navigator.getUserMedia(mediaConfig, function(stream) {
  91. video.src = stream;
  92. video.play();
  93. }, errBack);
  94. } else if(navigator.webkitGetUserMedia) {
  95. navigator.webkitGetUserMedia(mediaConfig, function(stream){
  96. video.src = window.webkitURL.createObjectURL(stream);
  97. video.play();
  98. }, errBack);
  99. } else if(navigator.mozGetUserMedia) {
  100. navigator.mozGetUserMedia(mediaConfig, function(stream){
  101. video.src = window.URL.createObjectURL(stream);
  102. video.play();
  103. }, errBack);
  104. }
  105. document.getElementById('snapshot').addEventListener('click', function() {
  106. context.Image(video, 440, 480);
  107. });
  108. }, false);
  109. </script>
  110. <html>
  111. <body onload="var intt=prompt('Enter Amount Of Circles Gen:');
  112. for(var i=0;i<intt;i++){
  113. Draw();
  114. }">
  115. <canvas id="myCanvas" width="1000" height="1000"
  116. style="border:0px solid #d3d3d3;">
  117. Your browser does not support the canvas element.
  118. </canvas>
  119. <script>
  120. function Draw(){
  121. var canvas = document.getElementById("myCanvas");
  122. var ctx=canvas.getContext("2d");
  123. ctx.border='1px';
  124. ctx.fillAlign = "center";
  125. ctx.beginPath();
  126. ctx.fillStyle='magenta';
  127. ctx.arc(Math.random()*1000,Math.random()*1000,40,0,2*Math.PI);
  128. ctx.fill();
  129. }
  130. </script>
  131. </body>
  132. </html>
  133. <script>
  134. var audioCtx=new AudioContext();
  135. var oscillator = audioCtx.createOscillator();
  136. var gainNode = audioCtx.createGain();
  137. oscillator.connect(gainNode);
  138. gainNode.connect(audioCtx.destination);
  139. var WIDTH = window.innerWidth;
  140. var HEIGHT = window.innerHeight;
  141. var FreqMax = prompt("Enter Max Freq");
  142. var VolMax = prompt("Enter Max Vol:");
  143. var Freq = prompt("Enter Starting Freq:");
  144. var Vol = prompt("Enter Starting Vol:");
  145. oscillator.type = 'sine-';
  146. oscillator.frequency.value = Freq;
  147. oscillator.start();
  148. gainNode.gain.value =Vol;
  149. var CurX;
  150. var CurY;
  151. var CurZ;
  152. var CurZZ;
  153. document.onmousemove = updatePage;
  154. function updatePage(e) {
  155. CurZ = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
  156. CurZZ = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
  157. CurX = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
  158. CurY = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
  159. oscillator.frequency.value = (CurX/WIDTH) * FreqMax;
  160. gainNode.gain.value = (CurY/HEIGHT) * VolMax;
  161. oscillator.frequency.value = (CurZ-WIDTH) % FreqMax;
  162. gainNode.gain.value = (CurZZ-HEIGHT) % VolMax;
  163. oscillator.detune=(0);
  164. }
  165. function drawe(){
  166. var canvas = document.getElementById("myCanvas");
  167. var ctx = canvas.getContext("2d");
  168. ctx.moveTo(event.x+CurX,event.y+CurX);
  169. ctx.lineTo(event.x+CurX,event.y+CurY);
  170. ctx.stroke();
  171. }
  172. </script>
  173. <html>
  174. <body onmousemove="drawe();" onchange="drawe();" background-color="white">
  175. <canvas id="myCanvas" width="1000" height="1000" style="background:darkorange;">
  176. </canvas>
  177. </body>
  178. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement