How to draw Arc between two points on the Canvas?

后端 未结 7 1220
渐次进展
渐次进展 2020-11-28 04:27

I have two points in the canvas, now I\'m able to draw a line between those points like this below image by using

This code canvas.drawLine(p1.x, p1.y, p2.x,

7条回答
  •  忘掉有多难
    2020-11-28 04:56

    A simple solution was suggested here by Langkiller. This draws a cubic line from the start point via the control point to the end point.

    Path path = new Path();
    float startX = 0;
    float startY = 2;
    float controlX = 2;
    float controlY = 4;
    float endX = 4
    float endY = 2
    conePath.cubicTo(startX, startY, controlX, controlY,endX, endY);
    
    Paint paint = new Paint();
    paint.setARGB(200, 62, 90, 177);
    paint.setStyle(Paint.Style.FILL);
    
    canvas.drawPath(path, paint)
    

提交回复
热议问题