Function for creating color wheels *

Question

This is something I've pseudo-solved many times and never quite found a solution that's stuck with me. The problem is to come up with a way to generate N colors, that are as distinguishable as possible where N is a parameter.

Answer

My first thought on this is "how generate N vectors in a space that maximize distance from each other." You can see that the RGB (or any other scale you use that forms a basis in color space) are just vectors. Take a look at Random Point Picking. Hope this is a good start for you! Once you have a set of vectors that are maximized a part, you can save them in a hash table or something for later, and just perform random rotations on them to get all the colors you desire that are maximally apart from each other!

Edit: Thinking about this problem more, it would be better to map the colors in a linear manor, possibly (0,0,0) --> (255,255,255) lexicographically, and then distribute them evenly. I really don't know how well this will work, but it should since, lets say:

n = 10 we know we have 16777216 colors (256^3). We can use buckles algorithm 515 to find the lexicographically indexed color.\frac {\binom {256^3} {3}} {n} * i. You'll probably have to edit the algorithm to avoid overflow and probably add some minor speed improvements.

< br > via < a class="StackLink" href=" http://stackoverflow.com/questions/180/" >Function for creating color wheels< /a>
Share on Google Plus

About Cinema Guy

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment