ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Convert color to number to emit in particular

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Emmanuel Roba
Convert color to number to emit in particular
on Aug 7, 2017 at 1:21:56 pm

I know alot about code but not enough to write the troubling problem i have. Anyway i need to use one number from the brightness of color given a point. so for instance i want to take one of the numbers here and use it in particular. Can you do that?


Return to posts index

Dan Ebberts
Re: Convert color to number to emit in particular
on Aug 7, 2017 at 5:01:12 pm

In expressions, color channel values are all normalized so that they are between 0.0 and 1.0. So the rgba array for your example would be: [156/255,0,0,1]. There is also a function, rgbToHsl() to convert rgba arrays to hsla. I don't know if that answers your question.

Dan



Return to posts index

Emmanuel Roba
Re: Convert color to number to emit in particular
on Aug 7, 2017 at 7:32:44 pm

what im trying to do is print out the saturation value to a slider
this is all i got
rgb = effect("Sample Image")("Sampled Color Output")
hsl = hslToRgb(rgb);
sat = effect("Slider Control")("Slider");
sat = hsl[0,1,0];


Return to posts index


Dan Ebberts
Re: Convert color to number to emit in particular
on Aug 7, 2017 at 7:47:11 pm

I'm not sure what's happening in the first line, but assuming it results in a color assigned to variable rgb, this should give you the (normalized) saturation value:

rgb = effect("Sample Image")("Sampled Color Output");
hsl = rgbToHsl(rgb);
s[1]


Dan



Return to posts index

Emmanuel Roba
Re: Convert color to number to emit in particular
on Aug 7, 2017 at 9:37:50 pm

the rgb that is pickwipped to the sample image script in after effects

what im getting is this


Return to posts index

Dan Ebberts
Re: Convert color to number to emit in particular
on Aug 7, 2017 at 10:09:46 pm

Sorry. Try it this way:

rgb = effect("Sample Image")("Sampled Color Output");
hsl = rgbToHsl(rgb);
hsl[1]



Return to posts index


Emmanuel Roba
Re: Convert color to number to emit in particular
on Aug 7, 2017 at 10:22:20 pm

thank you!!
but all im getting is it flipping from 1 and zero.
is it a way to get it from like 0 and 500?


Return to posts index

Dan Ebberts
Re: Convert color to number to emit in particular
on Aug 7, 2017 at 11:42:09 pm

It depends on what's being sampled, but this should do it:

rgb = effect("Sample Image")("Sampled Color Output");
hsl = rgbToHsl(rgb);
hsl[1]*500


Dan



Return to posts index

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