Hello,
I’d like to split my text into Strings and to move the same Strings to new coordinates. First when I split the text I don’t manage to insert a line break, how should I proceed?
Thanks a lot in advance for your help.
Best,
L
PFont f;
String alphabet="ABCDEFGHIJKLMNOPQRSTUVWXYZ2019,.;:!?\n ";
String wordsList="FOLLY,WHAT,FOR,TO,IS,THE,WORD,ALL,GIVEN,IS,FROM,ALL,THAT,SEEING,THIS,SEE,GLIMPSE,NEED,SEEM,WHERE,OVER,AWAY,AFAR,AFAINT";
String []lines;
String message;
int posX = 20;
int posY = 50;
boolean [] drawWords = new boolean[wordsList.length()];
boolean drawText;
char upperCaseChar;
void setup() {
size(1080, 1600);
f = createFont("Arial", 25, true);
textFont(f);
lines = loadStrings("Beckett.txt"); //laden des zu analysierenden textes
message= join(lines, " ");
lines=split(message, ",");
//message = message.replaceAll(",", "");
}
void draw() {
background(0);
translate(100, 100);
smooth();
posX=-40;
posY=10;
float[] sortPositionsX = new float[wordsList.length()];
String [] words= split(message," ");
for (int i=0; i<words.length; i++) {
String word= words[i].toLowerCase();
int index = wordsList.indexOf(word);
if (index<0)index=0;
float m=map(mouseX, 50, width-50, 0, 1);
m= constrain(m, 0, 1);
float sortX = sortPositionsX[index];
float interX = lerp(posX, sortX, m);
float sortY =index*30+30;
float interY = lerp(posY, sortY, m);
posX+=textWidth(words[i])+10;
if (word.equals(",")) {
posY+=40;
}
textSize(40);
fill(255);
text(word, interX, interY);
}
}