Skip to content

Instantly share code, notes, and snippets.

@goshki
Created April 12, 2011 10:33
Show Gist options
  • Save goshki/915301 to your computer and use it in GitHub Desktop.
Save goshki/915301 to your computer and use it in GitHub Desktop.
ActionScript 3 basic operations on an ARGB (alpha, red, green, blue) color
package {
public static function argbDecombine( ARGB:uint ):Array {
return [ ARGB >> 24, ( ARGB >> 16 ) & 0xFF, ( ARGB >> 8 ) & 0xFF, ARGB & 0xFF ];
}
public static function argbCombine( ARGB:Array ):uint {
return argbCombine( ARGB[0], ARGB[1], ARGB[2], ARGB[3] );
}
public static function argbCombine( A:uint, R:uint, G:uint, B:uint ):uint {
return ( A << 24 ) + ( R << 16 ) + ( G << 8 ) + B;
}
public static function argbGetA( ARGB:uint ):uint {
return ARGB >> 24;
}
public static function argbGetR( ARGB:uint ):uint {
return ( ARGB >> 16 ) & 0xFF;
}
public static function argbGetG( ARGB:uint ):uint {
return ( ARGB >> 8 ) & 0xFF;
}
public static function argbGetB( ARGB:uint ):uint {
return ARGB & 0xFF;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment