#ifndef LLMR_STYLE_PROPERTIES #define LLMR_STYLE_PROPERTIES #include #include #include #include namespace llmr { typedef std::array 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 constant(float z, const std::vector& values); float min(float z, const std::vector& values); float max(float z, const std::vector& values); float stops(float z, const std::vector& values); float linear(float z, const std::vector& values); float exponential(float z, const std::vector& values); } struct FunctionProperty { typedef float (*fn)(float z, const std::vector& values); fn function; std::vector values; inline FunctionProperty() : function(&functions::null) {} inline FunctionProperty(float value) : function(&functions::constant), values(1, value) {} template inline T evaluate(float z) const { return function(z, values); } }; struct PointClass { FunctionProperty enabled = true; std::array translate = {{ 0, 0 }}; FunctionProperty size; Color color = {{ 0, 0, 0, 1 }}; FunctionProperty opacity = 1; std::string image; FunctionProperty radius = 0; FunctionProperty blur = 0; }; struct PointProperties { bool enabled = true; std::array translate = {{ 0, 0 }}; float size = 0; Color color = {{ 0, 0, 0, 1 }}; float opacity = 1.0; std::string image; float radius = 0; float blur = 0; }; struct LineClass { FunctionProperty enabled = true; std::array translate = {{ 0, 0 }}; FunctionProperty width; FunctionProperty offset; Color color = {{ 0, 0, 0, 1 }}; std::array dash_array = {{ 1, -1 }}; FunctionProperty opacity = 1; }; struct LineProperties { bool enabled = true; std::array translate = {{ 0, 0 }}; float width = 0; float offset = 0; Color color = {{ 0, 0, 0, 1 }}; std::array dash_array = {{ 1, -1 }}; float opacity = 1.0; }; struct FillClass { FunctionProperty enabled = true; std::array translate = {{ 0, 0 }}; Winding winding = Winding::NonZero; FunctionProperty antialias = true; Color fill_color = {{ 0, 0, 0, 1 }}; Color stroke_color = {{ 0, 0, 0, std::numeric_limits::infinity() }}; FunctionProperty opacity = 1; std::string image; }; struct FillProperties { bool enabled = true; std::array translate = {{ 0, 0 }}; 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; }; struct TextClass { FunctionProperty enabled = true; std::array translate = {{ 0, 0 }}; Color color = {{ 0, 0, 0, 1 }}; Color halo = {{ 1, 1, 1, 0.75 }}; FunctionProperty haloRadius = 0.25f; FunctionProperty size = 12.0f; FunctionProperty rotate = 0.0f; FunctionProperty alwaysVisible = false; }; struct TextProperties { bool enabled = true; std::array translate = {{ 0, 0 }}; Color color = {{ 0, 0, 0, 1 }}; Color halo = {{ 1, 1, 1, 0.75 }}; float haloRadius = 0.25f; float size = 12.0f; float rotate = 0.0f; bool alwaysVisible = false; }; struct BackgroundClass { Color color = {{ 1, 1, 1, 1 }}; FunctionProperty opacity = 1; }; struct BackgroundProperties { Color color = {{ 1, 1, 1, 1 }}; float opacity = 1.0; }; struct RasterClass { FunctionProperty enabled = true; std::array translate = {{ 0, 0 }}; FunctionProperty opacity = 1; }; struct RasterProperties { bool enabled = true; std::array translate = {{ 0, 0 }}; float opacity = 1.0; }; } #endif