From cd60e7b98fc28fe0d9634c80de508f67445be6f1 Mon Sep 17 00:00:00 2001 From: Smore98 Date: Tue, 1 Dec 2015 13:05:12 -0500 Subject: [PATCH 1/3] Created Functions --- VoidFunctions/VoidFunctions.pde | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/VoidFunctions/VoidFunctions.pde b/VoidFunctions/VoidFunctions.pde index 8b13789..5eea5b0 100644 --- a/VoidFunctions/VoidFunctions.pde +++ b/VoidFunctions/VoidFunctions.pde @@ -1 +1,26 @@ +void setup() { + size(800, 600); +} +void draw() { + drawBlueSquareInCenter(); + drawCircle(30,155,255); + drawRandomTriangleOnMousePress(random(255),random(255),random(255)); +} + +void drawBlueSquareInCenter() { + fill(0, 0, 255); + rect(width/2 - 25, height/2 - 25, 50, 50); +} + +void drawCircle(float r, float g, float b) { + fill(r,g,b); + ellipse(mouseX, mouseY, 30, 30); +} + +void drawRandomTriangleOnMousePress(float r, float g, float b) { + fill(r,g,b); + if (mousePressed){ + triangle(random(795),random(695),random(795),random(695),random(795),random(695)); + } +} \ No newline at end of file From 0923db56aa9b0044f26f3ea89ca3fa0b58988aad Mon Sep 17 00:00:00 2001 From: Smore98 Date: Thu, 3 Dec 2015 12:17:33 -0500 Subject: [PATCH 2/3] Created Pythagorean Theorem --- ReturningValues/ReturningValues.pde | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 8b13789..df1aa6d 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1 +1,17 @@ +float c; +void setup(){ + size(800,600); + +} +void draw(){ + background(0); + pythaTheorem(5,3); + +} + +void pythaTheorem(float a, float b){ + float c = sqrt(sq(a) + sq(b)); + text("The square root of squared " +a+ " and " +b+ " equals " +c, width/2,height/2); + +} \ No newline at end of file From 2d9d730f3947167bed06bb2fbd10f659f6a846cf Mon Sep 17 00:00:00 2001 From: Smore98 Date: Thu, 3 Dec 2015 12:57:02 -0500 Subject: [PATCH 3/3] Improved previous code and added printed function --- ReturningValues/ReturningValues.pde | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index df1aa6d..1a0c0f3 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1,17 +1,20 @@ float c; -void setup(){ - size(800,600); - +void setup() { + size(800, 600); } -void draw(){ +void draw() { background(0); - pythaTheorem(5,3); - + pythaTheorem(5, 3); + println(functionResult(6, 7, 9)); } -void pythaTheorem(float a, float b){ - float c = sqrt(sq(a) + sq(b)); - text("The square root of squared " +a+ " and " +b+ " equals " +c, width/2,height/2); - +void pythaTheorem(float a, float b) { + float c = sqrt(sq(a) + sq(b)); + text("The square root of squared " +a+ " and " +b+ " equals " +c, width/2, height/2); +} + +float functionResult(float x, float y, float z) { + float w = x + y + z; + return w; } \ No newline at end of file