LibGfx: Add Color::from_cmyk

This commit is contained in:
Matthew Olsson 2021-05-23 12:51:53 -07:00 committed by Ali Mohammad Pur
parent f2d2f3fae7
commit f4941f5940
Notes: sideshowbarker 2024-07-18 17:26:29 +09:00

View file

@ -71,6 +71,15 @@ public:
static constexpr Color from_rgb(unsigned rgb) { return Color(rgb | 0xff000000); }
static constexpr Color from_rgba(unsigned rgba) { return Color(rgba); }
static constexpr Color from_cmyk(float c, float m, float y, float k)
{
auto r = static_cast<u8>(255.0f * (1.0f - c) * (1.0f - k));
auto g = static_cast<u8>(255.0f * (1.0f - m) * (1.0f - k));
auto b = static_cast<u8>(255.0f * (1.0f - y) * (1.0f - k));
return Color(r, g, b);
}
constexpr u8 red() const { return (m_value >> 16) & 0xff; }
constexpr u8 green() const { return (m_value >> 8) & 0xff; }
constexpr u8 blue() const { return m_value & 0xff; }