From 38e364a999f7a5641883cd6d811132dd095bb41e Mon Sep 17 00:00:00 2001 From: lallocco Date: Tue, 1 Dec 2015 12:28:54 -0500 Subject: [PATCH 1/5] Created blue square --- VoidFunctions/VoidFunctions.pde | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 8b13789..0701d28 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -1 +1,18 @@ +void setup(){ + size(600, 600); + background(0); + rectMode(CENTER); +} +void BlueSquare(){ + float sz = 50; + fill(0, 0, 255); + rect(width/2, height/2, sz, sz); +} + + + + +void draw(){ + BlueSquare(); +} \ No newline at end of file From 7c8ef62656de690a570aa651673071acdeb74d75 Mon Sep 17 00:00:00 2001 From: lallocco Date: Tue, 1 Dec 2015 12:49:28 -0500 Subject: [PATCH 2/5] Added functions to draw circle and triangle --- VoidFunctions/VoidFunctions.pde | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 0701d28..84bc33a 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -4,15 +4,27 @@ void setup(){ rectMode(CENTER); } -void BlueSquare(){ +void drawBlueSquare(){ float sz = 50; fill(0, 0, 255); rect(width/2, height/2, sz, sz); } - - - +void drawMouseEllipse(){ + float sz = 30; + ellipse(mouseX, mouseY, sz, sz); +} + +void drawRedTriangle(){ + fill(255, 0, 0); + triangle(30, 75, 58, 20, 86, 75); +} + void draw(){ - BlueSquare(); + drawBlueSquare(); + drawMouseEllipse(); + if (mousePressed == true){ + drawRedTriangle(); + } + } \ No newline at end of file From bcd4d6b40d06b4930db511292f42bd720ee33574 Mon Sep 17 00:00:00 2001 From: lallocco Date: Thu, 3 Dec 2015 12:21:31 -0500 Subject: [PATCH 3/5] Created Pythagorean Theorem function --- ReturningValues/ReturningValues.pde | 13 +++++++++++++ VoidFunctions/VoidFunctions.pde | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 8b13789..2246708 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1 +1,14 @@ +void setup(){ + size(800,600); +} +void draw(){ + float c = pythagorean(6, 50); + rect(width/2, height/2, c, c); + println(c); +} + +float pythagorean(float a, float b){ + float c = sqrt((a*a)+(b*b)); + return c; +} \ No newline at end of file diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 84bc33a..6db893b 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -10,8 +10,9 @@ void drawBlueSquare(){ rect(width/2, height/2, sz, sz); } -void drawMouseEllipse(){ +void drawMouseEllipse(color userColor){ float sz = 30; + fill(userColor); ellipse(mouseX, mouseY, sz, sz); } @@ -22,9 +23,8 @@ void drawRedTriangle(){ void draw(){ drawBlueSquare(); - drawMouseEllipse(); + drawMouseEllipse(color(30, 150, 90)); if (mousePressed == true){ drawRedTriangle(); } - } \ No newline at end of file From cf6f2671a931b32de4ed3d444ebd03b17afc3cbb Mon Sep 17 00:00:00 2001 From: lallocco Date: Thu, 3 Dec 2015 12:54:57 -0500 Subject: [PATCH 4/5] Created add three numbers function --- ReturningValues/ReturningValues.pde | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 2246708..b52295f 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -4,11 +4,19 @@ void setup(){ void draw(){ float c = pythagorean(6, 50); + float d = addThreeNumbers(4, 4, 4); rect(width/2, height/2, c, c); + rect(width/3, height/2, d, d); println(c); + println(d); } float pythagorean(float a, float b){ float c = sqrt((a*a)+(b*b)); return c; +} + +float addThreeNumbers(float a, float b, float c){ + float d = (a+b+c); + return d; } \ No newline at end of file From 4cf33f2474e25a877eb8626ee6144dce33cf8e80 Mon Sep 17 00:00:00 2001 From: lallocco Date: Thu, 3 Dec 2015 13:01:55 -0500 Subject: [PATCH 5/5] Added code to void draw --- ReturningValues/ReturningValues.pde | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index b52295f..d79c004 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -3,10 +3,13 @@ void setup(){ } void draw(){ + //provides a, b, and c variables for calculation functions float c = pythagorean(6, 50); float d = addThreeNumbers(4, 4, 4); + //draws rectangles rect(width/2, height/2, c, c); rect(width/3, height/2, d, d); + //prints values for c and d in command line println(c); println(d); }