summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorYoung Hahn <young@mapbox.com>2016-06-15 11:38:22 -0400
committerGitHub <noreply@github.com>2016-06-15 11:38:22 -0400
commit24b66bc8cdd40a52e08d198c063daa3e1f6be92a (patch)
tree6d98a5e1216a83f7d6d4c78422c8306d4a4cb157 /include
parentfe64238b4cd5a7da403a4f29a62b14234ecba569 (diff)
downloadqtlocation-mapboxgl-24b66bc8cdd40a52e08d198c063daa3e1f6be92a.tar.gz
Color class (#5361)
* Color class * Switch to list initialization
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/annotation/annotation.hpp6
-rw-r--r--include/mbgl/util/color.hpp16
2 files changed, 18 insertions, 4 deletions
diff --git a/include/mbgl/annotation/annotation.hpp b/include/mbgl/annotation/annotation.hpp
index 6cb26e6a82..fc0595af0f 100644
--- a/include/mbgl/annotation/annotation.hpp
+++ b/include/mbgl/annotation/annotation.hpp
@@ -30,15 +30,15 @@ public:
ShapeAnnotationGeometry geometry;
float opacity = 1;
float width = 1;
- Color color = {{ 0, 0, 0, 1 }};
+ Color color = { 0, 0, 0, 1 };
};
class FillAnnotation {
public:
ShapeAnnotationGeometry geometry;
float opacity = 1;
- Color color = {{ 0, 0, 0, 1 }};
- Color outlineColor = {{ 0, 0, 0, -1 }};
+ Color color = { 0, 0, 0, 1 };
+ Color outlineColor = { 0, 0, 0, -1 };
};
// An annotation whose type and properties are sourced from a style layer.
diff --git a/include/mbgl/util/color.hpp b/include/mbgl/util/color.hpp
index d7fe61c640..82cd3c42e7 100644
--- a/include/mbgl/util/color.hpp
+++ b/include/mbgl/util/color.hpp
@@ -5,6 +5,20 @@
namespace mbgl {
// Stores a premultiplied color, with all four channels ranging from 0..1
-using Color = std::array<float, 4>;
+class Color {
+public:
+ float r = 0.0f;
+ float g = 0.0f;
+ float b = 0.0f;
+ float a = 0.0f;
+};
+
+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);
+}
} // namespace mbgl