}
}
+float VPath::VPathData::length() const
+{
+ float len = 0.0;
+ int i = 0;
+ for (auto e : m_elements) {
+ switch (e) {
+ case VPath::Element::MoveTo:
+ i++;
+ break;
+ case VPath::Element::LineTo:
+ {
+ VPointF p0 = m_points[i - 1];
+ VPointF p = m_points[i++];
+ VBezier b = VBezier::fromPoints(p0, p0, p, p);
+ len += b.length();
+ break;
+ }
+ case VPath::Element::CubicTo:
+ {
+ VPointF p0 = m_points[i - 1];
+ VPointF p = m_points[i++];
+ VPointF p1 = m_points[i++];
+ VPointF p2 = m_points[i++];
+ VBezier b = VBezier::fromPoints(p0, p, p1, p2);
+ len += b.length();
+ break;
+ }
+ case VPath::Element::Close:
+ break;
+ }
+ }
+
+ return len;
+}
+
void VPath::VPathData::checkNewSegment()
{
if (mNewSegment) {
void addPolygon(float points, float radius, float roundness,
float startAngle, float cx, float cy, VPath::Direction dir = Direction::CW);
void transform(const VMatrix &m);
+ float length() const;
const std::vector<VPath::Element> &elements() const;
const std::vector<VPointF> &points() const;
private:
void checkNewSegment();
int segments() const;
void transform(const VMatrix &m);
+ float length() const;
void addRoundRect(const VRectF &, float, float, VPath::Direction);
void addRect(const VRectF &, VPath::Direction);
void arcTo(const VRectF&, float, float, bool);
return d->segments();
}
+inline float VPath::length() const
+{
+ //TODO re-calculate when there is a change
+ return d->length();
+}
+
inline void VPath::cubicTo(const VPointF &c1, const VPointF &c2, const VPointF &e)
{
d.write().cubicTo(c1, c2, e);