summaryrefslogtreecommitdiff
path: root/include/mbgl/util/color.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'include/mbgl/util/color.hpp')
-rw-r--r--include/mbgl/util/color.hpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/include/mbgl/util/color.hpp b/include/mbgl/util/color.hpp
index 82cd3c42e7..87d3175178 100644
--- a/include/mbgl/util/color.hpp
+++ b/include/mbgl/util/color.hpp
@@ -11,14 +11,26 @@ public:
float g = 0.0f;
float b = 0.0f;
float a = 0.0f;
+
+ static constexpr Color black() { return { 0.0f, 0.0f, 0.0f, 1.0f }; };
+ static constexpr Color white() { return { 1.0f, 1.0f, 1.0f, 1.0f }; };
};
-inline bool operator== (const Color& colorA, const Color& colorB) {
+inline bool operator==(const Color& colorA, const Color& colorB) {
return colorA.r == colorB.r && colorA.g == colorB.g && colorA.b == colorB.b && colorA.a == colorB.a;
}
-inline bool operator!= (const Color& colorA, const Color& colorB) {
- return !(colorA.r == colorB.r && colorA.g == colorB.g && colorA.b == colorB.b && colorA.a == colorB.a);
+inline bool operator!=(const Color& colorA, const Color& colorB) {
+ return !(colorA == colorB);
+}
+
+inline Color operator*(const Color& color, float alpha) {
+ return {
+ color.r * alpha,
+ color.g * alpha,
+ color.b * alpha,
+ color.a * alpha
+ };
}
} // namespace mbgl