1#pragma once
2
3#include <mbgl/util/interpolate.hpp>
4#include <mbgl/util/range.hpp>
5#include <mbgl/util/unitbezier.hpp>
6
7namespace mbgl {
8namespace style {
9namespace expression {
10
11class ExponentialInterpolator {
12public:
13 ExponentialInterpolator(double base_) : base(base_) {}
14
15 double base;
16
17 double interpolationFactor(const Range<double>& inputLevels, const double input) const {
18 return util::interpolationFactor(base,
19 range: Range<float> {
20 static_cast<float>(inputLevels.min),
21 static_cast<float>(inputLevels.max)
22 },
23 z: input);
24 }
25
26 bool operator==(const ExponentialInterpolator& rhs) const {
27 return base == rhs.base;
28 }
29};
30
31class CubicBezierInterpolator {
32public:
33 CubicBezierInterpolator(double x1_, double y1_, double x2_, double y2_) : ub(x1_, y1_, x2_, y2_) {}
34
35 double interpolationFactor(const Range<double>& inputLevels, const double input) const {
36 return ub.solve(x: input / (inputLevels.max - inputLevels.min), epsilon: 1e-6);
37 }
38
39 bool operator==(const CubicBezierInterpolator& rhs) const {
40 return ub == rhs.ub;
41 }
42
43 util::UnitBezier ub;
44};
45
46using Interpolator = variant<ExponentialInterpolator, CubicBezierInterpolator>;
47
48} // namespace expression
49} // namespace style
50} // namespace mbgl
51

source code of qtlocation/src/3rdparty/mapbox-gl-native/include/mbgl/style/expression/interpolator.hpp