Hello,
My code writes lines to the screen after the previous one has left it. Is there a possibility to write the lines directly unter the other and not wait until one has left the screen, just like on a website?
I also want the text to be displayed in three different text sizes, which are randomly selected, but I can’t figure out how.
I hope somebody could help me out. Many thanks!
PFont font;
String [] lines;
int index = 0;
float y;
void setup() {
size(600,300);
font = createFont("BradfordLLTT-Regular.ttf", 20);
y= height;
}
void draw() {
background(255);
fill(0);
textFont(font);
textAlign(LEFT);
String everything;
everything = "Die kleine Mauer, die oben umher die Einfassung macht, die hohen Bäume, die den Platz rings umher bedecken, die Kühle des Orts; das hat alles so was Anzügliches, was Schauerliches. Es vergeht kein Tag, daß ich nicht eine Stunde da sitze. Da kommen die Mädchen aus der Stadt und holen Wasser, das harmloseste Geschäft und das nötigste, das ehemals die Töchter der Könige selbst verrichteten.";
lines = splitTokens(everything, ",.?!;:-–—");
text(lines[index], 10, y);
textSize(random(10,20));
y= y - 3;
float h = textWidth(lines[index]);
if (y < -h) {
y = height;
index = (index + 1) % lines.length;
}
}