From: Elijah Cohen Date: Sun, 10 Jul 2022 06:51:54 +0000 (-0500) Subject: new drawing which is great X-Git-Url: https://git.eli173.com/?a=commitdiff_plain;h=bb8372c1c229f5ade3e6a8aa2c769ca75b792274;p=hexgrid new drawing which is great --- diff --git a/cell.js b/cell.js index 22431e2..261b4b9 100644 --- a/cell.js +++ b/cell.js @@ -117,3 +117,23 @@ function getClickCoords(c, scale, xoff, yoff, event) { return {r: r, q: q}; } */ + + + +DRAWHEX_RAD_SCALE = 1.18; + +function drawHexagon(ctx,x,y,sz,color) { + ctx.save(); + ctx.strokeStyle=color; + ctx.fillStyle=color; + ctx.beginPath(); + let r = sz * Math.sqrt(3)/2 * DRAWHEX_RAD_SCALE; + for(let i=0; i<=6;i++) { + let ang = Math.PI/6 + i*Math.PI/3; + let ix = x + r * Math.cos(ang); + let iy = y + r * Math.sin(ang); + ctx.lineTo(ix,iy); + } + ctx.fill(); + ctx.restore(); +} diff --git a/rps.html b/rps.html index d558937..3fe7a40 100644 --- a/rps.html +++ b/rps.html @@ -6,7 +6,6 @@ -