diff --git a/ReturningValues/ReturningValues.pde b/ReturningValues/ReturningValues.pde index 8b13789..8cdce05 100644 --- a/ReturningValues/ReturningValues.pde +++ b/ReturningValues/ReturningValues.pde @@ -1 +1,21 @@ +void setup(){ + size(800, 600); + textSize(16); +} +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 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