HI,
thanks so much for the quick reply.
As you see, I included both tips in the code below, and it basically works well for my purpose. But I'm still messing myself up in making any string fit screen.width.
I finally made an array, considering I will have many strings in the future.
textWidth (s[...]) works well returning an element's length value, but it accepts only one number between []. That forces me to choose one element of the three. In the code below you can read textWidth (s[2]) because element 2 is the longest string and guarantees the others to be fully displayed on screen although not fitting its width, as I prefer. Instead, I'd like textWidth (s[...]) to represent all the elements of the array so all strings can condense and expand according to their own length. Maybe an interation, but I couldn't code it well at the moment.
Could you give me a clue on this, please.
Thanks so much.
-
String [] s = { "ONE", "TWO-TWO", "THREE-THREE-THREE"}; //just example
int del = int (random (300,3000));
void setup () {
size (screen.width, screen.height);
}
void draw () {
background (0);
float base = textWidth (s[2]); //this is the key point
float sw = (screen.width-30)/base;
float altura = textAscent () + textDescent();
float sh = screen.height/altura*1.5;
int a = int (random (4));
switch(a) {
case 0:
scale (sw, sh);
fill (110,0,00);
text (s[0], 0, -3.0, width, height);
delay (del);
case 1:
scale (sw, sh);
fill (0,110,0);
text (s[1], 0, -3.0, width, height);
delay (del);
case 2:
scale (sw, sh);
fill (0,0,110);
text (s[2], 0, -3.0, width, height);
delay (del);
case 3:
text ("");
delay (del/2);
}
}