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 /js | |
parent | db20c66b3634e43049e1339ce8a0d51ee5944780 (diff) |
Added immediately display button & maximum brightness of function color to RPN
Diffstat (limited to 'js')
-rw-r--r-- | js/complexfunctions.js | 15 |
1 files changed, 13 insertions, 2 deletions
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"); + }); }); |