ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Converting float to hexidecimal

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Kevin Burke
Converting float to hexidecimal
on Aug 6, 2012 at 12:50:47 am

I'd like to set the source text of a Text Layer to the Hex value of a color control. The following code seems right, but the text field only reads zero. If I set the value to the var color without converting, I get a long float such as 0.86274516582489. Please help! Thank you!

var color = thisComp.layer("ColorPicker").effect("Color Control")("Color")[0];

Return to posts index

Kevin Burke
Re: Converting float to hexidecimal
on Aug 6, 2012 at 2:56:55 am

I found a solution - not sure if it's the best, but it works!

target = thisComp.layer("Colors Screen");
colorpicker = thisComp.layer("ColorPicker");
sampledColor_8bpc = 255* target.sampleImage(target.fromWorld(colorpicker.position), [0.5,0.5], true, time);
R = Math.round(sampledColor_8bpc[0]);
G = Math.round(sampledColor_8bpc[1]);
B = Math.round(sampledColor_8bpc[2]);

outputString = "#" +R.toString(16) + G.toString(16) + B.toString(16);

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved