Willkommen auf unserem Seminar-Blog

Immer auf dem aktuellen Stand bleiben

Dieser Seminar-Blog befindet sich noch im Aufbau und wird in den kommenden Tagen entsprechend verfeinert.

Member Login

Lost your password?

Registration is closed

Sorry, you are not allowed to register by yourself on this site!

You must either be invited by one of our team member or request an invitation by email at viad.info {at} zhdk {dot} ch.

Processing – Photo leafes

Februar 24, 2012

Der Sketch generiert farbige Blätter auf Grundlage eines Bildes.

boolean go = true;
PImage img;

void setup()  {
size(800,600);
smooth();
background(255);
stroke(255);

img = loadImage("mops.jpg");
img.loadPixels();

}

void draw() {
if(go) {
for(int i = 0;i img.width) {
_x -= abs(_x+w-img.width);
}
if(_y+w > img.height) {
_y -= abs(_y+w-img.height);
}
PVector c = new PVector();
for (int x = _x; x < _x+w; x++ ) {
for (int y = _y; y < _y+w; y++ ) {
int loc = x + y * img.width;
color col = img.pixels[loc];
c.x += red(col);
c.y += green(col);
c.z += blue(col);
}
}
c.div(w*h);
return color(c.x,c.y,c.z);
}

void makeLeaf(float _x,float _y) {

//int loc = int(_x) + int(_y) * img.width;
//fill(img.pixels[loc]);
fill(getColor(int(_x),int(_y),10,10));

pushMatrix();
translate(_x,_y+5);

scale(random(1,2.5));
rotate(random(TWO_PI));

strokeWeight(0.5);
beginShape();
vertex(0, -10); // V1 (see p.76)
bezierVertex(0, -10, 5, -2.5, 0, 0); // C1, C2, V2
bezierVertex(0, 0, -5, -2.5, 0, -10); // C3, C4, V3
endShape();

strokeWeight(0.2);
beginShape();
vertex(0, -10);
float c2x = random(3,4.2);
float c2y = random(0,2);
bezierVertex(0, -10, c2x, -c2y, 0, 0); // C1, C2, V2
bezierVertex(0, 0, -c2x, -c2y, 0, -10); // C3, C4, V3
c2x = random(0.5,1.5);
c2y = random(-0,-4);
bezierVertex(0, -10, c2x, -c2y, 0, 0); // C1, C2, V2
bezierVertex(0, 0, -c2x, -c2y, 0, -10); // C3, C4, V3
endShape();

popMatrix();
}