White - Perspective, A Guide for Artists, Architects and Designers
Programming for Artists and Designers: Week 2
-
Upload
tinker-london -
Category
Technology
-
view
425 -
download
1
description
Transcript of Programming for Artists and Designers: Week 2
![Page 1: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/1.jpg)
Week 2: Fundamentals of Programming
Variables, Arrays, For Loops, If Statements
![Page 2: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/2.jpg)
int centerX = 320;
variables
![Page 3: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/3.jpg)
variables
![Page 4: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/4.jpg)
variables
![Page 5: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/5.jpg)
variables
do not change
can change
![Page 6: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/6.jpg)
variables
![Page 7: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/7.jpg)
a short break: println and detecting the mouse
println(mouseX + “\t” + mouseY);
![Page 8: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/8.jpg)
a short break: width and height
ellipse(width/2, height/2,100,100);
![Page 9: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/9.jpg)
arrays
int[] centerX = new int[10];
![Page 10: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/10.jpg)
int[] centerX = {0,0,1,1,2,2,3,3,4,4
};
arrays
![Page 11: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/11.jpg)
int[] centerX = new int[10];
arrays
centerX[0]=0;centerX[1]=0;centerX[2]=1;centerX[3]=2; …and so on
void setup(){
![Page 12: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/12.jpg)
int[] centerX = new int[10];
arrays… and for loops
for (int i = 0; i < 10; i++){centerX[i] = i/2;
}
void setup(){
}
![Page 13: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/13.jpg)
for loops
void setup(){ blahblahblah();}
void draw(){ blahblah(); for (int i = 0; i < 20; i++){
blahblahblah();blah[i] = blah[i] +1;
} blahblah();}
![Page 14: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/14.jpg)
if… else
if (mousePressed == true){do something;
}else if (keyPressed == true){
do something else;}else {
do something else;}
![Page 15: Programming for Artists and Designers: Week 2](https://reader036.fdocuments.us/reader036/viewer/2022082920/55561a24d8b42a3f168b5409/html5/thumbnails/15.jpg)
if… else
if (centerX < width/2){do something;
}else if (centerX >= 3*width/4){
do something else;}else {
do something else;}