Video Production Stack Exchange is a question and answer site for engineers, producers, editors, and enthusiasts spanning the fields of video, and media creation. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using After Effects expressions, I can create a color reference by pick-whipping a color control and the result is:

var rgb = rgbToHsl(effect("Color Control")("Color"));

But, I want to avoid using a color control, and simply instantiate a color through code:

var rgb = rgbToHsl([159,27,41,1]);

...but this doesn't seem to work. Is it possible?

share|improve this question

migrated from Nov 6 '13 at 18:08

This question came from our site for Graphic Design professionals, students, and enthusiasts.

up vote 2 down vote accepted

From what I'm reading, it looks like it may just be [R,G,B] where each value is a floating point number between 0 and 1. I'm looking in the Adobe After Effects Scripting Guide. Every method I can find that accepts a color value simply uses an array like that.

Update: While certain scripting methods take a 3 parameter RGB value, other expressions require RGBA or HSLA. In these cases, there will be a forth parameter for Alpha (ie, transparency) where 1 is fully opaque (a good default value) and 0 is fully transparent. If you get an error with one format, I suggest trying the other and if you get unexpected values, check if the input expects HSL or RGB.

share|improve this answer
I believe it needs an array of 4, so you'd need to include the alpha value as well. Thanks for answering. – itsmikem Nov 7 '13 at 19:27
@itsmikem - for rgbToHsl it does appear it takes a rgba value, so if you need the color in hsla, then you would want to do 4 values with the final being the alpha. If you just want an RGB color, it only uses 3, but I'm not sure if rgbToHsl will work with that. – AJ Henderson Nov 7 '13 at 19:52

Note: I'm new to this exchange, and I posted this to the graphic design exchange, but my question got migrated here. I thought it had been deleted, so I proceeded to post it on Creative Cow. I got a great answer there, and I'd like to give credit to Kevin Camp, who answered it perfectly:

your rgb values need to be in values 0-1 rather than 0-255. so if you want to stick with entering 0-255 values you just need to divide that array by 255...

var myColor = rgbToHsl([159,27,41,255]/255);

note, i did assume that you wante the alpha component to be full (255) not 1. if i guessed wrong, change the alpha back to 1.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.