Source language: Translate to:

#000000 to RGB

General questions about NeoBook

Moderator: Neosoft Support

#000000 to RGB

Postby ajhunt » Sat Aug 08, 2015 3:04 pm

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.
ajhunt
 
Posts: 223
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom

Re: #000000 to RGB

Postby Tony Kroos » Sat Aug 08, 2015 4:38 pm

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
Tony Kroos
 
Posts: 402
Joined: Thu Oct 15, 2009 3:43 pm

Re: #000000 to RGB

Postby ajhunt » Sun Aug 09, 2015 2:14 am

Thankyou so so much Tony for this. This forum is just so so good for help from experts. Really gratefull. Regards Anthony
ajhunt
 
Posts: 223
Joined: Sat Apr 23, 2005 2:33 pm
Location: United Kingdom


Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 1 guest