Function for creating color wheels

Some related resources:

ColorBrewer - Sets of colours designed to be maximally distinguishable for use on maps.

Escaping RGBland: Selecting Colors for Statistical Graphics - A technical report describing a set of algorithms for generating good (i.e. maximally distinguishable) colour sets in the hcl colour space.


It would be best to find colors maximally distant in a "perceptually uniform" colorspace, e.g. CIELAB (using Euclidean distance between L*, a*, b* coordinates as your distance metric) and then converting to the colorspace of your choice. Perceptual uniformity is achieved by tweaking the colorspace to approximate the non-linearities in the human visual system.


My first thought on this is "how to 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. Once you have a set of vectors that are maximized apart, 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!

Thinking about this problem more, it would be better to map the colors in a linear manner, 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, let us 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.