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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
#ifndef LLMR_STYLE_PROPERTIES
#define LLMR_STYLE_PROPERTIES
#include <array>
#include <vector>
#include <string>
#include <limits>
namespace llmr {
typedef std::array<float, 4> Color;
enum class Winding {
EvenOdd = 1,
NonZero = 2
};
// enum LineCap {
// Round = 1
// };
// enum LineJoin {
// Butt = 1,
// Bevel = 2
// };
enum class Property {
Null = 1,
Constant = 2,
Stops = 3,
Linear = 4
};
namespace functions {
float null(float z, const std::vector<float>&);
bool null(float z, const std::vector<bool>&);
float constant(float z, const std::vector<float>& values);
bool constant(float z, const std::vector<bool>& values);
float stops(float z, const std::vector<float>& values);
bool stops(float z, const std::vector<bool>& values);
float linear(float z, const std::vector<float>& values);
bool linear(float z, const std::vector<bool>& values);
}
template <typename T>
struct FunctionProperty {
typedef T (*fn)(float z, const std::vector<T>& values);
fn function;
std::vector<T> values;
inline FunctionProperty() : function(&functions::null) {}
inline FunctionProperty(T value) : function(&functions::constant), values(1, value) {}
inline T operator()(float z) const { return function(z, values); }
};
struct PointClass {
FunctionProperty<bool> hidden;
FunctionProperty<float> size;
Color color = {{ 0, 0, 0, 1 }};
FunctionProperty<float> opacity = 1;
std::string image;
};
struct PointProperties {
bool hidden = false;
float size = 0;
Color color = {{ 0, 0, 0, 1 }};
float opacity = 1.0;
std::string image;
};
struct LineClass {
FunctionProperty<bool> hidden;
FunctionProperty<float> width;
FunctionProperty<float> offset;
Color color = {{ 0, 0, 0, 1 }};
FunctionProperty<float> opacity = 1;
};
struct LineProperties {
bool hidden = false;
float width = 0;
float offset = 0;
Color color = {{ 0, 0, 0, 1 }};
float opacity = 1.0;
};
struct FillClass {
FunctionProperty<bool> hidden;
Winding winding = Winding::NonZero;
FunctionProperty<bool> antialias = true;
Color fill_color = {{ 0, 0, 0, 1 }};
Color stroke_color = {{ 0, 0, 0, std::numeric_limits<float>::infinity() }};
FunctionProperty<float> opacity = 1;
std::string image;
};
struct FillProperties {
bool hidden = false;
Winding winding = Winding::NonZero;
bool antialias = true;
Color fill_color = {{ 0, 0, 0, 1 }};
Color stroke_color = {{ 0, 0, 0, 1 }};
float opacity = 1.0;
std::string image;
};
}
#endif
|