1 #ifndef _RIVE_POLYGON_BASE_HPP_
2 #define _RIVE_POLYGON_BASE_HPP_
3 #include "core/field_types/core_double_type.hpp"
4 #include "core/field_types/core_uint_type.hpp"
5 #include "shapes/parametric_path.hpp"
8 class PolygonBase : public ParametricPath
11 typedef ParametricPath Super;
14 static const int typeKey = 51;
16 /// Helper to quickly determine if a core object extends another without
18 bool isTypeOf(int typeKey) const override
22 case PolygonBase::typeKey:
23 case ParametricPathBase::typeKey:
24 case PathBase::typeKey:
25 case NodeBase::typeKey:
26 case TransformComponentBase::typeKey:
27 case ContainerComponentBase::typeKey:
28 case ComponentBase::typeKey:
35 int coreType() const override { return typeKey; }
37 static const int pointsPropertyKey = 125;
38 static const int cornerRadiusPropertyKey = 126;
42 float m_CornerRadius = 0;
44 inline int points() const { return m_Points; }
45 void points(int value)
47 if (m_Points == value)
55 inline float cornerRadius() const { return m_CornerRadius; }
56 void cornerRadius(float value)
58 if (m_CornerRadius == value)
62 m_CornerRadius = value;
63 cornerRadiusChanged();
66 bool deserialize(int propertyKey, BinaryReader& reader) override
70 case pointsPropertyKey:
71 m_Points = CoreUintType::deserialize(reader);
73 case cornerRadiusPropertyKey:
74 m_CornerRadius = CoreDoubleType::deserialize(reader);
77 return ParametricPath::deserialize(propertyKey, reader);
81 virtual void pointsChanged() {}
82 virtual void cornerRadiusChanged() {}