Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Converting float to hexidecimal

  • Converting float to hexidecimal

    Posted by Kevin Burke on August 6, 2012 at 12:50 am

    Hello,
    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];
    color.toString(16);

    Kevin Burke replied 13 years, 9 months ago 43,645 Members · 1 Reply
  • 1 Reply
  • Kevin Burke

    August 6, 2012 at 2:56 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);
    outputString;

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy