1 / 5

# Review of ArT3 Programming Course - PowerPoint PPT Presentation

Review of ArT3 Programming Course. David Meredith Aalborg University [email protected] 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 )

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Review of ArT3 Programming Course' - reegan

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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Review of ArT3 Programming Course

David Meredith

Aalborg University

• 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 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

• 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

• 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;}

• 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.