summaryrefslogtreecommitdiff
path: root/src/mbgl/style/piecewisefunction_properties.hpp
blob: 0440655ba50cbae69233d88936296f5ebce164e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#ifndef MBGL_STYLE_FADEDFUNCTION_PROPERTIES
#define MBGL_STYLE_FADEDFUNCTION_PROPERTIES

#include <mbgl/style/zoom_history.hpp>

#include <vector>

namespace mbgl {

template <typename T>
struct PiecewiseConstantFunction {
    inline PiecewiseConstantFunction(const std::vector<std::pair<float, T>> &values_, std::chrono::duration<float> duration_) : values(values_), duration(duration_) {}
    inline PiecewiseConstantFunction(T &value, std::chrono::duration<float> duration_) : values({{ 0, value }}), duration(duration_) {}
    inline PiecewiseConstantFunction() : values(), duration(std::chrono::milliseconds(300)) {}
    T evaluate(float z, const ZoomHistory &zoomHistory) const;

private:
    const std::vector<std::pair<float, T>> values;
    const std::chrono::duration<float> duration;
};

}

#endif