Reputation: 1814
I need to darken a given color by given percentage, if the percentage is 1 the black color should be returned and if the percentage is 0 the originalColor should be returned.
private function getDarkenedColor ( originalColor : uint, darkPercentage : Number = 0.5 ) : uint {
var red : uint = UtilColor.extractColor( originalColor, UtilColor.EXTRACT_COLOR_RED );
var blue : uint = UtilColor.extractColor( originalColor, UtilColor.EXTRACT_COLOR_BLUE );
var green : uint = UtilColor.extractColor( originalColor, UtilColor.EXTRACT_COLOR_GREEN );
return (new ColorTransform()).color; //please complete this line
}
Upvotes: 0
Views: 99
Reputation: 141
if the percentage is 1 the black color should be returned and if the percentage is 0 the originalColor should be returned
Then it is a ratio, not a percentage
Therefore you just have to multiply each component (red, blue, green) by your given ratio.
Upvotes: 1