about summary refs log tree commit diff stats
path: root/html/rogue/js/renderer.js
diff options
context:
space:
mode:
authorelioat <{ID}+{username}@users.noreply.github.com>2024-12-27 10:54:27 -0500
committerelioat <{ID}+{username}@users.noreply.github.com>2024-12-27 10:54:27 -0500
commitd17d85553a72e40ac390238dab5c03dfa9f567ee (patch)
tree896e1be92e1fe21b17d6a30cd1c0dfb5375e6224 /html/rogue/js/renderer.js
parent93af36423b2a1415c89ab7adb92ee458d4ae5a46 (diff)
downloadtour-d17d85553a72e40ac390238dab5c03dfa9f567ee.tar.gz
*
Diffstat (limited to 'html/rogue/js/renderer.js')
-rw-r--r--html/rogue/js/renderer.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/html/rogue/js/renderer.js b/html/rogue/js/renderer.js
new file mode 100644
index 0000000..3e64666
--- /dev/null
+++ b/html/rogue/js/renderer.js
@@ -0,0 +1,29 @@
+const Renderer = {
+    drawHex(ctx, hex, x, y, size, fillStyle, strokeStyle) {
+        ctx.beginPath();
+        for (let i = 0; i < 6; i++) {
+            const angle = 2 * Math.PI / 6 * i;
+            const xPos = x + size * Math.cos(angle);
+            const yPos = y + size * Math.sin(angle);
+            if (i === 0) ctx.moveTo(xPos, yPos);
+            else ctx.lineTo(xPos, yPos);
+        }
+        ctx.closePath();
+        
+        if (fillStyle) {
+            ctx.fillStyle = fillStyle;
+            ctx.fill();
+        }
+        if (strokeStyle) {
+            ctx.strokeStyle = strokeStyle;
+            ctx.stroke();
+        }
+    },
+    
+    drawCircle(ctx, x, y, radius, fillStyle) {
+        ctx.fillStyle = fillStyle;
+        ctx.beginPath();
+        ctx.arc(x, y, radius, 0, Math.PI * 2);
+        ctx.fill();
+    }
+}; 
\ No newline at end of file