5
5
#include " RectProp.h"
6
6
7
7
#include < memory>
8
+ #include < vector>
8
9
9
10
#pragma clang diagnostic push
10
11
#pragma clang diagnostic ignored "-Wdocumentation"
@@ -19,6 +20,10 @@ namespace RNSkia {
19
20
static PropId PropNameRx = JsiPropId::get(" rx" );
20
21
static PropId PropNameRy = JsiPropId::get(" ry" );
21
22
static PropId PropNameR = JsiPropId::get(" r" );
23
+ static PropId PropNameTopLeft = JsiPropId::get(" topLeft" );
24
+ static PropId PropNameTopRight = JsiPropId::get(" topRight" );
25
+ static PropId PropNameBottomRight = JsiPropId::get(" bottomRight" );
26
+ static PropId PropNameBottomLeft = JsiPropId::get(" bottomLeft" );
22
27
23
28
/* *
24
29
Reads a rect from a given propety in the node. The name of the property is
@@ -64,6 +69,51 @@ class RRectProp : public DerivedProp<SkRRect> {
64
69
width.getAsNumber (), height.getAsNumber ()),
65
70
rx.getAsNumber (), ry.getAsNumber ()));
66
71
}
72
+ } else if (value.hasValue (PropNameRect) &&
73
+ value.hasValue (PropNameTopLeft) &&
74
+ value.hasValue (PropNameTopRight) &&
75
+ value.hasValue (PropNameBottomRight) &&
76
+ value.hasValue (PropNameBottomLeft)) {
77
+ auto rect = value.getValue (PropNameRect);
78
+ if (rect.hasValue (PropNameX) && rect.hasValue (PropNameY) &&
79
+ rect.hasValue (PropNameWidth) && rect.hasValue (PropNameHeight)) {
80
+ auto x = rect.getValue (PropNameX);
81
+ auto y = rect.getValue (PropNameY);
82
+ auto width = rect.getValue (PropNameWidth);
83
+ auto height = rect.getValue (PropNameHeight);
84
+ std::vector<SkPoint> points;
85
+ points.reserve (4 );
86
+ auto topLeft = value.getValue (PropNameTopLeft);
87
+ auto topLeftX = topLeft.getValue (PropNameX);
88
+ auto topLeftY = topLeft.getValue (PropNameY);
89
+ points.push_back (
90
+ SkPoint::Make (topLeftX.getAsNumber (), topLeftY.getAsNumber ()));
91
+
92
+ auto topRight = value.getValue (PropNameTopRight);
93
+ auto topRightX = topRight.getValue (PropNameX);
94
+ auto topRightY = topRight.getValue (PropNameY);
95
+ points.push_back (SkPoint::Make (topRightX.getAsNumber (),
96
+ topRightY.getAsNumber ()));
97
+
98
+ auto bottomRight = value.getValue (PropNameBottomRight);
99
+ auto bottomRightX = bottomRight.getValue (PropNameX);
100
+ auto bottomRightY = bottomRight.getValue (PropNameY);
101
+ points.push_back (SkPoint::Make (bottomRightX.getAsNumber (),
102
+ bottomRightY.getAsNumber ()));
103
+
104
+ auto bottomLeft = value.getValue (PropNameBottomLeft);
105
+ auto bottomLeftX = bottomLeft.getValue (PropNameX);
106
+ auto bottomLeftY = bottomLeft.getValue (PropNameY);
107
+ points.push_back (SkPoint::Make (bottomLeftX.getAsNumber (),
108
+ bottomLeftY.getAsNumber ()));
109
+
110
+ auto rrect = std::make_shared<SkRRect>(SkRRect::MakeEmpty ());
111
+ rrect->setRectRadii (
112
+ SkRect::MakeXYWH (x.getAsNumber (), y.getAsNumber (),
113
+ width.getAsNumber (), height.getAsNumber ()),
114
+ points.data ());
115
+ return rrect;
116
+ }
67
117
}
68
118
}
69
119
}
0 commit comments