From bb8372c1c229f5ade3e6a8aa2c769ca75b792274 Mon Sep 17 00:00:00 2001 From: Elijah Cohen Date: Sun, 10 Jul 2022 01:51:54 -0500 Subject: [PATCH] new drawing which is great --- cell.js | 20 ++++++++++++++++++++ rps.html | 1 - wireworld.js | 21 +++++++++++++++++++-- 3 files changed, 39 insertions(+), 3 deletions(-) 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 @@ -