diff --git a/Userland/Libraries/LibGfx/Color.h b/Userland/Libraries/LibGfx/Color.h index f3f2f98a09d..5a0d490d8f1 100644 --- a/Userland/Libraries/LibGfx/Color.h +++ b/Userland/Libraries/LibGfx/Color.h @@ -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(255.0f * (1.0f - c) * (1.0f - k)); + auto g = static_cast(255.0f * (1.0f - m) * (1.0f - k)); + auto b = static_cast(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; }