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
18 changes: 18 additions & 0 deletions ReturningValues/ReturningValues.pde
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
void setup(){
size(800,600);
}

void draw(){
float c = pythagorean(5, 4);
float z = added(3,2,4);
println(z); //print whichever specified
}

float pythagorean(float a, float b){
float c = sqrt(pow(a,2)+pow(b,2));
return c;
}

float added(float w, float x, float y){
float z = w + x + y;
return z;
}
44 changes: 44 additions & 0 deletions VoidFunctions/VoidFunctions.pde
Original file line number Diff line number Diff line change
@@ -1 +1,45 @@
void setup(){
size(800,600);
background(0);
}

void draw(){
drawRandomRect();
drawBlueSquare();
drawMouseCircle();
}

void drawBlueSquare(){
float side = random(10,50);
noStroke();
fill(0,0,random(100,200));
rect(width/2,height/2,side,side);
}

void drawMouseCircle(){
float diam = random(10,30);
noStroke();
setFill();
ellipse(mouseX,mouseY, diam, diam);
}

void setFill(){
float r;
float g;
float b;
float transparency;
r = random(0,255);
g = random(0,255);
b = random(0,255);
transparency = random(50,150);
fill(r, g, b,transparency);
}

void drawRandomRect(){
if(mousePressed){
float leng = random(10,40);
float wid = random(10,40);
noStroke();
rect(random(width), random(height), leng, wid);
}
}