.

The common color wheel has 12 colors. The primary colors Red Blue Green are evenly spaced, say at 12, 4, and 8 o’clock. The secondary colors are midway made of equal parts of their primary neighbors. 6 tertiary colors fill the remaining spaces with a half strength of the more distant primary color and a full strength of the nearer one. The only RGB values used in this 12 color wheel are 0, 127 and 255. I have represented those in the diagram as 0, 1, and 2. Every color on the wheel has only one or two constituent primary colors. In other words, every RGB value trio has at least one zero. Wheels with more than 12 colors can be generated by dividing the range 0 to 255 with more than just one intermediate value, but still the geometry of the wheel requires only two colors mixed in various proportions for each color panel. The 216 color web standard for instance uses RGB values of 0, 51, 102, 153, 204, and 255. But every RGB value has at least one zero. By plotting out the RGB values for wheels with 12, 18, 24, 30, 36 colors and more, we can see how the pattern works.

The list of values for the R component of the RGB trio for a 12 color wheel consists in order (5) values of 255, (1) 127, (5) 0, and 1 (127). The values for G and B are exactly the same, except they are shifted around the wheel. the shift is by 4 places. 12 colors with 3 constituents evenly spaced are shifted 4 spaces. 12/3 = 4 .

if we manually create a few color wheels with different numbers of colors, i suggest 12, 18, 24, 30, the patterns emerge. a program can be made to create a color wheel of any size. the key number is the number of colors on the wheel. everything else is derived from that. separate arrays for Red, Green and Blue components are created, but they are made from the same pattern and rotated or shifted so the loop creating the wheel lets each color in turn dominate. The shift number is numcolors/3.

The array of RGB values will cycle through 4 states, full on, decreasing, off, increasing. full on and off are the same length, increasing and decreasing are mirror images. For a 12 color wheel there are 5 full on values, 5 off values. That only leaves one intermediate value. thats a function of the number 12 not an arbitrary decision. 5 is derived as the shift number plus one. the shift number is derived from the number of colors. the increasing and decreasing segments are the number of colors divided by 6. If you pick colors in multiples of 6, my theory is it all works out. i have not extensively tested the whole thing. i have run a color wheel with over 1000 colors.

One thing to realize is that a standard color wheel cannot display every color. since it cannot display any color that uses non-zero values for all 3 RGB components. it can never show any gray, white or black. if we compare the 12 color wheel to the number of possible colors using 3 values in 3 positions, that number is 3*3*3 = 27. the 12 color wheel is showing less than half the possible colors available using a palette of 0, 127 and 255. An easy way to figure all possible color values for that limitation is to treat the RGB number like a base 3 number and just count starting at 000 and ending with 222

I will post the code here for the full autocad color wheel generator after i clean it up a bit. it is somewhat long and has a few parts. In the meantime, here is the data array generator which makes the basic RGB values array for one component with the only input being the number of colors to be generated on the wheel.

Sub make_data_array(ByRef data_array() As Integer, clrs As Integer) Dim i As Integer, ndx As Integer, n As Integer Dim A As Integer, B As Integer Dim c As Integer, d As Integer Dim e As Integer, f As Integer Dim g As Integer, h As Integer n = clrs / 6 ReDim data_array(1 To clrs) A = 1 B = clrs / 3 + 1 c = B + 1 d = c + clrs / 6 - 2 e = d + 1 f = e + clrs / 3 g = f + 1 h = clrs For i = A To B data_array(i) = 255 Debug.Print 255 Next For i = c To d 'ndx = retndx_desc(0, 255, n, i - c + 1) ndx = retndx(255, 0, n, i - c + 1) data_array(i) = ndx Debug.Print ndx Next For i = e To f data_array(i) = 0 Debug.Print 0 Next For i = g To h ndx = retndx(0, 255, n, i - g + 1) data_array(i) = ndx Debug.Print ndx Next End Sub Function retndx(A As Integer, B As Integer, n As Integer, ndx As Integer) As Integer 'n is number of spaces to divide the span AB 'ndx is the index of the value to be returned Dim dbl_n As Double dbl_n = (B - A) / n retndx = A + (ndx * dbl_n) End Function