summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--complexfunctions.html9
-rw-r--r--js/complexfunctions.js15
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");
+ });
});