One quick and easy solution is to just store an array of color values using the ID of the item. That assumes that you have a relatively low amount of colors, and you're certain that you won't go above a certain number of items, however.
One quick and easy solution is to just store an array of color values using the ID of the item. That assumes that you have a relatively low amount of colors, and you're certain that you won't go above a certain number of items, however. If you want to generate colors rather than use a list, one trick to make them have a consistent and decent look is to generate them using HSB.
Pre-define a brightness and saturation, then base the hue value off some function of the ID (this can be a variety of things depending on how many IDs you plan to have, but multiplying the ID by some amount (and modding when it exceeds 255! ) is a good rough approach. With this approach the colors will all "align" in terms of saturation and brightness but they'll each have a distinct color.
I'm a bit bored at work, so I whipped together a fast solution: class HsbColor { public int Hue { get; set; } public int Saturation { get; set; } public int Brightness { get; set; } public Color ToRGB { // left as exercise to the reader... } } public class Item { public int Id { get; set; } private static const byte EXPECTED_MAX = 15; private static int HUE_FACTOR = 255 / EXPECTED_MAX; public HsbColor Color { get { var color = new HsbColor() { Saturation = 175, Brightness = 175 }; color. Hue = (Id * HUE_FACTOR) % 255; return color; } } }.
See my answer for a way to avoid predicting the EXPECTED_MAX and still get an even distribution. – Patrick McElhaney Jul 23 '09 at 2:04.
You can multiply the id by the golden ratio (phi) to get a number 0 Hue = floor(n * 256).
3 martin.ankerl. Com/2009/12/09/… – ohadsc Dec 7 '10 at 22:03.
Graphic designers know that if a lot of colors are going to be used near each other in an information display, the colors should be relatively close to each other in color space. Small changes in saturation or hue are usually better than large jumps–when many colors are involved, the human eye actually finds it easier to assimilate information when color distances are not very great. Also, don't forget that some of your users will be color blind.
Since there are so many varieties of color blindness, it is hard to know what combinations to avoid. Maybe someone else can address this question?
Try having a look to Color Lists, NSColorList.
I have written an article about this same topic: How to Generate Random Colors Programmatically Basically you can use the HSV color space. When you know the number of colors you need, just split the range 0,1 by this. If you do not know the number of required colors, you can still use the golden ratio to select colors from this space.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.