blob: 3f5c4795125eb572f8650fdefef1c141cef55225 (
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#ifndef MBGL_STYLE_FUNCTION
#define MBGL_STYLE_FUNCTION
#include <mbgl/style/types.hpp>
#include <mbgl/util/chrono.hpp>
#include <mapbox/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>;
// TODO: make explicit
/* explicit */ Function(const T& constant)
: stops({{ 0, constant }}) {}
explicit Function(const Stops& stops_, float base_)
: base(base_), stops(stops_) {}
T evaluate(const StyleCalculationParameters&) const;
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>;
// TODO: make explicit
/* 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;
};
}
#endif
|