tschiggi
YaBB Newbies
Offline
Posts: 40
Rotating single letters
Dec 28th , 2007, 3:26pm
Hello! After solving yesterday's problem of water ripples, a new one occured: I want the letters of a String to rotate and behave like a nice alphabet soup ;) I tried different ways. I've split the String with a CharAt command and played around with some rotate() and scale(), but the results are very bad. I found some interesting libaries, like traer.physics or NextText. But i was wondering if i can handle this problem without using any complicated libary?! Here's how i done it so far. Problem is that the letters are not flying away as a circle, but as kind of a helix. Heres the code: import processing.opengl.*; PFont fontRegular; String buchstaben[] = new String[500]; float count = 1; String flashWord; float [] myPosX = new float[500]; float [] myPosY = new float[500]; void setup() { size(1024,786,OPENGL); fontRegular = createFont("Monaco", 16); textFont(fontRegular); smooth(); flashWord = "Dietmar Bartsch hat einen Preis gewonnen!"; flashWord = flashWord.toUpperCase(); for(int i=0; i < flashWord.length(); i++) { buchstaben[i] = flashWord.substring(i,i+1); } } void draw() { background(#364d76); for(int i=0; i < flashWord.length(); i++) { noStroke(); fill(0); textAlign(CENTER); // text(buchstaben[i], width/2-150+i*10, height/2); myPosX[i] = count*cos(TWO_PI/flashWord.length()*i) + width/2-250+i*10; myPosY[i] = count*sin(TWO_PI/flashWord.length()*i) + height/2; if(i < 50) { pushMatrix(); translate(myPosX[i], myPosY[i]); fill(#b8bddd, random(30,100)); textAlign(CENTER); text(buchstaben[i], random(0,2), random(0,2)); popMatrix(); } if(i > 50 && i < 100) { pushMatrix(); translate(myPosX[i]-500, myPosY[i]+16); fill(#b8bddd, random(30,100)); textAlign(CENTER); text(buchstaben[i], random(0,2), random(0,2)); popMatrix(); } } count = count + 0.25f; if (count >= 600) { count = 1; } } I'm thankful for any advice or hint, greets