Assigning int variable to part of a variable name
in
Programming Questions
•
2 years ago
Hi all,
I have a series of colors defined eg:
color c_0 = color(255,255,255);
...
color c_5 = color(180,60,60);
Then I have an int which cycles through 0-6 based on some buttons...
What I want to do is assign the int "styleIndex" to the second part of the color variable (after the underscore)
ie.
fill(color(c_styleIndex));
but am obviously getting errors (cannot find symbol).
What is the proper syntax to achieve this?
Do I use brackets, ticks, $ sign ??/
I guess I could probably use an Array instead, but im kind of curious on this now...
thanks.
1