From 5265f844b97923bf835e0f7d3a29ea96891bc4e9 Mon Sep 17 00:00:00 2001 From: subhransu mohanty Date: Thu, 1 Nov 2018 10:57:14 +0900 Subject: [PATCH] lottie/vector: added new addroundrect api with uniform roundness of corner. Change-Id: Id6584d3b4fc4b81f2407ba66cafca4b6521d7fd8 --- src/vector/vpath.cpp | 8 ++++++++ src/vector/vpath.h | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/src/vector/vpath.cpp b/src/vector/vpath.cpp index 7d6701c..0f246d9 100644 --- a/src/vector/vpath.cpp +++ b/src/vector/vpath.cpp @@ -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) { diff --git a/src/vector/vpath.h b/src/vector/vpath.h index 567d99c..6a22225 100644 --- a/src/vector/vpath.h +++ b/src/vector/vpath.h @@ -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) { -- 2.7.4