Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- </head>
- <body>
- <input type="range" min="0" max="1000" id="T" onmousemove="Draw()" style="width:100%;"/>
- <canvas id="cvs" width="900" height="900" style="background-color:#000;"></canvas>
- <script>
- function gcd(a,b)
- {
- while(b!=0)
- {
- var c = a%b;
- a=b;
- b=c;
- }
- return a;
- }
- var offsetx,offsety;
- offsetx = offsety = 450;
- var map = new Array();
- for(var x=0; x<900; x++)
- {
- var row = new Array();
- for(var y=0; y<900; y++)
- {
- row.push(gcd(x-offsetx,y-offsety));
- }
- map.push(row);
- }
- var g = cvs.getContext("2d");
- function Draw()
- {
- g.clearRect(0,0,cvs.width,cvs.height);
- var threshold = Math.exp(T.value/100);
- for(var x=0; x<900; x++)
- {
- for(var y=0; y<900; y++)
- {
- if(map[x][y]>threshold)
- {
- g.fillStyle="hsl("+map[x][y]+",100%,50%)";
- g.fillRect(x,y,1,1);
- }
- }
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement