Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Changing color lightness using expression.

  • Dan Ebberts

    September 2, 2015 at 5:56 pm

    I don’t know if this is what you’re after, but here’s an example that would change the lightness of a Fill effect color to 25% of its current value:

    f = .25; // lightness factor
    hsl = rgbToHsl(value);
    hslToRgb([hsl[0],hsl[1],hsl[2]*f,hsl[3]])

    Dan

  • Xavier Gomez

    September 2, 2015 at 6:12 pm

    Colors are in RGB format.
    You have to convert to HLS, lower the “L” then convert back to RGB.

    The problem is how much you want to lower.
    It can be by a flat amount, or by a percentage of the current value.

    amount = 0.2;
    c = value;// (or pickwhip a color property)
    // convert to HLS
    c = rgbToHsl(c);
    // lower the L
    c[1] = Math.max(0, c[1]-amount);
    // back to RGB
    hslToRgb(c);

    To lower by a certain percentage instead of a flat amount, replace the lowering part by:
    c[1] -= c[1]*amount;

    In both cases amount should be a number in the range [0,1].

    Xavier.

    Edit : A bit late, it doesnt bring more !!!

  • Adam Levine

    September 2, 2015 at 6:24 pm

    Thank you master Xavier. You are my saviour.. :). Thank you also master Dan for replying me..

  • Marko Task

    May 23, 2016 at 8:33 pm

    Hi Dan

    How to make this “change lightness” work, if I want to link to color control expression

    comp(“control”).layer(“control”).effect(“Color Control”)(“Color”)

    Thx!

  • Dan Ebberts

    May 23, 2016 at 8:57 pm

    Like this maybe:

    c = comp(“control”).layer(“control”).effect(“Color Control”)(“Color”).value;
    f = .25; // lightness factor
    hsl = rgbToHsl(c);
    hslToRgb([hsl[0],hsl[1],hsl[2]*f,hsl[3]])

    Dan

  • Marko Task

    May 23, 2016 at 9:02 pm

    It’s working. Thx a lot!

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