#ifndef LLMR_STYLE_PROPERTIES #define LLMR_STYLE_PROPERTIES #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 }; namespace functions { float null(float z, const std::vector&); bool null(float z, const std::vector&); float constant(float z, const std::vector& values); bool constant(float z, const std::vector& values); } template struct FunctionProperty { typedef T (*fn)(float z, const std::vector& values); fn function; std::vector 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); } }; // StrokeClass is the information we parse from the stylesheet struct StrokeClass { FunctionProperty hidden; FunctionProperty width; FunctionProperty offset; Color color = {{ 0, 0, 0, 1 }}; }; // StrokeProperties is the one we resolve this to. struct StrokeProperties { bool hidden = false; float width = 0; float offset = 0; Color color = {{ 0, 0, 0, 1 }}; }; struct FillClass { FunctionProperty hidden; 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; }; 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; }; } #endif