Hi Dan,
I have realised that the code works OK, but weirdly, it seems to be the system colorpicker that doesn’t work. If I make a test UI panel using the code below, it works fine, unless you use the magnifying glass element of the system colorpicker. If you enter the values manually into the RGB sliders it returns the correct result, but if you try to pick say the grey of the AE interface, it returns RGB values of (84,84,84) (for example), but then the decimal value that is returned is incorrect and so the RGB values my code end up being something like (62,62,62). Also, from that point on ALL colors entered are incorrect, unless I quit AE and start again. Do you get whats going on? Am I missing something really obvious?
Thanks in advance,
James
MY CODE:
{
var myPanel;
function Create_Null(thisObj)
{
myPanel = (thisObj instanceof Panel) ? thisObj : new Window(“palette”, “Test Color”, [100, 100, 300, 300]);
myPanel.butCreate = myPanel.add(“button”, [05, 10, 200, 30], “Test Color” );
myPanel.butCreate.onClick=TestColor;
return myPanel;
}
function TestColor()
{
app.beginUndoGroup(“Test Color”);
var myDecColor = 0;
var myDecColor = $.colorPicker();
var myHexColor = myDecColor.toString(16);
r = HexToR(myHexColor);
g = HexToG(myHexColor);
b = HexToB(myHexColor);
function HexToR(h) {return parseInt((cutHex(h)).substring(0,2),16)}
function HexToG(h) {return parseInt((cutHex(h)).substring(2,4),16)}
function HexToB(h) {return parseInt((cutHex(h)).substring(4,6),16)}
function cutHex(h) {return (h.charAt(0)==”#”) ? h.substring(1,7):h}
alert(“decimal = ” + myDecColor + “, hex = ” + myHexColor + “, RGB = ” + r + ‘, ‘ + g + ‘, ‘ + b);
app.endUndoGroup();
}
Create_Null(this);
}