It also move its implemented code to VPath::VPathData from VPath.
Change-Id: Idc6f04e04930f1863bb78fd1a05ba86c573e328b
path.addOval(VRectF(300, 100, 100, 50), VPath::Direction::CCW);
- path.addPolystarStar(0.0, 150, 150, 15.0,
- 106.0, 34.0,
- 231.0, 88.0, VPath::Direction::CW);
-
+ path.addPolystar(15.0, 106.0, 34.0, 0.0, 150,
+ 150, 231.0, 88.0, VPath::Direction::CW);
PathTest test(APP);
test.setPath(path);
VMatrix m;
if (mData->mType == LOTPolystarData::PolyType::Star) {
- path.addPolystarStar(0.0, 0.0, 0.0, points,
- innerRadius, outerRadius,
- innerRoundness, outerRoundness,
- mData->direction());
+ path.addPolystar(points, innerRadius, outerRadius,
+ innerRoundness, outerRoundness,
+ 0.0, 0.0, 0.0, mData->direction());
} else {
- path.addPolystarPolygon(0.0, 0.0, 0.0, points,
- outerRadius, outerRoundness,
- mData->direction());
+ path.addPolygon(points, outerRadius, outerRoundness,
+ 0.0, 0.0, 0.0, mData->direction());
}
m.translate(pos.x(), pos.y()).rotate(rotation);
return startPoint;
}
-void VPath::addPolystarStar(float startAngle, float cx, float cy, float points,
- float innerRadius, float outerRadius,
- float innerRoundness, float outerRoundness,
- VPath::Direction dir)
+void VPath::VPathData::addPolystar(float points, float innerRadius, float outerRadius,
+ float innerRoundness, float outerRoundness,
+ float startAngle, float cx, float cy, VPath::Direction dir)
{
const static float POLYSTAR_MAGIC_NUMBER = 0.47829 / 0.28;
float currentAngle = (startAngle - 90.0) * M_PI / 180.0;
currentAngle += halfAnglePerPoint * angleDir;
}
- VPathData &ref = d.write();
-
- ref.moveTo(VPointF(x + cx, y + cy));
+ moveTo(VPointF(x + cx, y + cy));
for (int i = 0; i < numPoints; i++) {
float radius = longSegment ? outerRadius : innerRadius;
y = (float) (radius * sin(currentAngle));
if (innerRoundness == 0 && outerRoundness == 0) {
- ref.lineTo(VPointF(x + cx, y + cy));
+ lineTo(VPointF(x + cx, y + cy));
} else {
float cp1Theta = (float) (atan2(previousY, previousX) - M_PI / 2.0 * angleDir);
float cp1Dx = (float) cos(cp1Theta);
cp2y *= partialPointAmount;
}
- ref.cubicTo(VPointF(previousX - cp1x + cx, previousY - cp1y + cy),
- VPointF(x + cp2x + cx, y + cp2y + cy),
- VPointF(x + cx, y + cy));
+ cubicTo(VPointF(previousX - cp1x + cx, previousY - cp1y + cy),
+ VPointF(x + cp2x + cx, y + cp2y + cy),
+ VPointF(x + cx, y + cy));
}
currentAngle += dTheta * angleDir;
close();
}
-void VPath::addPolystarPolygon(float startAngle, float cx, float cy, float points,
- float radius, float roundness,
- VPath::Direction dir)
+void VPath::VPathData::addPolygon(float points, float radius, float roundness,
+ float startAngle, float cx, float cy, VPath::Direction dir)
{
// TODO: Need to support floating point number for number of points
const static float POLYGON_MAGIC_NUMBER = 0.25;
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 addRect(const VRectF &rect, VPath::Direction dir = Direction::CW);
- void addPolystarStar(float startAngle, float cx, float cy, float points,
- float innerRadius, float outerRadius,
- float innerRoundness, float outerRoundness,
- VPath::Direction dir = Direction::CW);
- void addPolystarPolygon(float startAngle, float cx, float cy, float points,
- float radius, float roundness,
- VPath::Direction dir = Direction::CW);
+ void addPolystar(float points, float innerRadius, float outerRadius,
+ float innerRoundness, float outerRoundness,
+ float startAngle, float cx, float cy, VPath::Direction dir = Direction::CW);
+ void addPolygon(float points, float radius, float roundness,
+ float startAngle, float cx, float cy, VPath::Direction dir = Direction::CW);
void transform(const VMatrix &m);
const std::vector<VPath::Element> &elements() const;
const std::vector<VPointF> &points() const;
void arcTo(const VRectF&, float, float, bool);
void addCircle(float, float, float, VPath::Direction);
void addOval(const VRectF &, VPath::Direction);
+ void addPolystar(float points, float innerRadius, float outerRadius,
+ float innerRoundness, float outerRoundness,
+ float startAngle, float cx, float cy, VPath::Direction dir = Direction::CW);
+ void addPolygon(float points, float radius, float roundness,
+ float startAngle, float cx, float cy, VPath::Direction dir = Direction::CW);
const std::vector<VPath::Element> &elements() const { return m_elements;}
const std::vector<VPointF> &points() const {return m_points;}
std::vector<VPointF> m_points;
d.write().addOval(rect, dir);
}
+inline void VPath::addPolystar(float points, float innerRadius, float outerRadius,
+ float innerRoundness, float outerRoundness,
+ float startAngle, float cx, float cy, VPath::Direction dir)
+{
+ d.write().addPolystar(points, innerRadius, outerRadius,
+ innerRoundness, outerRoundness,
+ startAngle, cx, cy, dir);
+}
+
+inline void VPath::addPolygon(float points, float radius, float roundness,
+ float startAngle, float cx, float cy, VPath::Direction dir)
+{
+ d.write().addPolygon(points, radius, roundness,
+ startAngle, cx, cy, dir);
+}
+
inline const std::vector<VPath::Element> &VPath::elements() const
{
return d->elements();