import traer.physics.*;
ParticleSystem physics;
Particle points;
Word w,w2,w3,w4;
PFont myFont;
void setup()
{
String[] fontList = PFont.list();
println(fontList);
size(600,600,P3D);
physics = new ParticleSystem(0,0.05); //jyuryoku bane
//w = new Word("Follow my words ! Follow my words ! Follow my words ! Follow my words ! Follow my words ! Follow my words ! Follow my words ! Follow my words ! Follow my words ! Follow my words ! Follow my words ! Follow my words ! Follow my words ! Follow my words ! Follow my words ! Follow my words ! Follow my words ! ",physics);
//w = new Word("Ah, dear Juliet, why art thou yet so fair?",physics);
w = new Word("?riaf os tey uoht tra yhw ,teiluJ raed , hA",physics);
frameRate(20);
background(0);
// myFont = createFont("ShelleyLTStd-Script",32);
textFont(myFont);
}
void draw()
{
fill(0,80);
rect(0,0,width,height);
// background(255);
w.update();
w.draw();
physics.tick();
}
import traer.physics.*;
class Word {
ParticleSystem physics;
Particle[] lettersParticules;
Spring[] lettersSpring;
String wordString;
//char[] charArray;
float xPos;
float yPos;
int nbLetters;
PFont font;
Word(String wstr,ParticleSystem ps) {
wordString = wstr;
nbLetters = wordString.length();
physics = ps;
// The font must be located in the sketch's
// "data" directory to load successfully
myFont = createFont("ShelleyLTStd-Script",30);
xPos = random(width);
yPos = random(height);
lettersParticules = new Particle[nbLetters];
lettersSpring = new Spring[nbLetters];
boolean firstTime=true;
for(int i=0;i<nbLetters;i++)
{
xPos = random(width);
yPos = random(height);
lettersParticules[i] = physics.makeParticle(10,xPos,yPos,0.0);
if(!firstTime)
{
lettersSpring[i] = physics.makeSpring( lettersParticules[i], lettersParticules[i-1], 1.2, 0.1, 10);
//physics.makeAttraction(lettersParticules[i] , lettersParticules[i-1], -200 , -100 );
}
else
{
firstTime=false;
}
}
lettersParticules[0].makeFixed();
}
void draw()
{
fill(200, 147, 188);
for(int i=0;i<nbLetters;i++)
{
textFont(myFont, 40+i/10.0);
text(wordString.charAt(nbLetters-i-1),lettersParticules[i].position().x(),lettersParticules[i].position().y());
}
}
void update()
{
for(int i=0;i<nbLetters;i++)
{
if(lettersParticules[i].position().y() > height)
{
lettersParticules[i].velocity().set(lettersParticules[i].velocity().x(),-abs(lettersParticules[i].velocity().y()),lettersParticules[i].velocity().z());
}
if(lettersParticules[i].position().x() > width)
{
lettersParticules[i].velocity().set(-abs(lettersParticules[i].velocity().x()),lettersParticules[i].velocity().y(),lettersParticules[i].velocity().z());
}
;
}
//lettersParticules[0].position().set( width-frameCount*2,height/2, 0);
lettersParticules[0].position().set(mouseX,mouseY, 0);
//lettersParticules[0].setX(mouseX);
//lettersParticules[0].setY(mouseY);
}
}
This design idea is from Shakespeare "Romeo and Juliet". The word will follow a cursor because it is finding Romeo. Since this is working progress, it would be modified, in terms of readability, speed, color and more complicated action & Graphic. Also, although letters is following a cursor in this case, it would be made more practical, like the projected letters on the ground are following real peoples' foots by using the code which is related to reaction on light.