// display the message with animation String msg = "This is a test"; float t = 1.0; // parameter for animation float cx[] = new float[msg.length()]; float theta[] = new float[msg.length()]; float r[] = new float[msg.length()]; void setup() { size(600, 600); textSize(80); fill(0); textAlign(CENTER, CENTER); // first compute total width of characters float total = 0; for (int k=0; k < msg.length(); k++) { total += textWidth(msg.charAt(k)); } // now go back and record the center x-coordinates float x = width/2 - total/2; for (int k=0; k < msg.length(); k++) { cx[k] = x + 0.5 * textWidth(msg.charAt(k)); x += textWidth(msg.charAt(k)); } randomize(); } void randomize() { // let's pick some random parameters for animation for (int k=0; k < msg.length(); k++) { theta[k] = random(-2*TWO_PI, 2*TWO_PI); r[k] = random(100,300); } } void draw() { background(204); if (t > 0) { t -= 0.005; } else { t = 0; } // now start drawing the characters for (int k=0; k < msg.length(); k++) { pushMatrix(); translate(cx[k],height/2); rotate(t*theta[k]); translate(t*r[k], 0); text(msg.charAt(k), 0, 0); popMatrix(); } } // restart with same parameters void keyPressed() { t = 1.0; } void mouseClicked() { randomize(); t = 1.0; }