From ab2ce3e4929a714e5843392f081c14974dd5aa21 Mon Sep 17 00:00:00 2001 From: elugtu Date: Tue, 1 Dec 2015 13:08:22 -0500 Subject: [PATCH 1/4] Functions added blueSquare(); circleAtMouse(color a, color b, color c); circleAtMouse(boolean rand); addition(int x, int y); --- VoidFunctions/VoidFunctions.pde | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 8b13789..3c76a6d 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -1 +1,42 @@ +void setup() { + size(800, 600); +} +void draw() { + background(255); + blueSquare(); + circleAtMouse(true); //example of boolean version + addition(525, 600); +} + + +//blue square drawn in the center with the length of 50 +void blueSquare() { + fill(0, 0, 255); + rectMode(CENTER); + rect(width/2, height/2, 50, 50); +} + +//circle drawn follows mouse. Needs int inputs +void circleAtMouse(color a, color b, color c) { + fill(a, b, c); + ellipse(mouseX, mouseY, 30, 30); +} + +//circle drawn follows mouse. Needs true/false statement input +void circleAtMouse(boolean rand) { + if (rand) { + fill(random(255), random(255), random(255)); + } else { + fill(0); + } + ellipse(mouseX, mouseY, 30, 30); +} + +//does simple addition for your lazy bones +void addition(int x, int y) { + fill(0); + textSize(30); + textAlign(CENTER); + text(x + " + " + y + " = " + (x + y), width/2, height/2 + 100); +} \ No newline at end of file From 3fc5817d0096b6c470ac7c7b4fd23ae356842b52 Mon Sep 17 00:00:00 2001 From: elugtu Date: Thu, 3 Dec 2015 12:15:57 -0500 Subject: [PATCH 2/4] added pythaThm function, returns value c --- ReturningValues/ReturningValues.pde | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 8b13789..8ecfe36 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1 +1,15 @@ +void setup(){ + size(800, 600); + textSize(16); +} +void draw(){ + background(0); + pythaThm(3, 4); +} + +float pythaThm(float a, float b){ + float c = sqrt(sq(a) + sq(b)); + text("The hypotenuse of a triangle with the sides " + a + " and " + b + " is " + c + ". ", width/4, height/2); + return c; +} \ No newline at end of file From edd3c531cfcb5ca5f1dd44768a60a9684f550136 Mon Sep 17 00:00:00 2001 From: elugtu Date: Thu, 3 Dec 2015 12:22:10 -0500 Subject: [PATCH 3/4] added comments --- ReturningValues/ReturningValues.pde | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 8ecfe36..792e4b8 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -8,8 +8,8 @@ void draw(){ pythaThm(3, 4); } -float pythaThm(float a, float b){ - float c = sqrt(sq(a) + sq(b)); - text("The hypotenuse of a triangle with the sides " + a + " and " + b + " is " + c + ". ", width/4, height/2); - return c; +float pythaThm(float a, float b){ //solves the hypotenuse c with a and b. Pythagorean Theorem. + float c = sqrt(sq(a) + sq(b)); + text("The hypotenuse of a triangle with the sides " + a + " and " + b + " is " + c + ". ", width/4, height/2); + return c; //saves the value back to c } \ No newline at end of file From ae07ec7c9ebb385d2867b2799f5b9e71efc52107 Mon Sep 17 00:00:00 2001 From: elugtu Date: Thu, 3 Dec 2015 12:58:23 -0500 Subject: [PATCH 4/4] created function that adds 3 values together --- ReturningValues/ReturningValues.pde | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 792e4b8..8cdce05 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -6,10 +6,16 @@ void setup(){ void draw(){ background(0); pythaThm(3, 4); + println(addEmUp(1, 2, 3)); } float pythaThm(float a, float b){ //solves the hypotenuse c with a and b. Pythagorean Theorem. float c = sqrt(sq(a) + sq(b)); text("The hypotenuse of a triangle with the sides " + a + " and " + b + " is " + c + ". ", width/4, height/2); return c; //saves the value back to c +} + +float addEmUp(float a, float b, float c){ //adds all three numbers and returns them + float d = a + b + c; + return d; } \ No newline at end of file