diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 8b13789..1a0c0f3 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1 +1,20 @@ +float c; +void setup() { + size(800, 600); +} +void draw() { + background(0); + 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); +} + +float functionResult(float x, float y, float z) { + float w = x + y + z; + return w; +} \ No newline at end of file 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