From 9956f6b1d0ca896c0b775353208855cb2d6adf10 Mon Sep 17 00:00:00 2001 From: pommicket Date: Sun, 16 Oct 2016 16:14:58 -0400 Subject: Added immediately display button & maximum brightness of function color to RPN --- complexfunctions.html | 9 +++++++++ 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)
+
+
+ + + + Immediately display result (no animation). +
+
+
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("
" + funcs[i] + "
"); @@ -119,4 +126,8 @@ $(function() if (e.keyCode == 13) $("#animate").click(); }); + $("#display").click(function() + { + $("#animate").html($("#display").prop("checked") ? "Display" : "Animate"); + }); }); -- cgit v1.2.3