ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Changing color lightness using expression.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Adam levine
Changing color lightness using expression.
on Sep 2, 2015 at 5:43:50 pm

Is there any way to change color lightness using a expression?


Return to posts index

Dan Ebberts
Re: Changing color lightness using expression.
on Sep 2, 2015 at 5:56:54 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



Return to posts index

Marko Task
Re: Changing color lightness using expression.
on May 23, 2016 at 8:33:20 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!


Return to posts index


Dan Ebberts
Re: Changing color lightness using expression.
on May 23, 2016 at 8:57:01 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



Return to posts index

Marko Task
Re: Changing color lightness using expression.
on May 23, 2016 at 9:02:54 pm

It's working. Thx a lot!


Return to posts index


Xavier Gomez
Re: Changing color lightness using expression.
on Sep 2, 2015 at 6:12:00 pm
Last Edited By Xavier Gomez on Sep 2, 2015 at 6:16:19 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 !!!


Return to posts index


Adam levine
Re: Changing color lightness using expression.
on Sep 2, 2015 at 6:24:40 pm
Last Edited By Adam levine on Sep 2, 2015 at 6:27:52 pm

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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]