Skip to content

Instantly share code, notes, and snippets.

@nowri
Created April 2, 2012 12:50
Show Gist options
  • Save nowri/2283221 to your computer and use it in GitHub Desktop.
Save nowri/2283221 to your computer and use it in GitHub Desktop.
RGB値 と alpha値 を uint に変換します
/**
* RGB値 と alpha値 を uint に変換します.
* @param r red [0,255]
* @param g green [0,255]
* @param b blue [0,255]
* @param a alpha [0,1]
*/
private static function RGBtoValue( r:uint, g:uint, b:uint, a:Number=0 ):uint
{
if( a>0 )
return ( uint( a * 0xff ) & 0xff ) << 24 | r << 16 & 0xff0000 | g << 8 & 0x00ff00 | b & 0xff;
else
return r << 16 & 0xff0000 | g << 8 & 0x00ff00 | b & 0xff;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment