Advertisement
BrU32

JS Canvas With Custom Synth Demo SRC FINAL!!!!!

Oct 29th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. <script>
  2. var audioCtx=new AudioContext();
  3. var oscillator = audioCtx.createOscillator();
  4. var gainNode = audioCtx.createGain();
  5. oscillator.connect(gainNode);
  6. gainNode.connect(audioCtx.destination);
  7. var WIDTH = window.innerWidth;
  8. var HEIGHT = window.innerHeight;
  9. var FreqMax = prompt("Enter Mox Freq");;
  10. var VolMax = prompt("Enter Max Vol:");
  11. var Freq = prompt("Enter Starting Freq:");
  12. var Vol = prompt("Enter Starting Vol:");
  13. oscillator.type = 'sawtooth';
  14. oscillator.frequency.value = Freq;
  15. oscillator.start();
  16. gainNode.gain.value =Vol;
  17. var CurX;
  18. var CurY;
  19. document.onmousemove = updatePage;
  20. function updatePage(e) {
  21. CurX = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
  22. CurY = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
  23. oscillator.frequency.value = (CurX/WIDTH) * FreqMax;
  24. gainNode.gain.value = (CurY/HEIGHT) * VolMax;
  25. osillator.detune=(0);
  26. canvasDraw();
  27. }
  28. </script>
  29. <html>
  30. <body onmousemove="drawe();" onchange="drawe();" background-color="white">
  31. <canvas id="myCanvas" width="1000" height="1000" style="background:darkorange;">
  32. </canvas>
  33. <script>
  34. function drawe(){
  35. var canvas = document.getElementById("myCanvas");
  36. var ctx = canvas.getContext("2d");
  37. ctx.moveTo(event.x+CurX,event.y+CurX);
  38. ctx.lineTo(event.x+CurX,event.y+CurY);
  39. ctx.stroke();
  40. ctx.clear();
  41. }
  42. </script>
  43. </body>
  44. </html>
  45. <video id='video'/>
  46. <canvas id="canvas" width="500" height="500" style="border:0px solid"/>
  47.  
  48. <script>
  49. function Draw(){
  50. var canvas = document.getElementById("canvas");
  51. var ctx=canvas.getContext("2d");
  52. ctx.border='1px';
  53. ctx.fillAlign = "center";
  54. ctx.beginPath();
  55. ctx.fillStyle='magenta';
  56. ctx.arc(Math.random()*1000,Math.random()*1000,40,0,2*Math.PI);
  57. ctx.fill();
  58. }
  59. var inncol=prompt('Enter Color:')
  60. document.writeln('<body bgcolor='+inncol+'>');
  61. var video = document.getElementById("video");
  62. var c = document.getElementById("canvas");
  63. var ctx = c.getContext("2d");
  64. var i=0;
  65. var canvas = document.getElementById('canvas');
  66. var context = canvas.getContext('2d');
  67. var video = document.getElementById('video');
  68. var mediaConfig = {video:true,audio:true};
  69. navigator.mediaDevices.getUserMedia(mediaConfig).then(function(stream) {
  70. video.src = this.window.URL.createObjectURL(stream);
  71. video.play();
  72. video.addEventListener("play", function() {i = window.setInterval(function() {
  73. ctx.drawImage(video,0,0,500,500)},1);
  74.  
  75. }, false);
  76. });
  77. </script>
  78. var intt=prompt('Enter Amount Of Circles Gen:');
  79. for(var i=0;i<intt;i++){
  80.  
  81. ctx.border='1px';
  82. ctx.fillAlign = "center";
  83. ctx.beginPath();
  84. ctx.fillStyle='magenta';
  85. ctx.arc(Math.random()*1000,Math.random()*1000,40,0,2*Math.PI);
  86. ctx.draw();
  87. }
  88. </script>
  89.  
  90.  
  91.  
  92. </body>
  93. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement