solved!!!
no, just kidding
I don’t have time, but I think what you have to do is skip all the split and join, because you want to work with the poem.
Now, since you want to work with single words, you want to have a 2nd for loop, going over the words within the current line of the poem and handle the word
Can’t do that but wish you luck.
Chrisir
//
PFont font;
String[]lines={
"folly",
"folly for to",
"for to",
"what is the word",
"folly from this",
"all this",
"folly from all this",
"given",
"folly given all this",
"seeing",
"folly seeing all this",
"this",
"what is the word",
"this this",
"this this here",
"all this this here",
"folly given all this",
"seeing",
"folly seeing all this this here",
"for to",
"what is the word",
"see",
"glimpse",
"seem to glimpse",
"need to seem to glimpse",
"folly for to need to seem to glimpse",
"what",
"what is the word",
"and where",
"folly for to need to seem to glimpse what where",
"where",
"what is the word",
"there",
"over there",
"away over there",
"afar",
"afar away over there",
"afaint",
"afaint afar away over there what",
"what",
"what is the word",
"seeing all this",
"all this this",
"all this this here",
"folly for to see what",
"glimpse",
"seem to glimpse",
"need to seem to glimpse",
"afaint afar away over there what",
"folly for to need to seem to glimpse afaint afar away over there what",
"what",
"what is the word",
"what is the word"
};
String wordsList;
//boolean drawLines = false;
//boolean drawText = true;
String[] lines2;
//********************************************************************************************************************************************************
void setup() {
size(1200, 1200);
font = createFont("helvetica", 20);
textFont(font);
/* for (int i = 0; i < lines.length; i++) {
lines[i]=lines[i]+"#";
}*/
//wordsList = join(lines, " ");
//lines= splitTokens(wordsList, " ");
lines2 = new String[lines.length];
for (int i = 0; i < lines.length; i++) {
lines[i] = lines[i].trim();
if (!lines[i].trim().equals(""))
lines2[i]=lines[i].trim();
}
java.util.Arrays.sort(lines2);
println("lines +++++++++++++++++++++++++++++++++++++++++++++++++");
printArray(lines);
println("lines2 +++++++++++++++++++++++++++++++++++++++++++++++++");
for (int i = 0; i < lines.length; i++) {
println( lines2[i]);
}
}
//********************************************************************************************************************************************************
void draw() {
background(0);
translate (40, 20);
smooth();
int posX = 0;
int posY = 20;
int lineDist= 20;
for (int j = 0; j < lines.length; j++) {
int index = givePosition(lines2, lines[j] );
if (index<0)
index=0;
float m=map(mouseX, 0, width, -0.2, 1.2);
m = constrain(m, 0, 1);
float sortY = index*lineDist+10;
float interY;
interY = lerp(posY, sortY, m);
fill(255, 200);
text(lines[j], posX, interY);
posY += lineDist;
posX = 0;
}
}
int givePosition( String[] list, String search ) {
for (int j = 0; j < list.length; j++) {
if (list[j].equals(search))
return j;
}//for
print("f");
return 0;
}
//