Skip to main content
Participant
February 21, 2017
Question

RGB to HEX #ffaadd value to Text Layer

  • February 21, 2017
  • 1 reply
  • 2477 views

Hi, I am trying to write an expression that will spit out #HEX value to a text layer source.  The RGBA color will come from a fill color on a solid layer.

I cannot find anything to convert RGB to a HEX value only rgb to hsl.

Is this even possible through expression or extendscript?

This is what I have so far, which will spit out RGBA values from converting rgbtohsl and then back to hsltorgb*255

in_rgb = thisComp.layer("controller").effect("color_04")("Color");

in_hsl = rgbToHsl(in_rgb);

new_hue = (in_hsl[0] + 0) % 1;

new_sat = in_hsl[1] * ((thisComp.layer("color_04_tint").effect("saturation")("Slider")/100)+1);

new_lightness = in_hsl[2] * ((thisComp.layer("color_04_tint").effect("brightness")("Slider")/100)+1);

mod_hsl = [new_hue, new_sat, new_lightness, in_hsl[3]];

src = hslToRgb(mod_hsl) * 255;

Any help is appreciated.  Please feel free to email me, jchung@guidespark.com.

Joe

This topic has been closed for replies.

1 reply

Mylenium
Legend
February 22, 2017

You simply use the .toString(16) function, which will convert any input value to 16 bit hex.

Mylenium