implement tint_color()

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@6251 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
haydentech 2004-01-23 16:17:40 +00:00
parent ce3857c204
commit 2f4343ad60

View File

@ -405,8 +405,30 @@ ui_color(color_which which)
_IMPEXP_BE rgb_color
tint_color(rgb_color color, float tint)
{
// Internally calculates the color
// TODO: Implement
rgb_color result;
#define LIGHTEN(x) ((uint8)(255.0f - (255.0f - x) * tint))
#define DARKEN(x) ((uint8)(x * (2 - tint)))
if (tint < 1.0f)
{
result.red = LIGHTEN(color.red);
result.green = LIGHTEN(color.green);
result.blue = LIGHTEN(color.blue);
result.alpha = color.alpha;
}
else
{
result.red = DARKEN(color.red);
result.green = DARKEN(color.green);
result.blue = DARKEN(color.blue);
result.alpha = color.alpha;
}
#undef LIGHTEN
#undef DARKEN
return result;
}