From c379b7ccc9c440ca935228fe78241d63a9b841f6 Mon Sep 17 00:00:00 2001 From: Charles Dang Date: Sun, 9 Apr 2017 23:59:21 +1100 Subject: [PATCH] Added getter for null color --- src/color.cpp | 4 ++-- src/color.hpp | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) 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)