diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-09-11 16:08:43 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-09-11 16:08:43 -0400 |
| commit | b9c2a6fa85e4585ff631123d74b0fa49296b8563 (patch) | |
| tree | bfb8551d88957f98cc630882083dbaf7af9ef7ea | |
| parent | 110e137f1f6a56f93e4edb57bfbdffc1384f78dc (diff) | |
workin better
| -rw-r--r-- | env.js | 27 | ||||
| -rw-r--r-- | index.html | 4 |
2 files changed, 22 insertions, 9 deletions
@@ -117,7 +117,8 @@ var environment = (function(){ snap.node.addEventListener("touchstart", getFirstTouch( dot_grid.mousedown.bind(dot_grid) )) document.addEventListener("touchmove", getFirstTouch( environment.mousemove)) document.addEventListener("touchend", dot_grid.mouseup.bind(dot_grid) ) - $("#draw").on("change", environment.check_drawing) + $("#draw").on("touchstart", environment.check_drawing) + $("#reset").on("touchstart", environment.reset) } else { $(snap.node).on("mousedown", dot_grid.mousedown.bind(dot_grid)) @@ -134,7 +135,11 @@ var environment = (function(){ use_scale = $("#use_scale").get(0).checked } environment.check_drawing = function(){ - drawing = $("#draw").get(0).checked + drawing = ! drawing + $("#draw").html( drawing ? "drawing" : "playing" ) + } + environment.reset = function(){ + environment.reset_wires() } environment.duration = function(){ duration = parseInt( $("#duration").val() ) || 1000 @@ -192,7 +197,7 @@ var environment = (function(){ environment.stride = function(e){ var dx = parseFloat( $("#x").val() ) var dy = parseFloat( $("#y").val() ) - environment.reset() + environment.reset_strided_wires() if (! dx && ! dy) return if (dx < 1.1 && ! dy) return var x0 = 0, x1 = dx, y0 = 0, y1 = dy @@ -212,15 +217,21 @@ var environment = (function(){ } while ( y0 < dot_grid.dots.length) } - environment.reset = function(){ + environment.reset_strided_wires = function(){ strided_wires.forEach(function(wire){ wire.remove() }) strided_wires = [] } + environment.reset_wires = function(){ + wires.forEach(function(wire){ + wire.remove(true) + }) + wires.length = 0 + } environment.randomize = function(){ var n = parseInt( $("#rand").val() ) - environment.reset() + environment.reset_strided_wires() var x0, y0, x1, y1 while (n--) { x0 = randint( dot_grid.dots.length ) @@ -471,9 +482,11 @@ var environment = (function(){ polysynth.triggerAttackRelease(f, d || randrange(1.0, 2.5)) } var last_f = 0 - Wire.prototype.remove = function(){ + Wire.prototype.remove = function(dont_splice){ this.path.remove() - wires.splice(wires.indexOf(this), 1) + if (! dont_splice) { + wires.splice(wires.indexOf(this), 1) + } } environment.update = function(t){ @@ -67,8 +67,8 @@ input[type=text] { width: 30px } <label for="use_scale">use scale</label> <input id="use_scale" type="checkbox" checked> <div id="mobile_controls"> - <label for="draw">draw</label> - <input id="draw" type="checkbox" checked> + <button id="draw">drawing</button> + <button id="reset">reset</button> </div> </div> |
