rgb_color: Add new APIs: Contrast(), IsLight(), IsDark()
- Remove perceptual_brightness - Change implementation of rgb_color::Brightness() to the previous BPrivate::perceptual_brightness() - Introduce convenience methods Contrast(rgb_color), IsLight() and IsDark() Change-Id: Id677d4a32ce43d73bffecf9baf8cffaafb01a16d Reviewed-on: https://review.haiku-os.org/c/haiku/+/7399 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
@@ -65,19 +65,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
static inline uint8 perceptual_brightness(rgb_color color)
|
||||
{
|
||||
// From http://alienryderflex.com/hsp.html
|
||||
// Useful in particular to decide if the color is "light" or "dark"
|
||||
// by checking if the perceptual brightness is > 127.
|
||||
int r = color.red;
|
||||
int g = color.green;
|
||||
int b = color.blue;
|
||||
|
||||
return (uint8)roundf(sqrtf(
|
||||
0.299f * r * r + 0.587f * g * g + 0.114 * b * b));
|
||||
}
|
||||
|
||||
} // namespace BPrivate
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user