[core] Round-trip linear interpolators
This commit is contained in:
committed by
Minh Nguyễn
parent
cf5d2ca4ef
commit
f4d9fb816d
Submodule mapbox-gl-js updated: 3c07b72a59...34902f8db3
@@ -223,7 +223,11 @@ mbgl::Value Interpolate<T>::serialize() const {
|
||||
|
||||
interpolator.match(
|
||||
[&](const ExponentialInterpolator& exponential) {
|
||||
serialized.emplace_back(std::vector<mbgl::Value>{{ std::string("exponential"), exponential.base }});
|
||||
if (exponential.base == 1) {
|
||||
serialized.emplace_back(std::vector<mbgl::Value>{{ std::string("linear") }});
|
||||
} else {
|
||||
serialized.emplace_back(std::vector<mbgl::Value>{{ std::string("exponential"), exponential.base }});
|
||||
}
|
||||
},
|
||||
[&](const CubicBezierInterpolator& cubicBezier) {
|
||||
static const std::string cubicBezierTag("cubic-bezier");
|
||||
|
||||
@@ -80,6 +80,8 @@ TEST(Stringify, Filter) {
|
||||
}
|
||||
|
||||
TEST(Stringify, CameraFunction) {
|
||||
ASSERT_EQ(stringify(CameraFunction<float>(ExponentialStops<float> { {{0, 1}}, 1 })),
|
||||
"[\"interpolate\",[\"linear\"],[\"zoom\"],0.0,1.0]");
|
||||
ASSERT_EQ(stringify(CameraFunction<float>(ExponentialStops<float> { {{0, 1}}, 2 })),
|
||||
"[\"interpolate\",[\"exponential\",2.0],[\"zoom\"],0.0,1.0]");
|
||||
ASSERT_EQ(stringify(CameraFunction<float>(IntervalStops<float> { {{0, 1}} })),
|
||||
@@ -109,7 +111,7 @@ TEST(Stringify, CompositeFunction) {
|
||||
2
|
||||
}, 0.0f)),
|
||||
"[\"interpolate\","
|
||||
"[\"exponential\",1.0],"
|
||||
"[\"linear\"],"
|
||||
"[\"zoom\"],"
|
||||
"0.0,[\"interpolate\",[\"exponential\",2.0],[\"number\",[\"get\",\"property\"]],0.0,1.0],"
|
||||
"1.0,[\"interpolate\",[\"exponential\",2.0],[\"number\",[\"get\",\"property\"]],0.0,1.0]]");
|
||||
|
||||
Reference in New Issue
Block a user