11=interface=20130607

36
Processing Processing 1 1 Interface I Interface I 介介 介介 I I

Upload: gene-kao

Post on 27-Apr-2017

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 11=Interface=20130607

ProcessingProcessing

11

Interface IInterface I 介面 介面 II

Page 2: 11=Interface=20130607

Input : Mouse I, IIInput : Mouse I, II

Page 3: 11=Interface=20130607

mouseX, mouseY,pmouseX, pmouseY, mousePressed, mouseButton,cursor(), noCursor().

Page 4: 11=Interface=20130607
Page 5: 11=Interface=20130607

void setup() { size(400,400); background(255); ellipseMode(CENTER);}

void draw() { noFill(); stroke(2); circles(mouseX,mouseY);}

void circles(int x, int y) { translate(x,y); ellipse(0,0,50,50);}

Page 6: 11=Interface=20130607

void setup() { size(400,400); background(255); ellipseMode(CENTER);}

void draw() { noFill(); stroke(2); circles(mouseX,mouseY);}

void circles(int x, int y) { translate(x,y); ellipse(0,0,50,50);}

Page 7: 11=Interface=20130607
Page 8: 11=Interface=20130607

void setup() { size(400,400); background(255); ellipseMode(CENTER);}

void draw() { noFill(); stroke(2); if (mousePressed == true) { circles(mouseX,mouseY); }}

void circles(int x, int y) { translate(x,y); ellipse(0,0,50,50);}

Page 9: 11=Interface=20130607
Page 10: 11=Interface=20130607

void setup() { size(400,400); background(255); ellipseMode(CENTER); smooth(); strokeWeight(3);}

void draw() { noStroke(); fill(random(255),random(255),random(255),random(200)); if (mousePressed == true) { circles(mouseX,mouseY);}}

void circles(int x, int y) { translate(x,y); ellipse(0,0,50, 50);}

Page 11: 11=Interface=20130607
Page 12: 11=Interface=20130607

void setup() { size(400,400); background(255); ellipseMode(CENTER); smooth(); strokeWeight(3);}

void draw() { noStroke(); fill(random(255),random(255),random(255),random(200)); if (mousePressed == true) { circles(mouseX,mouseY);}}

void circles(int x, int y) { translate(x,y); ellipse(0,0,50,random(50));}

Page 13: 11=Interface=20130607
Page 14: 11=Interface=20130607

void circles(int x, int y) { translate(x,y); ellipse(0,0,50,random(50));}

void circles(int x, int y) { translate(x,y); ellipse(0,0,random(100),random(100));}

Page 15: 11=Interface=20130607

void setup() { size(400,400); background(255); ellipseMode(CENTER); smooth(); strokeWeight(3);}

void draw() { noStroke(); fill(random(255),random(255),random(255),random(200)); if (mousePressed == true) { circles(mouseX,mouseY);}}

void circles(int x, int y) { translate(x,y); ellipse(0,0,random(100),random(100));}

Page 16: 11=Interface=20130607
Page 17: 11=Interface=20130607

void setup() { size(400,400); background(255); ellipseMode(CENTER); smooth(); strokeWeight(3);}

void draw() { if (mousePressed == true) { lines(mouseX,mouseY);}}

void lines(int x, int y) { translate(x,y); line(0,0,random(100),random(100));}

Page 18: 11=Interface=20130607
Page 19: 11=Interface=20130607

void lines(int x, int y) { translate(x,y); // stroke(random(255)); stroke(random(255),random(255),random(255)); float d = random(50); line(0,0,d,d);}

Page 20: 11=Interface=20130607

void setup() { size(400,400); background(255); ellipseMode(CENTER); smooth(); strokeWeight(3);}

void draw() { if (mousePressed == true) { lines(mouseX,mouseY);}}

void lines(int x, int y) { translate(x,y); // stroke(random(255)); stroke(random(255),random(255),random(255)); float d = random(50); line(0,0,d,d);}

Page 21: 11=Interface=20130607
Page 22: 11=Interface=20130607

void setup() { size(400,400); }void draw() { noFill(); stroke(1); rectangles(mouseX,mouseY);}void rectangles(int x, int y) { translate(x,y); rect(-5,-5,10,10); rect(-15,-15,30,30); rect(-25,-25,50,50);}

Page 23: 11=Interface=20130607
Page 24: 11=Interface=20130607

void setup() { size(400,400); }void draw() { noFill(); stroke(1); if (mousePressed == true) { rectangles(mouseX,mouseY);}}void rectangles(int x, int y) { translate(x,y); rect(-5,-5,10,10); rect(-15,-15,30,30); rect(-25,-25,50,50);}

Page 25: 11=Interface=20130607
Page 26: 11=Interface=20130607

void setup() { size(400,400); ellipseMode(CENTER); strokeWeight(2); smooth(); }void draw() { noFill(); stroke(1); if (mousePressed == true) { Bulleye(mouseX,mouseY);}}void Bulleye(int x, int y) { translate(x,y); fill(255); ellipse(0,0,50,50); fill(0); ellipse(0,0,30,30); fill(255); ellipse(0,0,10,10);}

Page 27: 11=Interface=20130607
Page 28: 11=Interface=20130607

void setup() { size(400,400); smooth();}void draw() { noFill(); stroke(1); if ((mousePressed == true) && (mouseButton == LEFT)) { rectangles(mouseX,mouseY);} if ((mousePressed == true) && (mouseButton == RIGHT)) { circles(mouseX,mouseY);}}void rectangles(int x, int y) { translate(x,y); rect(-5,-5,10,10); rect(-15,-15,30,30); rect(-25,-25,50,50);}

void circles(int x, int y) { translate(x,y); ellipse(0,0,10,10); ellipse(0,0,30,30); ellipse(0,0,50,50);}

Page 29: 11=Interface=20130607
Page 30: 11=Interface=20130607

int num = 10;

void setup(){ size(400, 400); smooth(); noFill();}

void draw() { background(255); for (int y = 0; y <= num; y ++) { for (int x = 0; x <= num; x ++) { stroke(random(255),random(255),random(255)); float posX = width / num * x; float posY = height / num * y; ellipse(posX, posY, 10, 10);}}}

Page 31: 11=Interface=20130607

int num = 10;

void setup(){ size(400, 400); smooth(); noFill();}

void draw() { background(255); randomSeed(0); strokeWeight(mouseY / 50); for (int y = 0; y <= num; y ++) { for (int x = 0; x <= num; x ++) { stroke(random(255),random(255),random(255)); float posX = width / num * x; float posY = height / num * y; float shiftX = random(-mouseX, mouseX) / 20; float shiftY = random(-mouseX, mouseX) / 20; ellipse(posX+shiftX, posY+shiftY, mouseY/5, mouseY/5);}}}

Page 32: 11=Interface=20130607

void setup() { size(100, 100); noCursor();}void draw() { background(204); if (mousePressed == true) { cursor();}}

Page 33: 11=Interface=20130607

void setup() { size(100, 100); strokeWeight(8); smooth();}void draw() { background(204); line(mouseX, mouseY, pmouseX, pmouseY);}

Page 34: 11=Interface=20130607

mousePressed(), mouseReleased(), mouseMoved(), mouseDragged()keyPressed(), keyReleased()loop(), redraw()

Input 3:Events (P.229)

Page 35: 11=Interface=20130607

constrain(), dist(), abs(), atan2()

Input 4:Mouse II (P.237)

Page 36: 11=Interface=20130607

Ch. 23, 2706/07/2013