programming for artists and designers: week 2
DESCRIPTION
Slides for the 2nd week of an introductory Processing course at the V&ATRANSCRIPT
Week 2: Fundamentals of Programming
Variables, Arrays, For Loops, If Statements
int centerX = 320;
variables
variables
variables
variables
do not change
can change
variables
a short break: println and detecting the mouse
println(mouseX + “\t” + mouseY);
a short break: width and height
ellipse(width/2, height/2,100,100);
arrays
int[] centerX = new int[10];
int[] centerX = {0,0,1,1,2,2,3,3,4,4
};
arrays
int[] centerX = new int[10];
arrays
centerX[0]=0;centerX[1]=0;centerX[2]=1;centerX[3]=2; …and so on
void setup(){
int[] centerX = new int[10];
arrays… and for loops
for (int i = 0; i < 10; i++){centerX[i] = i/2;
}
void setup(){
}
for loops
void setup(){ blahblahblah();}
void draw(){ blahblah(); for (int i = 0; i < 20; i++){
blahblahblah();blah[i] = blah[i] +1;
} blahblah();}
if… else
if (mousePressed == true){do something;
}else if (keyPressed == true){
do something else;}else {
do something else;}
if… else
if (centerX < width/2){do something;
}else if (centerX >= 3*width/4){
do something else;}else {
do something else;}