I need to randomly generate colors for multiple items in a to do list.
(like pick up the kids from school, pick up the dry cleaning and so on)
What’s the best way of doing this in ruby and also avoid colors that would be hard to see (like grey, white, and so on)?
Using RGB you will have harder times avoiding gray colors, as well as colors “difficult to see” (I’m guessing on a white background)
If you need them to be random, you can use HSV values to stay away from the white, gray and black spectra. That means you set a range in the value and saturation parameters (for example, ~175 to 255) while hue can be selected freely at random.
So, this may work:
where
is ported from here and the explanation can be found on the same Wikipedia article
However, if you additionally need to have random colors different from each other, perhaps the really true solution is to have them selected from a group of base colors, and select at random from that set.