Created
April 2, 2012 12:50
-
-
Save nowri/2283221 to your computer and use it in GitHub Desktop.
RGB値 と alpha値 を uint に変換します
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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