processing. particles
i know i'm about 5 years behind everyone else, but it seems like everyone is playing with particle systems but me and then of course you see all of the cool things that people like robert hodgin and karsten schmidt are doing.at first i simply tried using the traer physics library for processing, but i couldn't get it to do what i wanted. then i started digging for code in the forums and eventually just modified daniel shiffman's simple particle system i simplified it so that i could learn what was going on.
particle
the result is a very simple implementation using pixel brightness from an image to determine point size, as the particles move (fall) on the screen. their x and y coordinates are mapped to the image and the size changes accordingly.
grab the source code sparticle_0_2_5
boidicle
i added some boid functionality to it as well, i can't remember where i found it exactly, but i believe it was in the forums, i modified it a little bit as well.
grab the source code sparticle_0_3_5
now that i've gotten my toes wet, i just need to learn more about creating my own particle class and implementing it.
color palettes
on a somewhat related note, one thing i use a lot is a color palette loading class. i wrote the code myself, but admittedly i borrowed the idea from david wicks after we worked on a project together. here's the source code for my palette loading class, you can use the colors of an image as the colors in your sketch.
class Palette {
//-----------------------------------------------------------------------------
//properties
//-----------------------------------------------------------------------------
PImage bild;
color[] farbe;
int loc;
//-----------------------------------------------------------------------------
//constructor
//-----------------------------------------------------------------------------
Palette(String pfad) {
bild = loadImage(pfad);
farbe = new color[bild.width*bild.height];
int index = 0;
for (int i=0; i<bild.width; i++) {
for (int j=0; j<bild.height; j++) {
//-----------------------------------------------------------------------------
//get the color and location of images pixels
//-----------------------------------------------------------------------------
loc = i + j*bild.width;
farbe[index] = bild.pixels[loc];
index++;
}
}
}
//-----------------------------------------------------------------------------
//gets
//-----------------------------------------------------------------------------
color[] getFarben() {
return farbe;
}
color getFarbe(int w) {
return farbe[w];
}
int getFarbeZahl() {
return farbe.length;
}
color getFarbeTrans(int w, float wert) {
float r = red(farbe[w]);
float g = green(farbe[w]);
float b = blue(farbe[w]);
color farbeTrans = color(r,g,b, 255*wert);
return farbeTrans;
}
}
//-----------------------------------------------------------------------------
//properties
//-----------------------------------------------------------------------------
PImage bild;
color[] farbe;
int loc;
//-----------------------------------------------------------------------------
//constructor
//-----------------------------------------------------------------------------
Palette(String pfad) {
bild = loadImage(pfad);
farbe = new color[bild.width*bild.height];
int index = 0;
for (int i=0; i<bild.width; i++) {
for (int j=0; j<bild.height; j++) {
//-----------------------------------------------------------------------------
//get the color and location of images pixels
//-----------------------------------------------------------------------------
loc = i + j*bild.width;
farbe[index] = bild.pixels[loc];
index++;
}
}
}
//-----------------------------------------------------------------------------
//gets
//-----------------------------------------------------------------------------
color[] getFarben() {
return farbe;
}
color getFarbe(int w) {
return farbe[w];
}
int getFarbeZahl() {
return farbe.length;
}
color getFarbeTrans(int w, float wert) {
float r = red(farbe[w]);
float g = green(farbe[w]);
float b = blue(farbe[w]);
color farbeTrans = color(r,g,b, 255*wert);
return farbeTrans;
}
}
Labels: processing