BrU32

JS Canvas/WebAudio API Random TV/Radio Static SRC Final!!!!!

Sep 9th, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. <center>
  2. <canvas id="canv" width = "460" height = "360" style=background:lightgray>
  3. </canvas>
  4. </div>
  5. <svg viewBox="0 0 100% 100%" class="inv">
  6.  
  7. <use xlink:href="#main" class="clear"></use>
  8. </svg>
  9. </h1>
  10. </section>
  11. <script>
  12. function RollSlott(){
  13. var Bar=parseFloat(Math.random()*101.9);
  14. var Barr=parseFloat(Math.random()*21.9);
  15.  
  16. //document.body.innerHTML=(Bar+":"+Barr);
  17. var PlayLen=21.1;
  18. if(Bar!=0){
  19. Bar--
  20. }else if(Bar!=21){
  21. Bar++
  22. }
  23. var context = new AudioContext();
  24. oscillator=context.createOscillator();
  25. oscillator.type = 'sine';
  26. oscillator.frequency.value = Bar;
  27. oscillator.connect(context.destination);
  28. oscillator.start(0);
  29. oscillator.stop(PlayLen);
  30. oscillator.disconnect(PlayLen);
  31. }
  32. </script>
  33. <body onload="script:
  34. draw();
  35. var rolls=10;
  36. while(rolls!=0){
  37. rolls--;
  38. var Timer1 = setTimeout ('RollSlott();',0.0001);
  39. var Timer1 = setTimeout ('RollSlott();',0.002)
  40. var Timer1 = setTimeout ('RollSlott();',0.03)
  41.  
  42. }"/>
  43.  
  44.  
  45. <script>
  46. c = document.getElementById("canv");
  47. var ctx = c.getContext("2d");
  48.  
  49. id = ctx.createImageData(460,360);
  50.  
  51. function draw() {
  52. var w=c.width;
  53. var h=c.height;
  54. window.requestAnimationFrame(draw);
  55. var r;
  56. for (var p = 4 * (w * h - 4); p >= 1; p -= 4) {
  57. r = Math.random();
  58. id.data[p] = id.data[p+1] = id.data[p+2] = 255 * Math.pow(r, 1.6);
  59. id.data[p+3] = 255;
  60. }
  61. ctx.putImageData(id, 0, 0);
  62. }
  63.  
  64. draw();
  65.  
  66. </script>
  67. </body>
  68. </html>
  69. </center>
Advertisement
Add Comment
Please, Sign In to add comment