]> git.eli173.com Git - hexgrid/commitdiff
forgot this whoops
authorElijah Cohen <eli@eli173.com>
Thu, 21 Apr 2022 04:22:37 +0000 (23:22 -0500)
committerElijah Cohen <eli@eli173.com>
Thu, 21 Apr 2022 04:22:37 +0000 (23:22 -0500)
play.js

diff --git a/play.js b/play.js
index 9e8879024f91682f3cdc1a9e0ba4c2b2c9745ab4..79af1af2a4c522204ca7e927a1501a03d678105a 100644 (file)
--- a/play.js
+++ b/play.js
@@ -10,6 +10,7 @@ ycenter = 200
 scale = 10
 
 
+var demos = {};
 
 var ctx = null;
 var c = null;
@@ -65,6 +66,26 @@ function lc() {
                fl.onclick = flipButtonHandler;
                rf = document.getElementById("rfl");
                rf.onclick = reflectButtonHandler;
+               load_demos(document.getElementById('seldemo'));
+               dl = document.getElementById("dload");
+               dl.onclick = demoHandler;
+
+}
+
+demoHandler = function(e) {
+               let which = document.getElementById('seldemo').value;
+               g.loadState(demos[which]);
+               drawGrid(g, ctx, xcenter,ycenter,scale);
+}
+
+
+load_demos = function(selelt) {
+               for(let k in demos) {
+                               let opt = document.createElement('option');
+                               opt.value = k;
+                               opt.innerText = k;
+                               selelt.appendChild(opt);
+               }
 }
 
 radius_hover = function(e) {