BrU32

JS Canvas/Web Audio API Random Radio/TV Static SRC V3

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