Page 1 of 1

#000000 to RGB

PostPosted: Sat Aug 08, 2015 3:04 pm
by ajhunt
Hi again all, is there a way to translate the html color code to RGB and vise versa - e.g. #FF0000 = 255,0,0 (Red) and 0,0,255 (Blue) = #0000FF
I can't seem to find anything in a plugin but I'm out of daye a bit with the plugins available. Many thanks if anyone can help or suggest how to do it. Regards Anthony.

Re: #000000 to RGB

PostPosted: Sat Aug 08, 2015 4:38 pm
by Tony Kroos
Save to file, drop it to Functions folder and call

Hex2RGB
Code: Select all
{NeoBook Function}
Version=5,80
Language=JScript
Param=[%1]|Text|HEX value (#FFFFFF)
Param=[%2]|Variable|Result variable
{End}
nbSetVar("[%2]", [(bigint = parseInt("[%1]".replace(/[^0-9A-F]/gi, ''), 16)) >> 16 & 255, bigint >> 8 & 255, bigint & 255].join());

Call "hex2rgb" "#731f1f" "[Result]" -> 115,31,31

RGB2Hex
Code: Select all
{NeoBook Function}
Version=5,80
Language=JScript
Param=[%1]|Text|RGB value (R,G,B)
Param=[%2]|Variable|Result variable
{End}
var rgb = "[%1]".split(',');
nbSetVar("[%2]", "#" + ((1 << 24) + (parseInt(rgb[0]) << 16) + (parseInt(rgb[1]) << 8) + parseInt(rgb[2])).toString(16).slice(1));

Call "rgb2hex" "255,120,120" "[Result]" -> #ff7878

Re: #000000 to RGB

PostPosted: Sun Aug 09, 2015 2:14 am
by ajhunt
Thankyou so so much Tony for this. This forum is just so so good for help from experts. Really gratefull. Regards Anthony