EDP Particle System

This Processing Sketch is a particle system that uses ArrayList and PVector to trace text with particles. It develops slowly over time in to the Emergent Digital Practices logo. This sketch was made specifically for a vertical 1920×1080 size monitor for the Emergent Digital Practices offices at the University of Denver. The images below show what the sketch looks like from start to finish. I have also uploaded a video so you can see the sketch in action!

Also included below the images is the code. It is an open source code developed by me.

Processingsketch1

Processingsketch2

Processingsketch23

//Chadwick Friedman**
// Self generating particle system that uses ArrayList and PVector//**
ArrayList<Particle> particles; //stores a variable number of objects (items easily added or removed and rezised dynamically)*
int[] list;
PVector axis; //sets location for particles to generate
int distance; //sets distance from each particle determining connection
PFont font; //sets font
int count, max; //maximum number of particles
char Key1 = ‘e’;
char Key2 = ‘d’;
char Key3 = ‘p’;
char Key4 = ‘*’;
char Key5 = ‘*’;

void setup() {
colorMode(RGB,255,255,255);
size(1920,1080);
background(255);
strokeCap(SQUARE);
frameRate(20);
stroke(10);
strokeWeight(0.25); // thickness of particles
distance = 50; //distance between particles
particles=new ArrayList<Particle>();
count=0; //sets range
max=800;

font = createFont(“hurtmold-48.otf”,770); //sets font & font size
textFont(font);
fill(0);
textAlign(CENTER,CENTER);
pushMatrix();
translate(490,825);
rotate(-HALF_PI);
text(Key1,0,0);
popMatrix();
pushMatrix();
translate(width/2-140, height/2);
rotate(-HALF_PI);
// For centered text use: text(Key1, 100, height/2-60);
text(Key2, 0,0);
popMatrix();//text(Key2, width/2, height/2-60);
pushMatrix();
translate(1160,220); //150
rotate(-HALF_PI);
text(Key3,0,0); //text(Key3, 490, height/2-60);
popMatrix();

text(Key4,300,825); text(Key4,365,500); text(Key4,890,190);text(Key4,290,125); text(Key4,140,325);
text(Key4,160,625); text(Key4,490,325); text(Key4,650,115);text(Key4,970,925); text(Key4,100,925);
text(Key4,970,925);text(Key4,1170,805);text(Key4,1350,925);text(Key4,1295,605);text(Key4,1560,745);
text(Key4,1580,155); text(Key4,1770,325);text(Key4,1700,555);text(Key4,1770,925);text(Key4,1790,80);

// Iterates through ArrayList and gets each Particle
// The ArrayList also keeps track of the total number of particles.
list = new int[width*height]; //sets area for particles to trace font
loadPixels();
for(int y = 0; y<=height-1; y++){
for(int x = 0; x<=width-1; x++){
color pb = pixels[y*width+x];
if(red(pb)<5){ list[y*width+x]=0; }
else { list[y*width+x]=1; }}}
updatePixels();
}

void draw() { // creates the particle chain // change background, stroke, fill **
if(count<max){
int i=0;
while(i<3){
axis = new PVector(int(random(50,width)),int(random(50,height))); //axis location

if(list[int(axis.y*width+axis.x)]==0 && list[int(axis.y*width+axis.x+1)]==0 &&
list[int(axis.y*width+axis.x-1)]==0 && list[int((axis.y+1)*width+axis.x)]==0 &&
list[int((axis.y+1)*width+axis.x)]==0){
particles.add(new Particle(axis.x,axis.y)); // A new Particle object is added to the ArrayList every cycle through draw().
i++;
count++;
}
}
}

background(0);

//stroke(130,random(160),120,900); //color of particles
stroke(255);

for (int i = 0; i < particles.size(); i++) { //generates particles from class
Particle p=particles.get(i);
p.update();
for(int j=i+1;j<particles.size();j++){
Particle pp=particles.get(j);
if (dist(p.location.x , p.location.y , pp.location.x , pp.location.y) < distance) {
line(p.location.x , p.location.y , pp.location.x , pp.location.y);
}
}
}
}

class Particle { //controls particle actions/reactions
PVector location;
PVector velocity;
Particle(float x, float y) { //function for location and speed
location = new PVector(x,y); //particle location
velocity = new PVector(random(1),1); //speed of particles // leaving out (random) in second variable adds ‘growing’ effect
}

void update() { //constantly updates particles
location.add(velocity);
if ((list[int(location.y)*width+int(location.x+velocity.x)]==1) || (list[int(location.y)*width+int(location.x-velocity.x)]==1)) { velocity.x *= -1; }
if ((list[int(location.y+velocity.y)*width+int(location.x)]==1) || (list[int(location.y-velocity.y)*width+int(location.x)]==1)) { velocity.y *= -1; }
}
}