Tuesday, February 02, 2010
Green plastic wrap automatically
float r = 50;
int x;
int y;
float dx = 0;
float dy = 0;
float[] invisimap_x;
float[] invisimap_y;
void setup() {
size(800, 400);
background(255);
smooth();
noStroke();
x = width/2;
y = height/2;
invisimap_x = new float[width*height];
invisimap_y = new float[width*height];
for(int i = 0 ; i < width; i++) {
for(int j = 0 ; j < height; j++) {
invisimap_x[height*i+j] = random(-5,5);
invisimap_y[height*i+j] = random(-5,5);
}
}
}
void draw() {
fill(0, random(100, 255), 0, 50);
pushMatrix();
float w = x;
float h = y;
translate(w, h);
//r = pow(sqrt(sq(w-width/2)+sq(h-height/2)), 5/6.0);
quad(random(-r,r), random(-r,r), random(-r,r), random(-r,r),
random(-r,r), random(-r,r), random(-r,r), random(-r,r));
popMatrix();
x += dx;
y += dy;
if (x >= width) {
x = width-1;
dx = -dx;
}
else if (x < 0) {
x = 0;
dx = -dx;
}
if(y >= height) {
y = height-1;
dy = -dy;
}
else if (y < 0) {
y = 0;
dy = -dy;
}
dx += random(-5,5);
dy += random(-5,5);
}
int x;
int y;
float dx = 0;
float dy = 0;
float[] invisimap_x;
float[] invisimap_y;
void setup() {
size(800, 400);
background(255);
smooth();
noStroke();
x = width/2;
y = height/2;
invisimap_x = new float[width*height];
invisimap_y = new float[width*height];
for(int i = 0 ; i < width; i++) {
for(int j = 0 ; j < height; j++) {
invisimap_x[height*i+j] = random(-5,5);
invisimap_y[height*i+j] = random(-5,5);
}
}
}
void draw() {
fill(0, random(100, 255), 0, 50);
pushMatrix();
float w = x;
float h = y;
translate(w, h);
//r = pow(sqrt(sq(w-width/2)+sq(h-height/2)), 5/6.0);
quad(random(-r,r), random(-r,r), random(-r,r), random(-r,r),
random(-r,r), random(-r,r), random(-r,r), random(-r,r));
popMatrix();
x += dx;
y += dy;
if (x >= width) {
x = width-1;
dx = -dx;
}
else if (x < 0) {
x = 0;
dx = -dx;
}
if(y >= height) {
y = height-1;
dy = -dy;
}
else if (y < 0) {
y = 0;
dy = -dy;
}
dx += random(-5,5);
dy += random(-5,5);
}
comments

Add a comment: