Published using Google Docs
Processing Assign 5 - Advanced Variables (Pythagoras)
Updated automatically every 5 minutes

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%

  1. Using text (and an optional font) give your Program a title related to Pythagoras
  2. Find a definition/description of Pythagoras’ theorem and paste the whole definition into one or more text lines.
  1. Change the starting location of your triangle.  It must be different than your neighbour’s assignment.
  2. The height of the triangle is currently 250 pixels.  Change it to 200 pixels.  
  3. Add text on the screen stating the the lengths of all three lines:
  1. Add text explaining the surface area of the triangle.  This should update as you move the mouse.

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