Sunday, September 18, 2011

Class 3: For Loops, new Shapes and more Math!!!

Hello 3rdWard! I hope you had a great week and are ready of another action packed class of Processing.

Today we are going to be focusing on a very important concept: For Loops.

What is a for loop? A for loop is a way of repeating the same commands a specified number of times.
What does it look like? It looks like this:
for(init; test; update){
statements
}
How does a for loop work? The parenthesis setup the structure of a for loop by defining the init, test, and update. The statements inside the block(a block is defined as the arguments inside curly braces{}) run continously as long as the test evaluates as true. The init assigns the initial value of the variable used in the test. The update is used to modify the variable after each iteration of the block. A for loop works like this:
1. The init statement is run
2. The test is evaluated to true or false
3. If the test is true, continue to step 4. If the test is false, jump to step 6
4. Run the statements within the block
5. Run the update statement and jump to step 2
6. Exit the structure and continue running the program

For Loops are very useful in programming graphics as they allow you to make many many iterations very easily.

Shapes:

Here are some cheat sheets that will break down the order in which you need to state your vertices to create a shape the way you want to.


1 comment:

  1. I have been a herpes carrier for 2 years and I tried every possible means of curing but all of no useful until I saw a health promotion on a herbalist from West Africa who prepares herbal medicines to cure all sorts of diseases including #HSV and many others sickness but look at me today am very much happy and healthy, I'm telling you today don't lose hope keep trying God is with you, If you needs Dr.Chala help contact him on his email dr.chalaherbalhome@gmail.com or you can visit his website on http://drchalaherbalhome.godaddysites.com or https://mywa.link/dr.chalaherbalhome

    ReplyDelete