Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Fill colour linked to a specific number on a slider control.

  • Fill colour linked to a specific number on a slider control.

  • Ashley Aslett

    September 17, 2021 at 4:13 pm

    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){



    else if (s < 11){




    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!!



  • Dan Ebberts

    September 17, 2021 at 5:49 pm

    I’d do the part below the function like this:

    if (s < 0)




  • Ashley Aslett

    September 17, 2021 at 5:59 pm

    Dan you are an absolute life saver…works like a dream!

    Thanks so much for your speedy response, it is truly appreciated!

Viewing 1 - 3 of 3 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy