Skip to main content
Participant
October 20, 2017
Answered

Expression that references fill color and adds or subtracts brightness?

  • October 20, 2017
  • 1 reply
  • 3193 views

Hey,

I'm looking to create an expression that I can add to my bevel "highlight color" and "shadow color" that will reference the fill of a layer and automatically make it brighter by a bit (for highlight) and a version to make it a bit darker (for shadow).

I'm assuming I can pickwhip the fill, and then add to that or subtract from it (I'm presuming some sort of array that references the color value?), but I'm not trained enough in expressions to do that.

Thanks!

This topic has been closed for replies.
Correct answer Dan Ebberts

It might be a little different, depending on how you have things set up, but it could be something like this for Highlight:

c = content("Rectangle 1").content("Fill 1").color;

hsl = rgbToHsl(c);

factor = 1.25; // 25% brighter

newL = Math.min(hsl[2]*factor,1);

hslToRgb([hsl[0],hsl[1],newL,hsl[3]])

and like this for Shadow:

c = content("Rectangle 1").content("Fill 1").color;

hsl = rgbToHsl(c);

factor = .75; // 25% darker

newL = Math.min(hsl[2]*factor,1);

hslToRgb([hsl[0],hsl[1],newL,hsl[3]])

Dan

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
October 20, 2017

It might be a little different, depending on how you have things set up, but it could be something like this for Highlight:

c = content("Rectangle 1").content("Fill 1").color;

hsl = rgbToHsl(c);

factor = 1.25; // 25% brighter

newL = Math.min(hsl[2]*factor,1);

hslToRgb([hsl[0],hsl[1],newL,hsl[3]])

and like this for Shadow:

c = content("Rectangle 1").content("Fill 1").color;

hsl = rgbToHsl(c);

factor = .75; // 25% darker

newL = Math.min(hsl[2]*factor,1);

hslToRgb([hsl[0],hsl[1],newL,hsl[3]])

Dan

Participant
October 20, 2017

Perfect, man! Exactly what I was looking for.

Thanks so much!