Advertisement
Guest User

Untitled

a guest
May 25th, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>bB rand16 scatterplot</title>
  5. </head>
  6. <body style="background-color:#dfdfff;">
  7.  
  8. <br>
  9. <input id="num" type="number" width="1" min="1" max="64" value="1" onchange="docanvas()"></input>
  10. The number is thousands of points<br>
  11. <br>
  12. first plot is in blue using javascript's random function. That's overlayed with bB rand16 in red<br>
  13. and finally bB rand in green. I start seeing lines around 30 thousand points
  14. <br>
  15. <br>
  16.  
  17. <canvas id="canv" width="512" height="256" style="border:1px solid #d3d3d3;">
  18. Your browser does not support the HTML5 canvas tag.</canvas>
  19. <script>
  20.  
  21. var ctx=canv.getContext("2d");
  22.  
  23. var s8 = 7, s16 = 7, x1, x2, y1, y2;
  24.  
  25. function rev(p){return (p>1?rev(p/2)/2+(p&1?128:0):0)&255;}
  26. function r8(){s8 = (s8/2^((s8&1)?180:0))&255; return s8;}
  27. function r16(){s16 = (s16/2^((s16&1)?46080:0))&65535; return (s16/256^rev(s16&255))&255;}
  28.  
  29. function docanvas(){
  30. ctx.fillStyle = "rgb(0,0,0)"
  31. ctx.fillRect(1,1,510,254);
  32.  
  33. x1 = (Math.random()*256)&255;
  34. r = 1024 * Number(num.value);
  35. for(i=0; i<r; i++){
  36. y1 = x1; x1 = (Math.random()*256)&255;
  37.  
  38. ctx.fillStyle = "rgb(50,50,255)"
  39. ctx.fillRect(x1*2,y1,2,2);
  40. }
  41.  
  42. x1 = r16();
  43. r = 1024 * Number(num.value);
  44. for(i=0; i<r; i++){
  45. y1 = x1; x1 = r16();
  46.  
  47. ctx.fillStyle = "rgb(255,0,0)"
  48. ctx.fillRect(x1*2,y1,2,2);
  49. }
  50.  
  51. x1 = r8()
  52. for(i=0; i<256; i++){
  53. y1 = x1; x1 = r8();
  54.  
  55. ctx.fillStyle = "rgb(0,255,0)"
  56. ctx.fillRect(x1*2,y1,2,2);
  57. }
  58. }
  59.  
  60. docanvas();
  61. </script>
  62.  
  63. </body>
  64. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement