summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/style/expression/compound_expression.cpp7
-rw-r--r--src/mbgl/style/expression/util.cpp4
-rw-r--r--src/mbgl/util/color.cpp6
3 files changed, 10 insertions, 7 deletions
diff --git a/src/mbgl/style/expression/compound_expression.cpp b/src/mbgl/style/expression/compound_expression.cpp
index ff21157faa..42cb655024 100644
--- a/src/mbgl/style/expression/compound_expression.cpp
+++ b/src/mbgl/style/expression/compound_expression.cpp
@@ -210,7 +210,12 @@ std::unordered_map<std::string, CompoundExpressionRegistry::Definition> initiali
);
});
define("to-rgba", [](const Color& color) -> Result<std::array<double, 4>> {
- return std::array<double, 4> {{ color.r, color.g, color.b, color.a }};
+ return std::array<double, 4> {{
+ 255 * color.r / color.a,
+ 255 * color.g / color.a,
+ 255 * color.b / color.a,
+ color.a
+ }};
});
define("rgba", rgba);
diff --git a/src/mbgl/style/expression/util.cpp b/src/mbgl/style/expression/util.cpp
index f198fb3e1b..ee680dab08 100644
--- a/src/mbgl/style/expression/util.cpp
+++ b/src/mbgl/style/expression/util.cpp
@@ -1,4 +1,3 @@
-
#include <mbgl/style/expression/util.hpp>
#include <mbgl/style/expression/value.hpp>
@@ -30,10 +29,9 @@ Result<Color> rgba(double r, double g, double b, double a) {
"]: 'a' must be between 0 and 1."
};
}
- return Color(r / 255, g / 255, b / 255, a);
+ return Color(r / 255 * a, g / 255 * a, b / 255 * a, a);
}
} // namespace expression
} // namespace style
} // namespace mbgl
-
diff --git a/src/mbgl/util/color.cpp b/src/mbgl/util/color.cpp
index fcb7f4ec16..c8145d36e7 100644
--- a/src/mbgl/util/color.cpp
+++ b/src/mbgl/util/color.cpp
@@ -24,9 +24,9 @@ optional<Color> Color::parse(const std::string& s) {
std::string Color::stringify() const {
return "rgba(" +
- util::toString(r * 255) + "," +
- util::toString(g * 255) + "," +
- util::toString(b * 255) + "," +
+ util::toString(r * 255 / a) + "," +
+ util::toString(g * 255 / a) + "," +
+ util::toString(b * 255 / a) + "," +
util::toString(a) + ")";
}