From adeb3780e89cc42dd452280428bf46b1a0efc63b Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 21 May 2021 16:28:26 +0100 Subject: [PATCH] [Minor] Css: Allow to convert css color to uint32_t --- src/libserver/css/css_value.hxx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libserver/css/css_value.hxx b/src/libserver/css/css_value.hxx index 4c013124c..9e192acb6 100644 --- a/src/libserver/css/css_value.hxx +++ b/src/libserver/css/css_value.hxx @@ -40,6 +40,12 @@ struct alignas(int) css_color { css_color(std::uint8_t _r, std::uint8_t _g, std::uint8_t _b, std::uint8_t _alpha = 255) : r(_r), g(_g), b(_b), alpha(_alpha) {} css_color() = default; + constexpr auto to_number() const -> std::uint32_t { + return (std::uint32_t)alpha << 24 | + (std::uint32_t)r << 16 | + (std::uint32_t)g << 8 | + (std::uint32_t)b << 0; + } friend bool operator==(const css_color& l, const css_color& r) { return (memcmp(&l, &r, sizeof(css_color)) == 0); } -- 2.39.5