Processing Assign 5 - Advanced Variables
This assignment is to be completed by those students on pace for, and interested in, getting 90 or 100% in the credit.
Begin by opening the Pythagoras code example we completed in class. The code is available on the S: drive and/or at the end of this document. Then save the code as Assign5AdvancedVariables.pde. I will not mark it if it is not saved with the new name.
First 80%
Eventually you will ask yourself this question: Wait, how do I calculate the square root? I am not going to tell you... but this link will.
How do you know if you did it right?
Your height should aways equal 200. Your width should change as you drag your mouse. Do an area calculation outside of Processing and compare it with what your Processing file says. If the numbers match, you did it right.
Final 20%
Add a second shape (not a triangle) but its height should change using mouseY. Line lengths and surface areas must be included.
Still Need a Challenge
This is not for marks, but if you are a glutton for punishment, save the file as version 2 and then try the following (they may not all be possible within the time given).
Pythagoras Code
//Global Variables
int widthX = 200;
void setup(){
size(500,500);
}
void draw(){
background(0);
widthX = mouseX;
stroke(255,255,0);
strokeWeight(4);
line(50,50,50,300);
line(50,300,widthX,300);
line(50,50,widthX,300);
}//end draw