To work with these I've written a number of functions, to take one or two uint colours and output another. These don't need to be fast: they're usually only called at startup as assets are created or as a screen is loaded and populated. And written like this the code is clear and easy to copy and modify which I've done repeatedly.
static function Darken(iTint:uint, fAmt:Number):uint { var iA:int = ((iTint >>> 24) & 0xff) var iR:int = ((iTint >>> 16) & 0xff); var iG:int = ((iTint >>> 8) & 0xff); var iB:int = ( iTint & 0xff); var iScale:int = (1 - fAmt) * 256; iR = (iR * iScale) >>> 8; iG = (iG * iScale) >>> 8; iB = (iB * iScale) >>> 8; return iA + ((iR << 8) + iG << 8) + iB; }
No comments:
Post a Comment