Skip to content Skip to sidebar Skip to footer

Draw A Perfect Curve Connecting Three Points

I would like to draw a curve connecting three points in my screen PointA = (480,46) PointB = (160,137) PointC = (0,228) How to draw the curve using Android APIs ? Please Help.. Tha

Solution 1:

Whatever i wanted, i could to produce it by using the following code :

protectedvoidonDraw(Canvas canvas) {
    super.onDraw(canvas);

    PointFmPoint1=newPointF(w/1.2F, h/1.2F);
    PointFmPoint2=newPointF(w/24, h/1.2F);
    PathmyPath1=newPath();
    Paintpaint=newPaint();
    paint.setAntiAlias(true);
    paint.setStyle(Style.STROKE);
    paint.setStrokeWidth(2);
    paint.setColor(Color.WHITE);

    myPath1 = drawCurve(canvas, paint, mPoint1, mPoint2);
    canvas.drawPath(myPath1, paint);

}

private Path drawCurve(Canvas canvas, Paint paint, PointF mPointa, PointF mPointb) {

    PathmyPath=newPath();
    myPath.moveTo(63*w/64, h/10);
    myPath.quadTo(mPointa.x, mPointa.y, mPointb.x, mPointb.y);
    return myPath;  
}

This will find the two sides of the screen (Landscape mode) and will draw a perfect curve across the screen.

Post a Comment for "Draw A Perfect Curve Connecting Three Points"