Hey this is great thanks very much for your time and input. The original creator got back to me with another version, both are great and really close to what i was looking for. I had one other question regarding the system. Currently on the new key pressed it refreshes the particle system. Is it possible for the text to reform out of the remnants of the old text, this is pretty hard to explain in words sorry. In the original program when the key is not being pressed the particles start to float away. I would like to implement it so that the particles reform the new word. The current version is perfectly fine for the presentation i'm just interested to see how it works. Thanks again for your help and could you please send me an email to the above address with your full name for referencing/credit.
This is what i have so far
- class Particle {
PVector or;
PVector loc;
PVector vel;
PVector acc;
float ms;
float distance;
Particle(PVector a, PVector v, PVector l, PVector o, float ms_) {
acc = a;
vel = v;
loc = l;
ms = ms_;
or = o;
}
void run() {
update();
render();
}
void update() {
vel.add(acc);
loc.add(vel);
acc = new PVector();
}
void render() {
stroke(0);
point(loc.x,loc.y);
}
void add_force(PVector force) {
force.div(ms);
vel.add(force);
}
float getMass() {
return ms;
}
PVector getLocation() {
return loc;
}
PVector getOrigin() {
return or;
}
PVector getVelocity() {
return vel;
}
void setLocation(PVector l){
loc = l;
}
void setAcceleration(PVector a){
acc = a;
}
}
ArrayList particles = new ArrayList();
PFont ff;
PImage ww;
String[] sentence = new String[3];
Particle prt;
PVector origin;
void setup()
{
size(800, 600,P3D);
ff = loadFont("trade.vlw");
sentence[0] = "Interactive";
sentence[1] = "Dynamic";
sentence[2] = "Typography";
}
void draw()
{
background(255);
//println(particles.size());
moveYa();
}
PImage crImage(String s)
{
PGraphics pg = createGraphics(800,160,JAVA2D);
pg.beginDraw();
pg.background(255);
pg.fill(250);
pg.textAlign(CENTER);
pg.textFont(ff, 32);
pg.text(s, 0, 0, 800, 160);
pg.endDraw();
PImage w = createImage(800,160,RGB);
copy(pg, 0, 0, 800, 160, 0, 0, 800, 160);
return w;
}
void scan()
{
particles.clear();
for(int x = 0; x < ww.width; x++) {
for(int y = 0; y < ww.height; y++) {
if(get(x,y) != -65794){
origin = new PVector(x, y+200, 0);
PVector a = new PVector();
PVector v = new PVector();
PVector l = new PVector(random(width), random(height) , 0);
particles.add(new Particle(a,v,l, origin, random(0.05f, 2.0f)));
}
}
}
}
void moveYa(){
if(particles.size() <= 0)
return;
for (int h = 0; h<particles.size()-1; h++){
prt = (Particle) particles.get(h);
prt.run();
PVector actualVel = prt.getVelocity();
PVector attrito = PVector.mult(actualVel,-0.05);
prt.add_force(attrito);
PVector origLoc = prt.getOrigin();
PVector diff = PVector.sub(origLoc,prt.getLocation());
diff.normalize();
float factor = 0.5f;
diff.mult(factor);
prt.setAcceleration(diff);
if(mousePressed) {
PVector mouseLoc = new PVector(mouseX, mouseY, 0);
PVector diff2 = PVector.sub(mouseLoc,prt.getLocation());
diff2.normalize();
float factor2 = 1.0f;
diff2.mult(factor2);
prt.setAcceleration(diff2);
}
}
}
void keyPressed()
{
if (key == 'a' || key == 'A')
{
ww = crImage(sentence[0]);
scan();
}
if (key == 'b' || key == 'B')
{
ww = crImage(sentence[1]);
scan();
}
if (key == 'c' || key == 'C')
{
ww = crImage(sentence[2]);
scan();
}
}