Skip to content

Commit

Permalink
Added getter for null color
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultraz committed Apr 9, 2017
1 parent 08d25b0 commit c379b7c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/color.cpp
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion src/color.hpp
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c379b7c

Please sign in to comment.