The Green Man

Using a photo that I split up into 5 parts, I used the image import capabilities of Processing to create a Java animation of a green manikin.Have a look at it online here or the source code below.

int x1, x2, y1, y2, x1a, x2a, y1a, y2a, x1b, x2b, y1b, y2b, x1c, x2c, y1c, y2c, x1d, x2d, y1d, y2d;

int boxWidth=100;
int boxHeight=500;
int boxX=0;
int boxY=0;
int box2Width=100;
int box2Height=500;
int box2X=100;
int box2Y=0;
int box3Width=100;
int box3Height=500;
int box3X=200;
int box3Y=0;
int box4Width=100;
int box4Height=500;
int box4X=300;
int box4Y=0;
int box5Width=100;
int box5Height=500;
int box5X=400;
int box5Y=0;

int r=150;
int g=140;
int b=180;

PImage greenman;
PImage greenman1;
PImage greenman2;
PImage greenman3;
PImage greenman4;
PImage greenman5;

void setup(){
size(500,500);
frameRate(30);
greenman = loadImage("greenman.jpg");
greenman1 = loadImage("greenman1.jpg");
greenman2 = loadImage("greenman2.jpg");
greenman3 = loadImage("greenman3.jpg");
greenman4 = loadImage("greenman4.jpg");
greenman5 = loadImage("greenman5.jpg");
}

void draw() {
fill(0,250,250,250);
image(greenman,0,0,width,height);

x1 = int(random(6)-3);
x2 = int(random(4)-2);
y1 = int(random(2)-1);
y2 = int(random(2)-1);

boxX += x1;
boxY += y1;
boxWidth += x2;
boxHeight += y2;

r += int(random(4)-2);
g += int(random(4)-2);
b += int(random(4)-2);

tint(0,r,g,b);
image(greenman1,boxX,boxY,boxWidth,boxHeight);

x1a = int(random(6)-3);
x2a = int(random(4)-2);
y1a = int(random(2)-1);
y2a = int(random(2)-1);

box2X += x1a;
box2Y += y1a;
box2Width += x2a;
box2Height += y2a;

image(greenman2,box2X,box2Y,box2Width,box2Height);

x1b = int(random(6)-3);
x2b = int(random(4)-2);
y1b = int(random(2)-1);
y2b = int(random(2)-1);

box3X += x1b;
box3Y += y1b;
box3Width += x2b;
box3Height += y2b;

image(greenman3,box3X,box3Y,box3Width,box3Height);

x1c = int(random(6)-3);
x2c = int(random(4)-2);
y1c = int(random(2)-1);
y2c = int(random(2)-1);

box4X += x1c;
box4Y += y1c;
box4Width += x2c;
box4Height += y2c;

image(greenman4,box4X,box4Y,box4Width,box4Height);

x1d = int(random(6)-3);
x2d = int(random(4)-2);
y1d = int(random(2)-1);
y2d = int(random(2)-1);

box5X += x1d;
box5Y += y1d;
box5Width += x2d;
box5Height += y2d;

image(greenman5,box5X,box5Y,box5Width,box5Height);
}

Tags: , , , ,

Leave a Reply