From: Elijah Cohen Date: Thu, 21 Apr 2022 04:22:37 +0000 (-0500) Subject: forgot this whoops X-Git-Url: https://git.eli173.com/?a=commitdiff_plain;h=a419e399db29d0cb61dc578d52f76d6856da3936;p=hexgrid forgot this whoops --- diff --git a/play.js b/play.js index 9e88790..79af1af 100644 --- 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) {