diff options
author | pommicket <leonardomtenenbaum@gmail.com> | 2016-10-16 16:14:58 -0400 |
---|---|---|
committer | pommicket <leonardomtenenbaum@gmail.com> | 2016-10-16 16:14:58 -0400 |
commit | 9956f6b1d0ca896c0b775353208855cb2d6adf10 (patch) | |
tree | 16f73be92c165d47ea20c8b1db6dedc54cb7a151 | |
parent | db20c66b3634e43049e1339ce8a0d51ee5944780 (diff) |
Added immediately display button & maximum brightness of function color to RPN
-rw-r--r-- | complexfunctions.html | 9 | ||||
-rw-r--r-- | js/complexfunctions.js | 15 |
2 files changed, 22 insertions, 2 deletions
diff --git a/complexfunctions.html b/complexfunctions.html index a5e7a3b..dc52a23 100644 --- a/complexfunctions.html +++ b/complexfunctions.html @@ -52,6 +52,15 @@ Graph complex functions (C->C) </div> </div> <br> + <div class="container-fluid row"> + <div class="input-group input-group-md col-lg-3 col-md-6 col-sm-8 col-xs-10"> + <span class="input-group-addon"> + <input id="display" class="checkbox" type="checkbox"> + </span> + <span class="form-control">Immediately display result (no animation).</span> + </div> + </div> + <br> <button id="animate" class="btn btn-default">Animate</button> <div id="canvas"></div> <div id="legend"></div> diff --git a/js/complexfunctions.js b/js/complexfunctions.js index 9703b5d..688eea0 100644 --- a/js/complexfunctions.js +++ b/js/complexfunctions.js @@ -94,20 +94,27 @@ function makeCanvas(w, h) drawPoints(domainPoints); } +function randColor() +{ + var r = Math.random() * 255; + var g = Math.random() * 255; + var b = Math.random() * 255; + return (r + g + b) / 3 > 150 ? randColor() : [r, g, b]; +} $(function() { $("#animate").click(function() { makeCanvas(parseInt($("#width").val()), parseInt($("#height").val())); - t = 0; + t = $("#display").prop("checked") ? 1 : 0; animating = false; var funcs = $("#function").val().split(","); colors = []; $("#legend").html(""); for (var i = 0; i < funcs.length; i++) { - colors.push([Math.random() * 255, Math.random() * 255, Math.random() * 255]); + colors.push(randColor()); $("#legend").append("<div><span style='display: inline-block; background: rgb(" + Math.floor(colors[i][0]) + ", " + Math.floor(colors[i][1]) + ", " + Math.floor(colors[i][2]) + "); width: 10px; height: 10px;'></span> " + funcs[i] + "</div>"); @@ -119,4 +126,8 @@ $(function() if (e.keyCode == 13) $("#animate").click(); }); + $("#display").click(function() + { + $("#animate").html($("#display").prop("checked") ? "Display" : "Animate"); + }); }); |