Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions ReturningValues/ReturningValues.pde
Original file line number Diff line number Diff line change
@@ -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;
}
41 changes: 41 additions & 0 deletions VoidFunctions/VoidFunctions.pde
Original file line number Diff line number Diff line change
@@ -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);
}