pick one of x number of colors randomly

I have 5 colors defined as colors and I want to pick one of them randomly. Although I thought this was simple it doesn't seem so (unless it really is...?). I defined the 5 colors. I tried storing them in an array list, randomly picking a number between 1-5 and then use that to get the index of the array list. Probably is... "color" isn't a type although it is constructed like a type (int, float, etc.). color myColor = color(255, 120, 5);

I've tried putting them in hashmaps which worked well and was making a function to get them out only you can't "return" a color from a function. color (or Color) getRandomColor() (for example) doesn't work.

Any suggestions for this simple exercise?

Tagged:

Answers

Sign In or Register to comment.