• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Participant ,
Aug 18, 2013 Aug 18, 2013

Copy link to clipboard

Copied

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!

TOPICS
Scripting

Views

4.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Aug 18, 2013 Aug 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

Votes

Translate

Translate
Community Expert ,
Aug 18, 2013 Aug 18, 2013

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 18, 2013 Aug 18, 2013

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 19, 2013 Aug 19, 2013

Copy link to clipboard

Copied

Dan,

Just wanted to add that I didn't realize your function assumed the hex color value would be passed in as `0xFFFFFF`.  My data was passed in as a string such as `FFFFFF`.  To fix, I just added one line:

function hexToColor(theHex){

  theHex = parseInt(theHex,16);

 

  var r = theHex >> 16;

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

  var b = theHex & 0xff;

 

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

 

}

Thought this might help somebody who had the same data coming in question.  Thanks, again for the help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 24, 2013 Aug 24, 2013

Copy link to clipboard

Copied

It did help somebody thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 21, 2022 Jul 21, 2022

Copy link to clipboard

Copied

Very helpful thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 21, 2022 Jul 21, 2022

Copy link to clipboard

Copied

LATEST

AE now has a built-in, direct Expression method for hex to RGB conversion. More info here - 
https://ae-expressions.docsforadobe.dev/color-conversion.html

Motion Graphics Brand Guidelines & Motion Graphics Responsive Design Toolkits

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines