Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

HEX to RGB (See related posts)

function hexToRGB ( hex:Number ){
   var returnObj:Object = new Object();   
   var returnObj .r = hex >> 16;
   var temp = hex ^ r << 16;
   var returnObj .g = temp >> 8;
   var returnObj .b = temp ^ g << 8;

   return returnObj;
}

Comments on this post

pp-layouts posts on Nov 17, 2007 at 15:43
function hex2RGB ( hex:Number ) {
	var rgb:Object = {
		r:Number = (hex & 0xff0000) >> 16,
		g:Number = (hex & 0x00ff00) >> 8,
		b:Number = hex & 0x0000ff }
	return rgb;
}

function RGB2hex ( rgb:Object ) {
	return (rgb.r << 16) + (rgb.g << 8) + rgb.b;
}

You need to create an account or log in to post comments to this site.


Click here to browse all 4858 code snippets

Related Posts