1 / 5

Review of ArT3 Programming Course

Review of ArT3 Programming Course. David Meredith Aalborg University dave@create.aau.dk. Lecture 1: Introduction to Processing. Drawing simple shapes point(x,y ) line(x1,y1,x2,y2) rect(x,y,w,h ) rectMode(CORNER|CENTER|CORNERS ) ellipse(x,y,w,h ) ellipseMode(CORNER|CENTER|CORNERS )

reegan
Download Presentation

Review of ArT3 Programming Course

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Review of ArT3 Programming Course David Meredith Aalborg University dave@create.aau.dk

  2. Lecture 1: Introduction to Processing • Drawing simple shapes point(x,y) line(x1,y1,x2,y2) rect(x,y,w,h) rectMode(CORNER|CENTER|CORNERS) ellipse(x,y,w,h) ellipseMode(CORNER|CENTER|CORNERS) • Defining greyscale values • 0 = black, 255 = white stroke(n) (default is black) fill(n) (default is white) background(n) (default is grey) noStroke() noFill() • Defining colours fill(r,g,b) stroke(r,g,b) background(r,g,b) • Defining opacity (alpha) • 255 = completely opaque, 0 = completely transparent • Greyscale fill(n,a) background(n,a) stroke(n,a) • Colour fill(r,g,b,a) background(r,g,b,a) stroke(r,g,b,a) • Defining line width strokeWeight(x) • Defining drawing area size(x,y) • Smoothing lines and edges smooth() • Printing to console println(“a string”) • Comments // comments rest of line /* comments region in between */ • Program structure setup() and draw() • Tracking mouse location mouseX and mouseY pmouseX and pmouseY • Responding to mouse clicks and key presses void mousePressed() void keyPressed() • Using Processing • Shift-Click Run to run full screen • Sketchbook • Publishing (Exporting) a sketch

  3. Lecture 2: Variables and Conditionals • Variables • Types • int, byte, short, long • double, float • char • boolean • Declaring variables • intx; • Initializing variables • intx = 2; • Global variables • Defined outside setup() and draw() • Assigning values to variables • x = 5; • System variables • width, height, frameCount, frameRate, screen.width, screen.height, key, keyCode, mousePressed, mouseX, mouseY, pmouseX, pmouseY, mouseButton • Random numbers • w = random(x,y) • w = random(x) • Type-casting • e.g., w = int(random(1,100)) • Conditionals • Boolean expressions • Relational operators • >, <, >=, <=, ==, != • if (condition) {doThis();} • if (condition) {doThis();}else {doThat();} • if (condition1) {doThis();}else if (condition2) {doThat();}else {doTheOther();} • Logical operators • &&, ||, ! • Bouncing ball programme

  4. Lecture 3: Loops and Functions • Loops • while(condition) {doThis(); change something;} • intx = constrain(value, min, max); • for (initialization; test; change something) {doThis();} • Increment expressions • i++, i--, i += 2, i -= 2 • Scope • Loops within loops • Functions • Modularity and reusability • ReturnType functionName(ArgType1 arg1, ArgType2 arg2) {ReturnTyper = something;doSomethingWithR(); return r;}

  5. Lecture 4: Objects and Arrays • Objects • Data and functions together • Instance variables and methods • Classes as templates for making objects • Dot notation for messages • myCar.move(); • ints = myCar.speed; • Writing a class • class ClassName {intx; float y;ClassName(intx, float y) {this.x = x;this.y = y; } void display() { //Use x and y to show this object …. }} • Class definitions must appear outside of setup() or draw() • Putting a class in its own tab • Arrays • Array is a list of boxes, all holding values of the same type • Declaring an array variable • int[] arrayOfInts; • Creating an array • int[] arrayOfInts = new int[10]; • Accessing an element in an array • arrayOfInts[0] = 5; • intx = arrayOfInts[0]; • Initializing all elements at once • int[] intArray = {5,4,3,2,1}; • Initializing an array with a loop • for (inti = 0; i < intArray.length; i++)intArray[i] = 2 * i; • Array functions • shorten(), concat(), subset(), etc.

More Related