For the cyclic cellular automaton I had to get a variable amount of colors around the color circle. This is how I solved that problem.I split the color wheel into 6 equal parts:
incr. means the color is increasing and decr. means the color is decreasing going counter clockwise around the circle.
The pseudo code to achieve this:
#get the i'th color, of n colors. color(i,n): r, g, b = 0 stepsize = floor((255*6)/n) progress = i*stepsize switch(floor(progress/255)) case 0: b = 255 r = progress%255 case 1: r = 255 b = progress%255 case 2: r = 255 g = progress%255 case 3: g = 255 r = progress%255 case 4: g = 255 b = progress%255 case 5: b = 255 g = progress%255 return r, g, b
RGB color wheel: https://commons.wikimedia.org/wiki/File:RGB_color_wheel_360.svg