Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>bB rand16 scatterplot</title>
- </head>
- <body style="background-color:#dfdfff;">
- <br>
- <input id="num" type="number" width="1" min="1" max="64" value="1" onchange="docanvas()"></input>
- The number is thousands of points<br>
- <br>
- first plot is in blue using javascript's random function. That's overlayed with bB rand16 in red<br>
- and finally bB rand in green. I start seeing lines around 30 thousand points
- <br>
- <br>
- <canvas id="canv" width="512" height="256" style="border:1px solid #d3d3d3;">
- Your browser does not support the HTML5 canvas tag.</canvas>
- <script>
- var ctx=canv.getContext("2d");
- var s8 = 7, s16 = 7, x1, x2, y1, y2;
- function rev(p){return (p>1?rev(p/2)/2+(p&1?128:0):0)&255;}
- function r8(){s8 = (s8/2^((s8&1)?180:0))&255; return s8;}
- function r16(){s16 = (s16/2^((s16&1)?46080:0))&65535; return (s16/256^rev(s16&255))&255;}
- function docanvas(){
- ctx.fillStyle = "rgb(0,0,0)"
- ctx.fillRect(1,1,510,254);
- x1 = (Math.random()*256)&255;
- r = 1024 * Number(num.value);
- for(i=0; i<r; i++){
- y1 = x1; x1 = (Math.random()*256)&255;
- ctx.fillStyle = "rgb(50,50,255)"
- ctx.fillRect(x1*2,y1,2,2);
- }
- x1 = r16();
- r = 1024 * Number(num.value);
- for(i=0; i<r; i++){
- y1 = x1; x1 = r16();
- ctx.fillStyle = "rgb(255,0,0)"
- ctx.fillRect(x1*2,y1,2,2);
- }
- x1 = r8()
- for(i=0; i<256; i++){
- y1 = x1; x1 = r8();
- ctx.fillStyle = "rgb(0,255,0)"
- ctx.fillRect(x1*2,y1,2,2);
- }
- }
- docanvas();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement