summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--complexfunctions.html1
-rw-r--r--js/complexfunctions.js8
2 files changed, 8 insertions, 1 deletions
diff --git a/complexfunctions.html b/complexfunctions.html
index 5917c00..a5e7a3b 100644
--- a/complexfunctions.html
+++ b/complexfunctions.html
@@ -54,6 +54,7 @@ Graph complex functions (C->C)
<br>
<button id="animate" class="btn btn-default">Animate</button>
<div id="canvas"></div>
+ <div id="legend"></div>
</div>
<div class="container-fluid">
diff --git a/js/complexfunctions.js b/js/complexfunctions.js
index f71c23b..9703b5d 100644
--- a/js/complexfunctions.js
+++ b/js/complexfunctions.js
@@ -79,7 +79,7 @@ function draw()
function makeCanvas(w, h)
{
- $("#canvas").html();
+ $("#canvas").html("");
var canvas = createCanvas(w, h);
canvas.parent("canvas");
domainPoints = [];
@@ -104,8 +104,14 @@ $(function()
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]);
+ $("#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>");
+ }
drawFuncs(funcs);
});
$(".form-control").keydown(function(e)