I am new to Processing and need help with a problem. I need the code in draw not to be played completely over and over again, but frame by frame. The background should change his color according to the first char of my text and in the next frame the next color and so on. Is there any way to do so? Many thanks in advance for every answer!
String text = "hello world";
char chars[] = ("aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ").toCharArray();
void setup() {
size(600,360);
}
void draw() {
noStroke();
for(int i = 0; i < text.length(); i++) {
fill(map(letter(text.charAt(i)),0,chars.length,0,255));
rect(0,0,600,360);
}
}
int letter(char chr) {
int letter = -1;
for(int i = 0; i < chars.length; i++) {
if(chr == chars[i]) {
letter = i;
}
}
return letter;
}
Thanks for your reply. What do you mean by increasing i at the end of draw?
I already tried a lot with slowing down the frameRate but only bad results.