I want to draw a curve according to a control points list.
This is what I expected:
Here are the control points: (0,90) (1,100) (-3,145) (10,150) (23,155) (73,108) (80,120) (86,131) (40,210) (50,220) (60,230) (148,185) (140,180) (131,175) (23,188) (0,190)
Here is my code:
public List<PointType> controlPoints;
public void render(Canvas canvas, Paint paint) {
int size = controlPoints.size();
if (size < 2) {
return;
}
paint.setColor(this.color);
paint.setStyle(this.style);
Path curvePath = new Path();
PointType firstPoint = null;
PointType beginPoint = null;
for (PointType point : controlPoints) {
if (firstPoint == null) {
firstPoint = point;
} else if (beginPoint == null) {
beginPoint = point;
} else {
curvePath.moveTo(firstPoint.x, firstPoint.y);
curvePath.quadTo(beginPoint.x, beginPoint.y, point.x, point.y);
firstPoint = beginPoint;
beginPoint = point;
}
}
canvas.drawPath(curvePath, paint);
}
But the result is this:
What's wrong and How can I draw the correct curve?