1 #ifndef _RIVE_POLYGON_BASE_HPP_
2 #define _RIVE_POLYGON_BASE_HPP_
3 #include "rive/core/field_types/core_double_type.hpp"
4 #include "rive/core/field_types/core_uint_type.hpp"
5 #include "rive/shapes/parametric_path.hpp"
7 class PolygonBase : public ParametricPath {
9 typedef ParametricPath Super;
12 static const uint16_t typeKey = 51;
14 /// Helper to quickly determine if a core object extends another without RTTI
16 bool isTypeOf(uint16_t typeKey) const override {
18 case PolygonBase::typeKey:
19 case ParametricPathBase::typeKey:
20 case PathBase::typeKey:
21 case NodeBase::typeKey:
22 case TransformComponentBase::typeKey:
23 case WorldTransformComponentBase::typeKey:
24 case ContainerComponentBase::typeKey:
25 case ComponentBase::typeKey:
32 uint16_t coreType() const override { return typeKey; }
34 static const uint16_t pointsPropertyKey = 125;
35 static const uint16_t cornerRadiusPropertyKey = 126;
38 uint32_t m_Points = 5;
39 float m_CornerRadius = 0.0f;
42 inline uint32_t points() const { return m_Points; }
43 void points(uint32_t value) {
44 if (m_Points == value) {
51 inline float cornerRadius() const { return m_CornerRadius; }
52 void cornerRadius(float value) {
53 if (m_CornerRadius == value) {
56 m_CornerRadius = value;
57 cornerRadiusChanged();
60 Core* clone() const override;
61 void copy(const PolygonBase& object) {
62 m_Points = object.m_Points;
63 m_CornerRadius = object.m_CornerRadius;
64 ParametricPath::copy(object);
67 bool deserialize(uint16_t propertyKey, BinaryReader& reader) override {
68 switch (propertyKey) {
69 case pointsPropertyKey:
70 m_Points = CoreUintType::deserialize(reader);
72 case cornerRadiusPropertyKey:
73 m_CornerRadius = CoreDoubleType::deserialize(reader);
76 return ParametricPath::deserialize(propertyKey, reader);
80 virtual void pointsChanged() {}
81 virtual void cornerRadiusChanged() {}