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!
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
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
Copy link to clipboard
Copied
Hey Dan thanks so much for your expertise and time! This is really helpful. I really appreciate it!
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.
Copy link to clipboard
Copied
It did help somebody thanks!
Copy link to clipboard
Copied
Very helpful thanks!
Copy link to clipboard
Copied
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