Name: Anonymous 2010-01-23 10:31
Screenshot http://img706.imageshack.us/img706/4900/partysquares.png
Processing Dev. Env. http://processing.org/download/
Makes eye candy with ease (2D, 3D, OpenGL) and is fun to use. Tons of examples included with the IDE download. Downside is that it is Java based (double processing time?). In my example you can test how much it can handle at once by changing
Processing Dev. Env. http://processing.org/download/
Makes eye candy with ease (2D, 3D, OpenGL) and is fun to use. Tons of examples included with the IDE download. Downside is that it is Java based (double processing time?). In my example you can test how much it can handle at once by changing
int squares to a higher value.
RandSquare[] square;
float factor = 1.5; //modify this to change the window size.
int squares = 300;
int size_scale = int(400 * factor);
float len_max = 60 * factor;
float len_min = 20 * factor;
float pos = len_max/2 * factor;
float speed = 2 * factor;
float r, b, g, t = 0;
float freq = .001;
float amp_shift = 0;
float amplitude = 255/4;
float r_phase = random(2*3.1415);
float g_phase = random(2*3.1415);
float b_phase = random(2*3.1415);
void setup() {
size(size_scale, size_scale);
square = new RandSquare[squares];
for(int i = 0; i < squares; i++) {
square[i] = new RandSquare(color(random(255), random(255), random(255), random(255)), random(width), random(height), random(-speed, speed), random(-speed, speed), random(len_min, len_max));
}
}
void draw() {
bgshift();
background(r, b, g);
for(int i = 0; i < squares; i++) {
square[i].move();
square[i].display();
}
}
void bgshift() {
t += freq;
if(t % (2 * 3.141) == 0) {
t = 0;
}
r = amplitude * sin(t*r_phase) + amp_shift;
b = amplitude * sin(t*b_phase) + amp_shift;
g = amplitude * sin(t*g_phase) + amp_shift;
}
class RandSquare {
color c;
float xpos;
float ypos;
float xspeed;
float yspeed;
float len;
RandSquare(color c_, float xpos_, float ypos_, float xspeed_, float yspeed_, float len_) {
c = c_;
xpos = xpos_;
ypos = ypos_;
xspeed = xspeed_;
yspeed = yspeed_;
len = len_;
}
void display() {
noStroke();
fill(c);
rectMode(CENTER);
rect(xpos, ypos, len, len);
}
void move() {
xpos = xpos + xspeed;
ypos = ypos + yspeed;
if((xpos > width + pos + 1) || (xpos < -pos - 1) || (ypos > height + pos + 1) || (ypos < -pos - 1)) {
reset();
}
}
void reset() {
int coin = int(random(4));
c = color(random(255), random(255), random(255), random(127,245));
len = random(len_min, len_max);
if (coin == 0) {
xpos = width + pos;
ypos = random(-pos, height + pos);
xspeed = random(-speed,0);
yspeed = random(-speed,speed);
}
else if (coin == 1) {
xpos = -pos;
ypos = random(-pos, height + pos);
xspeed = random(0,speed);
yspeed = random(-speed,speed);
}
else if (coin == 2) {
xpos = random(-pos, width + pos);
ypos = height + pos;
xspeed = random(-speed,speed);
yspeed = random(-speed,0);
}
else {
xpos = random(-pos, width + pos);
ypos = -pos;
xspeed = random(-speed,speed);
yspeed = random(0,speed);
}
}
}