Activity › Forums › Adobe After Effects Expressions › Changing color lightness using expression.
-
Changing color lightness using expression.
Posted by Adam Levine on September 2, 2015 at 5:43 pmIs there any way to change color lightness using a expression?
Marko Task replied 10 years, 2 months ago 4 Members · 6 Replies -
6 Replies
-
Dan Ebberts
September 2, 2015 at 5:56 pmI 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 pmColors 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 pmThank you master Xavier. You are my saviour.. :). Thank you also master Dan for replying me..
-
Marko Task
May 23, 2016 at 8:33 pmHi 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 pmLike 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
Reply to this Discussion! Login or Sign Up