Skip to main content
Known Participant
September 14, 2013
Answered

How to interpret the returned value from $.colorPicker()

  • September 14, 2013
  • 1 reply
  • 987 views

Hi there

I have one questiion how  do I interpret the returned value from this function:

$.colorPicker()

It returns a strange number how do I convert that into usable RGB values.

Any help would be really appeciated.

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

This should help:

function hexToColor(theHex){

    var r = theHex >> 16;

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

    var b = theHex & 0xff;

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

}

var hexColor = $.colorPicker();

var newColor = hexToColor(hexColor);

Dan

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
September 14, 2013

This should help:

function hexToColor(theHex){

    var r = theHex >> 16;

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

    var b = theHex & 0xff;

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

}

var hexColor = $.colorPicker();

var newColor = hexToColor(hexColor);

Dan

Known Participant
September 29, 2013

Thank you so much Dan it is exactly what I was lloking for.

Keep up with the good work