-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrid.html
More file actions
14 lines (14 loc) · 712 Bytes
/
grid.html
File metadata and controls
14 lines (14 loc) · 712 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<html><head><script>
var ok=()=>{
var g=document.getElementById("grid");var c=g.getContext("2d");
var w=512;var h=512;var a={'width':'w','height':'h'};var dbc={'width':'clientWidth','height':'clientHeight'};
for(var k in a){var dbv=document.body[dbc[k]];var v=dbv-32+0*window.screen[k];g[k]=v;eval(a[k]+'=v;');}
document.title=JSON.stringify({w,h});
var fix=(x,dx)=>((x/dx)|0)*dx;
var dv=64;var dx=dv;var dy=dv;var tw=fix(w,dx);var th=fix(h,dy);
for(var x=0.5;x<w;x+=dx){c.moveTo(x,0);c.lineTo(x,th);}
for(var y=0.5;y<h;y+=dy){c.moveTo(0,y);c.lineTo(tw,y);}
c.lineWidth="2";c.strokeStyle="bold;#000";c.stroke();
};
</script></head>
<body onload="ok();"><center><canvas id="grid"></canvas></center></body></html>