diff --git a/src/color.cpp b/src/color.cpp index b82c72179a39..4acc64bdeb4f 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -20,7 +20,7 @@ color_t color_t::from_rgba_string(const std::string& c) { if(c.empty()) { - return {0,0,0,0}; + return null_color(); } std::vector fields = utils::split(c); @@ -41,7 +41,7 @@ color_t color_t::from_rgba_string(const std::string& c) color_t color_t::from_rgb_string(const std::string& c) { if(c.empty()) { - return {0,0,0,0}; + return null_color(); } std::vector fields = utils::split(c); diff --git a/src/color.hpp b/src/color.hpp index 389cdf032450..2115583f87be 100644 --- a/src/color.hpp +++ b/src/color.hpp @@ -188,7 +188,7 @@ struct color_t bool null() const { - return r == 0 && g == 0 && b == 0 && a == 0; + return *this == null_color(); } bool operator==(const color_t& c) const @@ -232,6 +232,12 @@ struct color_t a }; } + + /** Definition of a 'null' color - fully transparent black. */ + static color_t null_color() + { + return {0,0,0,0}; + } }; inline std::ostream& operator<<(std::ostream& s, const color_t& c)