From a982632b1cc3218d74acec2b5f6a69ffc5e97ead Mon Sep 17 00:00:00 2001 From: pommicket Date: Wed, 31 Aug 2016 14:58:23 -0400 Subject: Cleaned up code and improved website layout. --- js/modularcircles.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'js/modularcircles.js') diff --git a/js/modularcircles.js b/js/modularcircles.js index 8b588f9..8e346e0 100644 --- a/js/modularcircles.js +++ b/js/modularcircles.js @@ -5,45 +5,45 @@ function setup() function nPoints() { - return document.getElementById("npoints").value; + return parseInt($("#npoints").val()); } function shouldMul() { - return document.getElementById("should_mul").checked; + return $("#should_mul").prop("checked"); } function amount() { - return parseFloat(document.getElementById("amount").value); + return parseFloat($("#amount").val()); } function getPos(number) { - angle = 2*PI * number/(nPoints()); + angle = 2*PI * number/(nPoints()); return [cos(angle)*250+300, sin(angle)*250+300]; } function draw() { if (shouldMul()) - document.getElementById("amount").step = 0.1; + $("#amount").prop("step", 0.1); else - document.getElementById("amount").step = 1; + $("#amount").prop("step", 1); background(255); ellipseMode(CENTER); noStroke(); fill(0); for (var i = 0; i < nPoints(); i++) ellipse(getPos(i)[0], getPos(i)[1], 3, 3); - + stroke(0); for (var i = 0; i < nPoints(); i++) { if (shouldMul()) { stroke(map(map((amount()*i)%nPoints(), 0, nPoints(), 0, 256) - map(i, 0, nPoints(), 0, 256), -256, 256, 0, 256), map(i, 0, nPoints(), 0, 256), map((amount()*i)%nPoints(), 0, nPoints(), 0, 256)); - line(getPos(i)[0], getPos(i)[1], getPos((amount()*i)%nPoints())[0], getPos((amount()*i)%nPoints())[1]); + line(getPos(i)[0], getPos(i)[1], getPos((amount()*i)%nPoints())[0], getPos((amount()*i)%nPoints())[1]); } else { @@ -51,4 +51,4 @@ function draw() line(getPos(i)[0], getPos(i)[1], getPos((amount()+i)%nPoints())[0], getPos((amount()+i)%nPoints())[1]); } } -} \ No newline at end of file +} -- cgit v1.2.3