lottie/vector: added new addroundrect api with uniform roundness of corner. 22/192222/1
authorsubhransu mohanty <sub.mohanty@samsung.com>
Thu, 1 Nov 2018 01:57:14 +0000 (10:57 +0900)
committersubhransu mohanty <sub.mohanty@samsung.com>
Thu, 1 Nov 2018 01:57:14 +0000 (10:57 +0900)
Change-Id: Id6584d3b4fc4b81f2407ba66cafca4b6521d7fd8

src/vector/vpath.cpp
src/vector/vpath.h

index 7d6701c282d9bd889e620e6f5ffae3b63d8536ca..0f246d9000344464571b564865417e9ed1b43c2e 100644 (file)
@@ -215,6 +215,14 @@ void VPath::VPathData::addRect(const VRectF &rect, VPath::Direction dir)
     }
 }
 
+void VPath::VPathData::addRoundRect(const VRectF &rect, float roundness,
+                                    VPath::Direction dir)
+{
+    if (2 * roundness > rect.width()) roundness = rect.width()/2.0;
+    if (2 * roundness > rect.height()) roundness = rect.height()/2.0;
+    addRoundRect(rect, roundness, roundness, dir);
+}
+
 void VPath::VPathData::addRoundRect(const VRectF &rect, float rx, float ry,
                                     VPath::Direction dir)
 {
index 567d99c8a6d3fc1a4e65559503e690ebf4064077..6a22225329ef81c0ec31e8d80e32f685e5689e32 100644 (file)
@@ -33,6 +33,8 @@ public:
     void  addOval(const VRectF &rect, VPath::Direction dir = Direction::CW);
     void  addRoundRect(const VRectF &rect, float rx, float ry,
                        VPath::Direction dir = Direction::CW);
+    void  addRoundRect(const VRectF &rect, float roundness,
+                       VPath::Direction dir = Direction::CW);
     void  addRect(const VRectF &rect, VPath::Direction dir = Direction::CW);
     void  addPolystar(float points, float innerRadius, float outerRadius,
                       float innerRoundness, float outerRoundness,
@@ -62,6 +64,7 @@ private:
         void  transform(const VMatrix &m);
         float length() const;
         void  addRoundRect(const VRectF &, float, float, VPath::Direction);
+        void  addRoundRect(const VRectF &, float, VPath::Direction);
         void  addRect(const VRectF &, VPath::Direction);
         void  arcTo(const VRectF &, float, float, bool);
         void  addCircle(float, float, float, VPath::Direction);
@@ -174,6 +177,12 @@ inline void VPath::addRoundRect(const VRectF &rect, float rx, float ry,
     d.write().addRoundRect(rect, rx, ry, dir);
 }
 
+inline void VPath::addRoundRect(const VRectF &rect, float roundness,
+                                VPath::Direction dir)
+{
+    d.write().addRoundRect(rect, roundness, dir);
+}
+
 inline void VPath::addCircle(float cx, float cy, float radius,
                              VPath::Direction dir)
 {