Convert Hexcode to RGB values

This answer has been taken from Stackoverflow which helped me to convert hex to rgb format.

the below function you can use to convert but pass hex values without ‘#’ and get RGB values

Hexcode = ‘#00000’;

call function like

hexToRgb(00000);

function hexToRgb(hex) {
var bigint = parseInt(hex, 16);
var r = (bigint >> 16) & 255;
var g = (bigint >> 8) & 255;
var b = bigint & 255;
return r + “,” + g + “,” + b;
}

Result : ‘0,0,0’

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s