Added getter for null color

This commit is contained in:
Charles Dang 2017-04-09 23:59:21 +11:00
parent 08d25b0542
commit c379b7ccc9
2 changed files with 9 additions and 3 deletions

View file

@ -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<std::string> 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<std::string> fields = utils::split(c);

View file

@ -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)