Skip to content

Instantly share code, notes, and snippets.

@SnugglePilot
Created October 7, 2013 16:48
Show Gist options
  • Save SnugglePilot/6871127 to your computer and use it in GitHub Desktop.
Save SnugglePilot/6871127 to your computer and use it in GitHub Desktop.
protected static var _lumR:Number = 0.212671;
protected static var _lumG:Number = 0.715160;
protected static var _lumB:Number = 0.072169;
public function ColorManip() { }
static public function colorize(color:Number, amount:Number = 1):Array {
if (isNaN(amount)) {
amount = 1;
}
var r:Number = ((color >> 16) & 0xff) / 255;
var g:Number = ((color >> 8) & 0xff) / 255;
var b:Number = (color & 0xff) / 255;
var inv:Number = 1 - amount;
var temp:Array = [inv + amount * r * _lumR, amount * r * _lumG, amount * r * _lumB, 0, 0,
amount * g * _lumR, inv + amount * g * _lumG, amount * g * _lumB, 0, 0,
amount * b * _lumR, amount * b * _lumG, inv + amount * b * _lumB, 0, 0,
0, 0, 0, 1, 0];
return temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment