Special 6
in
Share your Work
•
3 years ago
Harukit's particle sketch is one of the awesome pieces of Processing code I have come across the internet. I have used and remixed it several times in my sketches.
I would like to see what others can create with it.
The original code was designed with pre-alpha builds of processing but after a few tweaks it works. Here is the original location but I will post the modified code
See what you can create with it and post youtube or vimeo videos, flickr pictures or even post the code. More specifically, what methods can be used to speed the sketch up as the size sketch increases the framerate drops because the code cycles through each pixel regardless of its contents.
http://www.harukit.com/process/sp/applet/index.html
http://www.harukit.com/process/sp/applet/sp.pde
Updated code
I would like to see what others can create with it.
The original code was designed with pre-alpha builds of processing but after a few tweaks it works. Here is the original location but I will post the modified code
See what you can create with it and post youtube or vimeo videos, flickr pictures or even post the code. More specifically, what methods can be used to speed the sketch up as the size sketch increases the framerate drops because the code cycles through each pixel regardless of its contents.
http://www.harukit.com/process/sp/applet/index.html
http://www.harukit.com/process/sp/applet/sp.pde
Updated code
- // Shining Particle by harukit
// Created with Processing 68 alpha on September 11 , 2004
// http://www.harukit.com
int pNum =4;
Particle[] p = new Particle[pNum];
float rr,gg,bb,dis;
int gain = 5;
float[] cc = new float[3];
void setup(){
size(200,200,P3D);
loadPixels();
noStroke();
background(0);
for(int i=0;i<3;i++){
cc[i]=random(40)+random(40)+random(40)+random(40)+random(40);
}
for(int i=0;i<pNum;i++){
p[i] = new Particle(random(width),random(height),random(0.1,0.3));
}
}
void draw(){
for(int i=0;i<pNum;i++){
p[i].update();
}
for(int y=0;y<height;y++){
for(int x=0;x<width;x++){
int pos=y*width+x;
color col = pixels[pos];
rr = col >> 16 & 0xff;
gg = col >> 8 & 0xff;
bb = col & 0xff;
for(int i=0;i<pNum;i++){
dis =dist(p[i].xpos,p[i].ypos,x,y)/2;
rr += cc[0]/dis-gain;
gg += cc[1]/dis-gain;
bb += cc[2]/dis-gain;
}
pixels[pos]=color(rr,gg,bb);
}
}
}
void mousePressed(){
// background(0);
Particle[] p = new Particle[pNum];
}
void mouseReleased(){
for(int i=0;i<3;i++){
cc[i]=random(40)+random(40)+random(40)+random(40)+random(40);
}
// background(0);
for(int i=0;i<pNum;i++){
p[i] = new Particle(random(width),random(height),random(0.1,0.3));
}
}
class Particle{
float xpos,ypos,del;
Particle(float x,float y,float d){
xpos=x;
ypos=y;
del = d;
}
void update(){
xpos += (mouseX-xpos)*del;
ypos += (mouseY-ypos)*del;
}
}