From f24f6ba300c616663f78f264ee346d929ec548c0 Mon Sep 17 00:00:00 2001 From: elizabethebui Date: Tue, 1 Dec 2015 12:30:44 -0500 Subject: [PATCH 1/6] Draw a blue ball using a function --- VoidFunctions/VoidFunctions.pde | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 8b13789..4f83a9d 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -1 +1,15 @@ +void setup(){ +size(800,600); +} +void draw(){ +drawBlueCircle(); + +} + +void drawBlueCircle(){ +float diam = 50; +noStroke(); +fill(0,0,255); +ellipse(width/2,height/2,diam,diam); +} \ No newline at end of file From 5e7930acc64ae7085f94ba4a9667dc44fbeee6f1 Mon Sep 17 00:00:00 2001 From: elizabethebui Date: Tue, 1 Dec 2015 12:43:45 -0500 Subject: [PATCH 2/6] functions for drawing a blue square and ellipses --- VoidFunctions/VoidFunctions.pde | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 4f83a9d..aa76759 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -1,15 +1,24 @@ void setup(){ size(800,600); +background(0); } void draw(){ -drawBlueCircle(); + drawBlueSquare(); +drawMouseCircle(); } -void drawBlueCircle(){ -float diam = 50; +void drawBlueSquare(){ + float side = random(10,50); + noStroke(); + fill(0,0,random(100,200)); + rect(width/2,height/2,side,side); +} + +void drawMouseCircle(){ +float diam = random(10,30); noStroke(); -fill(0,0,255); -ellipse(width/2,height/2,diam,diam); -} \ No newline at end of file +fill(random(0,255), random(0,255), random(0,255),random(90,100)); +ellipse(mouseX,mouseY, diam, diam); +} \ No newline at end of file From c21543d8d3a7976c185d7aebc961e33604028fab Mon Sep 17 00:00:00 2001 From: elizabethebui Date: Tue, 1 Dec 2015 12:51:21 -0500 Subject: [PATCH 3/6] draw some more functions --- VoidFunctions/VoidFunctions.pde | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index aa76759..9ae0e0e 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -19,6 +19,19 @@ void drawBlueSquare(){ void drawMouseCircle(){ float diam = random(10,30); noStroke(); -fill(random(0,255), random(0,255), random(0,255),random(90,100)); +setFill(); ellipse(mouseX,mouseY, diam, diam); +} + +void setFill(){ + float r; + float g; + float b; + float transparency; + r = random(0,255); + g = random(0,255); + b = random(0,255); + transparency = random(50,150); + fill(r, g, b,transparency); + } \ No newline at end of file From 49f7d5278b7b70d7a9e95a6c13d4b5db38836885 Mon Sep 17 00:00:00 2001 From: elizabethebui Date: Tue, 1 Dec 2015 13:02:45 -0500 Subject: [PATCH 4/6] Draw a random rectangle --- VoidFunctions/VoidFunctions.pde | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 9ae0e0e..3f3cf87 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -4,8 +4,8 @@ background(0); } void draw(){ - - drawBlueSquare(); +drawRandomRect(); +drawBlueSquare(); drawMouseCircle(); } @@ -33,5 +33,13 @@ void setFill(){ b = random(0,255); transparency = random(50,150); fill(r, g, b,transparency); - +} + +void drawRandomRect(){ + if(mousePressed){ + float leng = random(10,40); + float wid = random(10,40); + noStroke(); + rect(random(width), random(height), leng, wid); + } } \ No newline at end of file From 5b95061c0d35745fcb7b0edee66533f9d648d8a3 Mon Sep 17 00:00:00 2001 From: elizabethebui Date: Thu, 3 Dec 2015 12:41:41 -0500 Subject: [PATCH 5/6] Create the pythagorean theorem --- ReturningValues/ReturningValues.pde | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 8b13789..2969b9d 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1 +1,14 @@ +void setup(){ +size(800,600); +} +void draw(){ +float c = pythagorean(5, 4); + +println(c); +} + +float pythagorean(float a, float b){ + float c = sqrt(pow(a,2)+pow(b,2)); +return c; +} \ No newline at end of file From 9f9833942bfda1672aabf784d7e0a1c4cb8035cc Mon Sep 17 00:00:00 2001 From: elizabethebui Date: Thu, 3 Dec 2015 12:54:43 -0500 Subject: [PATCH 6/6] Add three values --- ReturningValues/ReturningValues.pde | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 2969b9d..4e5c5bf 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -4,11 +4,16 @@ size(800,600); void draw(){ float c = pythagorean(5, 4); - -println(c); +float z = added(3,2,4); +println(z); //print whichever specified } float pythagorean(float a, float b){ float c = sqrt(pow(a,2)+pow(b,2)); return c; +} + +float added(float w, float x, float y){ +float z = w + x + y; +return z; } \ No newline at end of file