59 lines
1.3 KiB
C++
59 lines
1.3 KiB
C++
#ifndef MBGL_STYLE_FUNCTION
|
|
#define MBGL_STYLE_FUNCTION
|
|
|
|
#include <mbgl/style/types.hpp>
|
|
#include <mbgl/util/chrono.hpp>
|
|
#include <mbgl/util/optional.hpp>
|
|
|
|
#include <vector>
|
|
#include <utility>
|
|
|
|
namespace mbgl {
|
|
|
|
class StyleCalculationParameters;
|
|
|
|
template <typename T>
|
|
class Function {
|
|
public:
|
|
using Stop = std::pair<float, T>;
|
|
using Stops = std::vector<Stop>;
|
|
|
|
explicit Function(const T& constant)
|
|
: stops({{ 0, constant }}) {}
|
|
|
|
explicit Function(const Stops& stops_, float base_)
|
|
: base(base_), stops(stops_) {}
|
|
|
|
T evaluate(const StyleCalculationParameters&) const;
|
|
|
|
float getBase() const { return base; }
|
|
const std::vector<std::pair<float, T>>& getStops() const { return stops; }
|
|
|
|
private:
|
|
float base = 1;
|
|
std::vector<std::pair<float, T>> stops;
|
|
};
|
|
|
|
// Partial specialization for cross-faded properties (*-pattern, line-dasharray).
|
|
template <typename T>
|
|
class Function<Faded<T>> {
|
|
public:
|
|
using Stop = std::pair<float, T>;
|
|
using Stops = std::vector<Stop>;
|
|
|
|
explicit Function(const T& constant)
|
|
: stops({{ 0, constant }}) {}
|
|
|
|
explicit Function(const Stops& stops_)
|
|
: stops(stops_) {}
|
|
|
|
Faded<T> evaluate(const StyleCalculationParameters&) const;
|
|
|
|
private:
|
|
std::vector<std::pair<float, T>> stops;
|
|
};
|
|
|
|
} // namespace mbgl
|
|
|
|
#endif
|