1 #ifndef _RIVE_STROKE_BASE_HPP_
2 #define _RIVE_STROKE_BASE_HPP_
3 #include "core/field_types/core_bool_type.hpp"
4 #include "core/field_types/core_double_type.hpp"
5 #include "core/field_types/core_uint_type.hpp"
6 #include "shapes/paint/shape_paint.hpp"
9 class StrokeBase : public ShapePaint
12 typedef ShapePaint Super;
15 static const int typeKey = 24;
17 /// Helper to quickly determine if a core object extends another without
19 bool isTypeOf(int typeKey) const override
23 case StrokeBase::typeKey:
24 case ShapePaintBase::typeKey:
25 case ContainerComponentBase::typeKey:
26 case ComponentBase::typeKey:
33 int coreType() const override { return typeKey; }
35 static const int thicknessPropertyKey = 47;
36 static const int capPropertyKey = 48;
37 static const int joinPropertyKey = 49;
38 static const int transformAffectsStrokePropertyKey = 50;
41 float m_Thickness = 1;
44 bool m_TransformAffectsStroke = true;
46 inline float thickness() const { return m_Thickness; }
47 void thickness(float value)
49 if (m_Thickness == value)
57 inline int cap() const { return m_Cap; }
68 inline int join() const { return m_Join; }
79 inline bool transformAffectsStroke() const
81 return m_TransformAffectsStroke;
83 void transformAffectsStroke(bool value)
85 if (m_TransformAffectsStroke == value)
89 m_TransformAffectsStroke = value;
90 transformAffectsStrokeChanged();
93 bool deserialize(int propertyKey, BinaryReader& reader) override
97 case thicknessPropertyKey:
98 m_Thickness = CoreDoubleType::deserialize(reader);
101 m_Cap = CoreUintType::deserialize(reader);
103 case joinPropertyKey:
104 m_Join = CoreUintType::deserialize(reader);
106 case transformAffectsStrokePropertyKey:
107 m_TransformAffectsStroke =
108 CoreBoolType::deserialize(reader);
111 return ShapePaint::deserialize(propertyKey, reader);
115 virtual void thicknessChanged() {}
116 virtual void capChanged() {}
117 virtual void joinChanged() {}
118 virtual void transformAffectsStrokeChanged() {}