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 uint16_t typeKey = 24;
17 /// Helper to quickly determine if a core object extends another without
19 bool isTypeOf(uint16_t typeKey) const override
23 case StrokeBase::typeKey:
24 case ShapePaintBase::typeKey:
25 case ContainerComponentBase::typeKey:
26 case ComponentBase::typeKey:
33 uint16_t coreType() const override { return typeKey; }
35 static const uint16_t thicknessPropertyKey = 47;
36 static const uint16_t capPropertyKey = 48;
37 static const uint16_t joinPropertyKey = 49;
38 static const uint16_t transformAffectsStrokePropertyKey = 50;
41 float m_Thickness = 1.0f;
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 Core* clone() const override;
94 void copy(const StrokeBase& object)
96 m_Thickness = object.m_Thickness;
98 m_Join = object.m_Join;
99 m_TransformAffectsStroke = object.m_TransformAffectsStroke;
100 ShapePaint::copy(object);
103 bool deserialize(uint16_t propertyKey, BinaryReader& reader) override
107 case thicknessPropertyKey:
108 m_Thickness = CoreDoubleType::deserialize(reader);
111 m_Cap = CoreUintType::deserialize(reader);
113 case joinPropertyKey:
114 m_Join = CoreUintType::deserialize(reader);
116 case transformAffectsStrokePropertyKey:
117 m_TransformAffectsStroke =
118 CoreBoolType::deserialize(reader);
121 return ShapePaint::deserialize(propertyKey, reader);
125 virtual void thicknessChanged() {}
126 virtual void capChanged() {}
127 virtual void joinChanged() {}
128 virtual void transformAffectsStrokeChanged() {}