the first thing I want to do is wrap the text and the second thing is to make the color change of specific words, but I found it is hard to do. Please somebody can help me!!!
hi,
first you should try to copy your pasted code back to PDE
and see that it is not running.
that’s because you not pasted it using the
</> Preformatetd text
button from the forum editor menu, looks like
```
type or paste code here
```
also as we not have that file you load
we like to see a MCVE a code what runs without files need unless you provide them as external .zip
your code looks like you want a different color for each character not each word??
this would be a version what use colors words but still prints characters
( uselessly but just to show what heavy problem you have, if you try to do that character positioning manually )
String[] l = { "test1, test2, test3", "test11, test12, test13" };
String[] words;
String lot;
void setup() {
size(600, 600);
background(0);
//l = loadStrings("l.csv"); // not available
println("there are " + l.length + " lines");
print("l: ");
println(l);
lot = join(l, " ");
print("lot: ");
println(lot);
words = splitTokens( lot, ", ");
print("words: ");
println(words);
noLoop();
}
void draw() {
background(0, 0, 80);
textSize(20);
fill(0);
float x =10;
for (int i = 0; i < words.length; i++) {
fill(random(50, 255), random(50, 255), 0);
for ( int j = 0; j < words[i].length(); j++ ) {
char c = words[i].charAt(j);
x = x + textWidth(c);
text(c, x, 20);
}
x+=10; // between the words
}
}