DOC PREVIEW
GT LCC 6310 - Computation as an Expressive Medium

This preview shows page 1-2-15-16-17-32-33 out of 33 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 33 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Computation as an Expressive MediumLab HoursWhat have you gone over?What will we go over?VariablesSlide 6More info on drawing primitivesJava Control FlowJava Control Flow: LoopingSlide 10Java Control Flow: While LoopsSlide 12Java Control Flow: For LoopsJava Control Flow: Nested LoopsSlide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24The draw() functionSlide 26Slide 27Slide 28Slide 29The setup() functionTracking Mouse PositionReacting to Mouse ClicksThat’s It For Today!Computation as an Computation as an Expressive MediumExpressive MediumLab 1: Loops, Animation, and Lab 1: Loops, Animation, and Simple User InteractionSimple User InteractionJason AldermanJason Alderman*Slides blatantly stolen from Mayhew Seavey. Yoinks!*Slides blatantly stolen from Mayhew Seavey. Yoinks!Lab HoursLab HoursThanks for your responses! Thanks for your responses! I’ll send out an e-mail by the end of I’ll send out an e-mail by the end of the day with with lab hours.the day with with lab hours.And always feel free to e-mail me if And always feel free to e-mail me if you have questions. I’m at you have questions. I’m at [email protected]@mail.gatech.edu . . (If you forget, it’ll be on the whiteboard (If you forget, it’ll be on the whiteboard in here.)in here.)http://www.lcc.gatech.edu/~mateas/courses/LCC6310-Fall2005/Syllabus2005.htmlWhat have you gone over?What have you gone over?Window size and coordinate systemWindow size and coordinate systemCommenting codeCommenting codeVariablesVariablesDrawing primitivesDrawing primitivespointpointlinelinerectrectellipseellipsetriangletriangleprint() and println()print() and println()if(boolean){ do something }else{ do something} logicif(boolean){ do something }else{ do something} logic(0,0)xyWhat will we go over?What will we go over?Courseware!Courseware!Variables: A RecapVariables: A RecapDrawing primitives (more info)Drawing primitives (more info)Java Control Flow: LoopingJava Control Flow: LoopingThe Processing “draw()” looping The Processing “draw()” looping function for animationfunction for animationSimple mouse interactionSimple mouse interactionVariablesVariablesVariables are placeholders for your data.Variables are placeholders for your data.int i; // declares a new variable ii = 1; // assigns the value of 1 to the new variableint j = i + 1; // declares a new variable j, and assigns it to i + 1, which is 2.VariablesVariablesTwo main types: Primitives and ObjectsTwo main types: Primitives and ObjectsPrimitives:Primitives:BooleanBoolean, , CharChar, Byte, Short, , Byte, Short, IntInt, Long, , Long, FloatFloat, , DoubleDoubleObjects:Objects:Everything else. Everything else. Constructed with primitives as a base. For Constructed with primitives as a base. For example, a “String” object is a series of Char example, a “String” object is a series of Char variables.variables.More info on drawing More info on drawing primitivesprimitivesZooooom on over to the reference Zooooom on over to the reference pages…pages…Java Control FlowJava Control FlowIf-Then-Else: Conditional LogicIf-Then-Else: Conditional Logicint i = 5;if(i > 10) {save_the_kitten();}else if(i > 3) {throw_the_kitten();}else {paint_the_kitten();}Java Control Flow: LoopingJava Control Flow: LoopingWant to draw ten lines, evenly-Want to draw ten lines, evenly-spaced apart?spaced apart?line(10, 10, 10, 200);line(20, 10, 20, 200);line(30, 10, 30, 200);...This can get old, fast. Also would be tedious if you This can get old, fast. Also would be tedious if you wanted to change all of the lines to start 5 pixels wanted to change all of the lines to start 5 pixels higher, instead.higher, instead.Java Control Flow: LoopingJava Control Flow: LoopingWant to draw ten lines, evenly-Want to draw ten lines, evenly-spaced apart?spaced apart?line(10, 10, 10, 200);line(20, 10, 20, 200);line(30, 10, 30, 200);...This can get old, fast. Also would be tedious if you This can get old, fast. Also would be tedious if you wanted to change all of the lines to start 5 pixels wanted to change all of the lines to start 5 pixels higher, instead.higher, instead.What if we could run this What if we could run this same line of code multiple same line of code multiple times, only changing these times, only changing these two numbers?two numbers?Java Control Flow: While Java Control Flow: While LoopsLoopsHoly Toledo! We can! Let’s use a while loop!Holy Toledo! We can! Let’s use a while loop!line(10, 10, 10, 200);line(20, 10, 20, 200);line(30, 10, 30, 200);...int i = 10;while(i <= 100) { line(i, 10, i, 200); i = i + 10;}A while loop will run the code inside the brackets repeatedly A while loop will run the code inside the brackets repeatedly until the condition in the parentheses is false.until the condition in the parentheses is false.Java Control Flow: While Java Control Flow: While LoopsLoopsBe careful with loops. Make sure the Be careful with loops. Make sure the condition will eventually return false, or else condition will eventually return false, or else it will go forever.it will go forever.while(true) { ...}int i = 10;while(i > 0) { line(i, 10, i, 200); i = i + 10;}Both of these loops are valid, will compile, Both of these loops are valid, will compile, and run infinitely.and run infinitely.Java Control Flow: For LoopsJava Control Flow: For LoopsFor Loops are just like While loops, but a For Loops are just like While loops, but a bit more compact for simple incrementing, bit more compact for simple incrementing, like in our last example.like in our last example.These two loops are functionally the same:These two loops are functionally the same:int i = 10;while(i <= 100) { line(i, 10, i, 200); i += 10;}for(int i = 10; i <= 100; i += 10) { line(i, 10, i, 200);}(i += 10 is equivalent to i = i + 10)Java Control Flow: Nested Java Control Flow: Nested LoopsLoopsNesting of loops refers to putting one Nesting of loops refers to putting one loop inside the brackets of another.loop inside the brackets of another.for(int i = 10; i <= 100; i += 10) { for(int j = 10; j <= 100; j += 10) { point(i, j); }}What does this mean? It means that the inside What does this mean? It means that the inside loop will run all the way through, then loop will run all the way through, then ii will will increment, and the inside loop


View Full Document

GT LCC 6310 - Computation as an Expressive Medium

Documents in this Course
Load more
Download Computation as an Expressive Medium
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Computation as an Expressive Medium and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Computation as an Expressive Medium 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?