From 740073061af633e8422eeaaac5a69d293bf5f489 Mon Sep 17 00:00:00 2001 From: Sconnda Date: Tue, 1 Dec 2015 13:20:48 -0500 Subject: [PATCH 1/4] Created a circle, a square, and a lag --- VoidFunctions/VoidFunctions.pde | 43 +++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 8b13789..67c0720 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -1 +1,44 @@ +float x; +float y; +float diam; +int total = 50; +PVector [] lag = new PVector[total]; +void setup() { + size(500, 500); + for (int i = 0; i < total; i++) { + lag[i] = new PVector(-100, -100); + } +} + +void square(float c1, float c2, float c3, float alpha) { + fill(c1, c2, c3, alpha); + rect(width/2-25, height/2-25, 50, 50); +} + +void circle(float x, float y, float diam, float c1, float c2, float c3, float alpha) { + fill(c1, c2, c3, alpha); + ellipse(mouseX, mouseY, diam, diam); +} + +void ripples(float x, float y) { +} + +void draw() { + background(0); + x = mouseX; + y = mouseY; + diam = 30; + stroke(255); + square(255, 255, 255, 128); + noFill(); + for (int i = 0; i < total-1; i++) { + lag[i].set(lag[i+1]); + } + lag[total-1].set(x,y); + for (int i = 0; i < total; i++) { + stroke(255, 255*i/(total-1)); + ellipse(lag[i].x, lag[i].y, diam, diam); + } + circle(x, y, diam, 255, 0, 0, 128); +} \ No newline at end of file From 94c9bb54acad3d3aad833c634c1bbe2e9f120e7a Mon Sep 17 00:00:00 2001 From: Sconnda Date: Thu, 3 Dec 2015 12:05:32 -0500 Subject: [PATCH 2/4] Edited the effect of the lag --- VoidFunctions/VoidFunctions.pde | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 67c0720..b8a8cd0 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -1,11 +1,13 @@ +int weight = 2; float x; float y; -float diam; +float diam = 10; int total = 50; PVector [] lag = new PVector[total]; void setup() { size(500, 500); + strokeWeight(weight); for (int i = 0; i < total; i++) { lag[i] = new PVector(-100, -100); } @@ -28,17 +30,16 @@ void draw() { background(0); x = mouseX; y = mouseY; - diam = 30; stroke(255); square(255, 255, 255, 128); noFill(); for (int i = 0; i < total-1; i++) { lag[i].set(lag[i+1]); } - lag[total-1].set(x,y); + lag[total-1].set(x, y); for (int i = 0; i < total; i++) { stroke(255, 255*i/(total-1)); - ellipse(lag[i].x, lag[i].y, diam, diam); + ellipse(lag[i].x, lag[i].y, diam+weight*(total-1-i), diam+weight*(total-1-i)); } circle(x, y, diam, 255, 0, 0, 128); } \ No newline at end of file From 47472854c421b2522fc178ed95dd9b5c9fb0de56 Mon Sep 17 00:00:00 2001 From: Sconnda Date: Thu, 3 Dec 2015 12:13:36 -0500 Subject: [PATCH 3/4] Added comments --- VoidFunctions/VoidFunctions.pde | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index b8a8cd0..d2c187b 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -1,3 +1,4 @@ +//declare variables int weight = 2; float x; float y; @@ -6,40 +7,57 @@ int total = 50; PVector [] lag = new PVector[total]; void setup() { + //set size and strokeweight size(500, 500); strokeWeight(weight); + + //set lag values initially so that they are not visible for (int i = 0; i < total; i++) { - lag[i] = new PVector(-100, -100); + lag[i] = new PVector(-diam-weight*total, -diam-weight*total); } } +//define square function to include color void square(float c1, float c2, float c3, float alpha) { fill(c1, c2, c3, alpha); rect(width/2-25, height/2-25, 50, 50); } +//define circle function to include position, diameter, color void circle(float x, float y, float diam, float c1, float c2, float c3, float alpha) { fill(c1, c2, c3, alpha); ellipse(mouseX, mouseY, diam, diam); } -void ripples(float x, float y) { -} - void draw() { + //draw background background(0); + + //define x as mouseX in case mouse moves within frame x = mouseX; y = mouseY; + + //set stroke and draw square stroke(255); square(255, 255, 255, 128); + + //remove fill for ripples noFill(); + + //shift values for lag for (int i = 0; i < total-1; i++) { lag[i].set(lag[i+1]); } + + //set final lag to mouse position lag[total-1].set(x, y); + + //draw all ripples at location for (int i = 0; i < total; i++) { stroke(255, 255*i/(total-1)); ellipse(lag[i].x, lag[i].y, diam+weight*(total-1-i), diam+weight*(total-1-i)); } + + //draw circle circle(x, y, diam, 255, 0, 0, 128); } \ No newline at end of file From b658c919e8b32d7c0139a01dbe7bf20be8885ffe Mon Sep 17 00:00:00 2001 From: Sconnda Date: Thu, 3 Dec 2015 13:10:22 -0500 Subject: [PATCH 4/4] Created pythagorean square and added comments --- ReturningValues/ReturningValues.pde | 68 +++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 8b13789..a7bf171 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1 +1,69 @@ +//declare theta +float theta; +void setup() { + //set size + size(500, 500); +} + +//definies float c as the hypotenuse of a right triangle with sides a and b +float c(float a, float b) { + return sqrt(sq(a)+sq(b)); +} + +void draw() { + //draw background + background(0); + + //set modes, initial stroke, initial text size + rectMode(RADIUS); + noStroke(); + textSize(15); + + //define theta + theta = asin(mouseX/(c(mouseX,width-mouseX))); + + pushMatrix(); + translate(width/2,height/2); + rotate(theta); + fill(255); + rect(0,0,c(mouseX,width-mouseX)/2,c(mouseX,width-mouseX)/2); + fill(0); + pushMatrix(); + translate(0,20-c(mouseX,width-mouseX)/2); + rotate(-theta); + text("c", 0,0); + popMatrix(); + + pushMatrix(); + translate(20-c(mouseX,width-mouseX)/2,0); + rotate(-theta); + text("c", 0,0); + popMatrix(); + + pushMatrix(); + translate(0,c(mouseX,width-mouseX)/2-20); + rotate(-theta); + text("c", 0,0); + popMatrix(); + + pushMatrix(); + translate(c(mouseX,width-mouseX)/2-20,0); + rotate(-theta); + text("c", 0,0); + popMatrix(); + + pushMatrix(); + rotate(-theta); + textSize(30); + text("c²", 0,0); + popMatrix(); + popMatrix(); + + //set stroke and draw line to cursor to indicate what controls the values + stroke(255,0,0); + line(mouseX,0,mouseX,mouseY); + + //print values and proof + println("a = " + mouseX + ", b = " + (width-mouseX) + ", c = " + round(c(mouseX, width-mouseX)) + ". (a + b)² = a² + 2ab + b². c² = (a + b)² - 2ab."); +} \ No newline at end of file