We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Exploding Text (Read 1456 times)
Exploding Text
Jan 21st, 2008, 1:39pm
 
Hello!

I'm trying to make an exploding text. Right now i attach a single letter to a growing ellipse, in the moment the ellipse is "touching" the letter. The effect looks nice, but it looks not very natural. My code:

 for(int i=0; i < headline_new.length(); i++) {


   myPosX[i] = count*cos(TWO_PI/headline_new.length()*i); // Kreis erstellen
   myPosY[i] = count*sin(TWO_PI/headline_new.length()*i);
   noFill();

   
   stroke(#b8bddd);

   if(dist(width/2, height/2, width/2-(headline_new.length()/2)*10+i*10, height/2) == count) { // Wenn der Buchstabe auf dem Kreis liegt...
   letters_status[i] = true;
   }
   
   if (letters_status[i] == true) { // Text an den Kreis heften
   pushMatrix();
   translate(myPosX[i]+width/2, myPosY[i]+height/2);
   fill(#b8bddd, random(30,100));
   text(letters_new[i], random(0,2), random(0,2));
   popMatrix();
   }
   
   else { // Text stehen lassen
   pushMatrix();
   translate(width/2-(headline_new.length()/2)*10+i*10, height/2);
   fill(#b8bddd, random(30,100));
   text(letters_new[i], random(0,2), random(0,2));
   popMatrix();
   }}
 
 count = count + 0.25f; // Counter hochzählen
 if (count >= 600) {
   count = 1;
 }

Anyone got a better solution for this problem?

Greets
Re: Exploding Text
Reply #1 - Jan 21st, 2008, 2:46pm
 
can you post your full code, or give a link to the sketch online?
Re: Exploding Text
Reply #2 - Jan 21st, 2008, 3:20pm
 
The sketch seems not to run online, so here's the full code:

String headline_new = "Es gibt etwas zu Essen!";
String letters_new[] = new String[500]; // Array fŸr die Buchstabenkette

PFont fontRegular;
float count = 1; //Counter anlegen

boolean letters_status[] = new boolean[500];

float [] myPosX = new float[500]; //Array fŸr die Position der Buchstaben
float [] myPosY = new float[500];

void setup() {  

   size(600, 400);  // Grš§e festlegen, Vollbild

   fontRegular = createFont("Monaco", 16); // RegulŠre Schrift Festlegen, Monospace
   textFont(fontRegular);
   smooth();
   
   headline_new = headline_new.toUpperCase();
   for(int i=0; i < headline_new.length(); i++) {
   letters_new[i] = headline_new.substring(i,i+1);
 }
}  

void draw() {
 background(#364d76);

 for(int i=0; i < headline_new.length(); i++) {


   myPosX[i] = count*cos(TWO_PI/headline_new.length()*i); // Kreis erstellen
   myPosY[i] = count*sin(TWO_PI/headline_new.length()*i);
   noFill();

   
   stroke(#b8bddd);

   if(dist(400, 200, 400-(headline_new.length()/2)*10+i*10, 200) == count) { // Wenn der Buchstabe auf dem Kreis liegt...
   letters_status[i] = true;
   }
   
   if (letters_status[i] == true) { // Text an den Kreis heften
   pushMatrix();
   translate(myPosX[i]+400, myPosY[i]+200);
   fill(#b8bddd, random(30,100));
   text(letters_new[i], random(0,2), random(0,2));
   popMatrix();
   }
   
   else { // Text stehen lassen
   pushMatrix();
   translate(400-(headline_new.length()/2)*10+i*10, 200);
   fill(#b8bddd, random(30,100));
   text(letters_new[i], random(0,2), random(0,2));
   popMatrix();
   }}
 
 count = count + 0.25f; // Counter hochzŠhlen
 if (count >= 600) {
   count = 1;
 }
}
Re: Exploding Text
Reply #3 - Jan 21st, 2008, 3:22pm
 
http://playground-berlin.com/fhp/explosion/

Here's the link. Needed to refresh my browser..

Greets
Re: Exploding Text
Reply #4 - Jan 22nd, 2008, 10:03pm
 
You might want to use particles. Physics http://www.cs.princeton.edu/~traer/physics/ is quite a cool library. I used it to make words contract and expand.

I posted an example at http://vimeo.com/627948. I guess it's very well possible to have movement that's more like an explosion.
Re: Exploding Text
Reply #5 - Jan 22nd, 2008, 10:45pm
 
I'll give this libary a try!

Unfortunately i'm not permitted to view your video. Seems to be private...

Greets
Re: Exploding Text
Reply #6 - Jan 23rd, 2008, 7:49am
 
The video should be public now.

Just a few words, in case you might wonder. There are a number of fixed particles at the positions where the letters come together in the center. All the other particles are non-fixed and each has an attraction to one of the fixed ones. Depending on the mode, they move towards the center (contract) or away (expand). The letters are then rendered at the positions of the (non-fixed) particles.

Cheers
Nadja
Re: Exploding Text
Reply #7 - Jan 24th, 2008, 12:56pm
 
Yeah, the Traer physics library and particles is the way to go. I've also been playing with this to explode simple dots, but the dots are just being drawn where the invisible/mathematic/theoretical particles are. What I mean by that is that the Traer engine sets up the dynamics, it's up to you to draw what you like in the locations it spits out.

See here for an example: http://www.polaine.com/playpen/2007/12/26/20000-processing-particles/

Link to the code is here: http://www.polaine.com/playpen/wp-content/processing/_2000_particles/applet/
Re: Exploding Text
Reply #8 - Jan 24th, 2008, 2:50pm
 
thanks for your replies. i played around with traer.physics a bit, and i seem got get the results i wanted. yeah!

greets from berlin
Re: Exploding Text
Reply #9 - Jan 24th, 2008, 4:42pm
 
Good stuff. Don't forget to post a link to it to show what you've done (if you're okay with that)!
Page Index Toggle Pages: 1