Reputation: 11393
I have set of categories (the number of which changes according to specific state) each of which I need to assign a unique color.
I have tried using random colors but they look bad, so I need a method of generating random colors which suit each other.
Upvotes: 6
Views: 2204
Reputation: 4131
Easiest thing on earth:
Use the HSV color model (http://en.wikipedia.org/wiki/HSL_and_HSV) and just change one of the parameters (Hue) to have a nice colour transitions.
Upvotes: 2
Reputation: 542
A trick I use in similar situations is to generate three random intensity values, then use these three values in six possible RGB combinations to generate a palette of colors having constant intensity and uniform contrast.
Example using three intensity values 33, 88, and aa.
<div style='background-color: #3388aa;'>Color 1</div>
<div style='background-color: #33aa88;'>Color 2</div>
<div style='background-color: #aa8833;'>Color 3</div>
<div style='background-color: #aa3388;'>Color 4</div>
<div style='background-color: #8833aa;'>Color 5</div>
<div style='background-color: #88aa33;'>Color 6</div>
Upvotes: 1
Reputation: 10327
You should look in to colour theory and complementary colours; this will give you colours which work well together.
Have a look at Color Scheme Designer. Use the tetrad mode to see how you can combine 4 colours and different shades to give a number of distinct areas in the image.
Here is a colour shades chart and some examples which may help you.
Upvotes: 7
Reputation: 2571
You will have to figfure out an algorithm using a colorpicker from the web and see what happens when you change the RGB-values with a fixed amount. If you can find that (for example: add 10 to the R-value and if the end is reached add 10 to the G value and reset the R-value), you can dynamicaly make a list for yourself.
Second option is that when you know you have an ultimate maximum of categories, you can create a list and use that.
Upvotes: 1
Reputation: 9936
Why not create a list of colours that you think would suit each other (like the basic Red, Green, Blue, Yellow, Orange etc.) and simply pick random colours off the list, safe in the knowledge that no matter what colours are picked, they will all look reasonably good together?
Upvotes: 3
Reputation: 4317
To expand on the earlier answer, you could use a service such as http://www.colr.org/ (which creates colour schemes from images) to create colour schemes that are guaranteed "non-strange", then pick a random colour from that scheme.
Upvotes: 3