tschiggi
YaBB Newbies
Offline
Posts: 40
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 fr die Buchstabenkette PFont fontRegular; float count = 1; //Counter anlegen boolean letters_status[] = new boolean[500]; float [] myPosX = new float[500]; //Array fr die Position der Buchstaben float [] myPosY = new float[500]; void setup() { size(600, 400); // Gr§e festlegen, Vollbild fontRegular = createFont("Monaco", 16); // Regulre 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 hochzhlen if (count >= 600) { count = 1; } }