I’m not sure this is exactly what you’re after, but it should get you close. This defines a bunch of colors in an array (you could get them from color controls instead) and will transition between colors at layer markers:
// red yellow green cyan blue magenta
colors = [[1,0,0,1],[1,1,0,1],[0,1,0,1],[0,1,1,1],[0,0,1,1],[1,0,1,1]];
fadeDur = .5;
m = marker;
n = 0;
if (m.numKeys > 0){
n = m.nearestKey(time).index;
if (time < m.key(n).time) n--;
}
if (n == 0 || m.numKeys == 1){
colors[0];
}else if (n >= colors.length || n >= m.numKeys){
colors[colors.length-1];
}else{
t1 = m.key(n).time;
t2 = t1 + fadeDur;
v1 = colors[n-1];
v2 = colors[n];
linear(time,t1,t2,v1,v2);
}