Skip to main content
Lazlo_Hollyfeld
Inspiring
August 18, 2013
Answered

Possible to supply a hex value to solid's color property?

  • August 18, 2013
  • 1 reply
  • 6174 views

I know the AE Scripting Guide specifies that we have to supply an array of RGB values if we wish to change a solid's color property.  I'm just curious if it is possible to supply a hex value in lieu of an RGB array.  Does anybody have any experience with a work around?

Thanks!

This topic has been closed for replies.
Correct answer Dan Ebberts

The conversion is easy enough:

function hexToColor(theHex){

  var r = theHex >> 16;

  var g = (theHex & 0x00ff00) >> 8;

  var b = theHex & 0xff;

  return [r/255,g/255,b/255];

}

Dan

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
August 18, 2013

The conversion is easy enough:

function hexToColor(theHex){

  var r = theHex >> 16;

  var g = (theHex & 0x00ff00) >> 8;

  var b = theHex & 0xff;

  return [r/255,g/255,b/255];

}

Dan

Lazlo_Hollyfeld
Inspiring
August 18, 2013

Hey Dan thanks so much for your expertise and time!  This is really helpful.  I really appreciate it!