DOC PREVIEW
GT LCC 6310 - LCC 6310 Computation as an Expressive Medium

This preview shows page 1-2-3-4-5-6 out of 18 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 18 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 18 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 18 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 18 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 18 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 18 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 18 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

LCC 6310 Computation as an Expressive MediumAdministriviaOverviewDrawing primitives revisitedThe drawing commands are methodsIntroduction to variablesVariables have a typeEffect of creating an int variableAssigned values must match the typeThe “primitive” typesCan combine declaring and assigningPrint and printlnControl flowIfSome boolean expressionsExampleWhat do you think of this?NMR IntroductionsLCC 6310Computation as an Expressive MediumLCC 6310Computation as an Expressive MediumLecture 2Lecture 2AdministriviaAdministrivia•Books?Books?•Processing installed?Processing installed?•Lab timesLab timesOverviewOverview•Discuss variables & if-thenDiscuss variables & if-then•Discuss readingsDiscuss readings•Look at assignment 1Look at assignment 1Drawing primitives revisitedDrawing primitives revisited•What are the different parts of a What are the different parts of a drawing primitive?drawing primitive?lineline((00, , 00, , 5050, , 5050));;method nameparentheses contain argumentsargumentsThe drawing commands are methodsThe drawing commands are methods•Methods are reusable commands Methods are reusable commands •Like a little machine that does work for you•Let’s you reuse code without typing it over and over•The arguments tell the method precisely The arguments tell the method precisely what to dowhat to do•We’ll see later that you can define your We’ll see later that you can define your own methods!own methods!Introduction to variablesIntroduction to variables•A variable is a named box for storing valuesA variable is a named box for storing values•You can put values in a variable by using You can put values in a variable by using the assignment operator (aka “=“ )the assignment operator (aka “=“ )e.g. x = 1;e.g. x = 1;•To use the value stored in a variable, just To use the value stored in a variable, just use the variable’s nameuse the variable’s namee.g. line(x, 0, 50, 50);e.g. line(x, 0, 50, 50);Variables have a typeVariables have a type•You must tell Processing (Java) what You must tell Processing (Java) what kinds of values can go in the boxkinds of values can go in the box•You do this by giving a variable a You do this by giving a variable a typetypeint x; // variable x can hold integers (int)int y; // variable y can hold integers (int)x = 20; // store 20 in xy = 30; // store 30 in ypoint(x, y); // use the values of x and y to draw a pointEffect of creating an int variableEffect of creating an int variable// Single intint anInt;// Put a value in the intanInt = 3;// Type error!anInt = “hello”;Code EffectName: anInt, Type: int3Name: anInt, Type: intName: anInt, Type: int“hello”Can’t shove “hello” into an intAssigned values must match the type Assigned values must match the type int x; // variable x can hold integers (int)int y; // variable y can hold integers (int)x = 1.5; // store 1.5 in x causes an error!!!y = 30; // store 30 in ypoint(x, y); // use the values of x and y to draw a pointThe “primitive” typesThe “primitive” types•int – integers between 2,147,483,648 and 2,147,483,647 int – integers between 2,147,483,648 and 2,147,483,647 •float – floating point numbers (e.g. 3.1415927, -2.14)float – floating point numbers (e.g. 3.1415927, -2.14)•char – a single character (e.g. ‘c’)char – a single character (e.g. ‘c’)•byte – integers between -128 and 127byte – integers between -128 and 127•boolean – holds the values boolean – holds the values truetrue or or falsefalse•color – holds a color (red, green, blue, alpha)color – holds a color (red, green, blue, alpha)Can combine declaring and assigningCan combine declaring and assigning•Declaring a variable means telling Processing it’s Declaring a variable means telling Processing it’s typetypeint x;int x;•Assigning a value to a variable means putting a Assigning a value to a variable means putting a value in the named boxvalue in the named boxx = 1;x = 1;•You can declare and assign at the same timeYou can declare and assign at the same timeint x = 1; int x = 1; •But only declare a variable once, otherwise you get But only declare a variable once, otherwise you get an erroran errorPrint and printlnPrint and println•When working with variables, it is When working with variables, it is often convenient to look at their often convenient to look at their valuesvalues•print() and println() print to the print() and println() print to the bottom processing panebottom processing pane•They do the same thing, except println starts a new line after printingControl flowControl flow•By default Processing (Java) executes the lines of By default Processing (Java) executes the lines of a method one after the othera method one after the other•Sequential control flow•Unc onditional – doesn’t matter what happens in the world•Often we want which steps are executed to Often we want which steps are executed to depend on what else has happeneddepend on what else has happened•That is, we want That is, we want conditionalconditional control flow control flow•This is necessary in order to make anything that is intera c t iveIfIf•IfIf statements introduce conditional statements introduce conditional branchesbranchesIf (<boolean expression>){If (<boolean expression>){// do this code// do this code}}•Boolean expressions have one of two Boolean expressions have one of two values: values: truetrue or or falsefalseSome boolean expressionsSome boolean expressionsanInteger == 1 true if variable anInteger is equal to 1x > 20 true if variable x is greater than 201 == 2 true if 1 is equal to 2, it’s not so this is false! is the not operator – reverses true and false so, ! 1 == 2 is true!This is not a boolean expressionint anInteger = 1;ExampleExamplestrokeWeight(2); // draw with heavier linestroke(200, 0, 0); // draw with redish lineboolean drawRect = true; boolean drawAnX = true;if (drawRect) { fill(0, 200, 0); // fill with green rect(30, 30, 40, 40);}if (drawAnX) { line(0, 0, 100, 100); line(100, 0, 0, 100);}Try changing the values of drawRect and drawAnXTry changing the values of drawRect and drawAnXWhat do you think of this?What do you think of this?“Which means that those computer scientists who invented these technologies … are the important artists of our time, maybe the only artists who are truly important and who will be remembered from this historical period.”Lev


View Full Document

GT LCC 6310 - LCC 6310 Computation as an Expressive Medium

Documents in this Course
Load more
Download LCC 6310 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 LCC 6310 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 LCC 6310 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?