2

My problem is that I need for a graphical output of an algorithm a method to colorize all the objects I have. So I wrote this one here:

    int[] next_color = {0x70,0x00,0x00};
    private int max_co = 0xF0;
    private int next_c = 0x01;
    private int step = 0x10;
    public Color getNextColor(){
        next_color[next_c%3]%=max_co;
        next_color[(next_c++)%3]+=step;
        return new Color(next_color[0], next_color[1], next_color[2]);
    }

What I was thinking while writing this: I found out that colors under #707070 will appear mostly like black, so it does not make any sense to use them. Also I found out that only steps with greater than 0x10 are (really good) recognized by the eye. But now I have only red and some blue objects arround (when using small amounts of objects) - so it looks a little bit like crap. Is there a good way to generate a new color, which can be good differed from the previous and next one?

Peter O.
  • 32,158
  • 14
  • 82
  • 96
reox
  • 5,036
  • 11
  • 53
  • 98
  • possible duplicate of [Algorithm to randomly generate an aesthetically-pleasing color palette](http://stackoverflow.com/questions/43044/algorithm-to-randomly-generate-an-aesthetically-pleasing-color-palette) – Thilo Aug 29 '11 at 06:38
  • Note that the actual value from which something looks black depends on a lot of factors, not at least on the display used. Over here #303060 is still *clearly* distinguishable from black. – Joachim Sauer Aug 29 '11 at 06:39
  • 3
    How many different colors will you need, approximately? If it's a low number, then finding and hard-coding a pre-defined set of distinguishable colors might be a better approach. – Joachim Sauer Aug 29 '11 at 06:42
  • I don't think it's a duplicate of the linked-to question. Or, we don't know enough about the question yet to know if it's a duplicate. – Joachim Sauer Aug 29 '11 at 06:57
  • i really dont care about the color, i just need colors that can be differed really easy. so if its black and then white I'm fine :) – reox Aug 29 '11 at 07:35
  • http://en.wikipedia.org/wiki/Web_colors displays a number of different sets of colors - e.g. the 16 named HTML colors. If nothing else, it's a nice pallete with which to look at different colors and choose sets of them. – mcdowella Aug 29 '11 at 07:47
  • Don't forget that some people have problems with colour vision, red-green colourblind etc. You may want to allow alternative colour palettes and black/white as alternatives. – rossum Aug 29 '11 at 10:33

1 Answers1

1

HSV/HSL color geometries should be easier to use in such algorithms.

Mateusz Chromiński
  • 2,742
  • 4
  • 28
  • 45
  • ah yes thank you! Im just taking now the hue value and run it from 0 to 360 in steps of 23 and its working really good! – reox Aug 29 '11 at 07:47