-
Fill colour linked to a specific number on a slider control.
Hi, new to the forum but wondering if anyone can please help with the below.
I am trying to control a fill colour on a layer to a specific number on a slider control. So if the number is on 0 the fill colour is dark grey, if it is on -10 the colour is red and if its on 10 it is green. I want the colour to transition through the shades from dark grey to either green or red and not just be a hard cut between the colours. Searching around the forums I found close expressions which I adapted to the below:
s = thisComp.layer(“CONTROLS”).effect(“Slider Control”)(“Slider”);
c1 = 0xdc2e2e; // Red
c2 = 0x222222 // Dark Grey
c3 = 0x0fb824 // Green
function hexToFloat(c){
r = ((c & 0xff0000) >> 16)/255;
g = ((c & 0xff00) >> 8)/255;
b = (c & 0xff)/255;
return [r,g,b,1];
}
if (s > -11){
ease(s,-1,-11,hexToFloat(c1),hexToFloat(c2));
}
else if (s < 11){
ease(s,0,10,hexToFloat(c2),hexToFloat(c3));
}
Going from 0 (dark gery) to -10 (red) works perfectly but when I go above 0 it just stays with the dark grey colour rather than transitioning into green.
Any help on the above would be super appreciated!!
Thanks