本文介绍了画上一个完美的曲线连接三个点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想绘制一条曲线连接三个点在我的屏幕
PointA =(480,46)PointB =(160137)PointC =(0228)

I would like to draw a curve connecting three points in my screen
PointA = (480,46)PointB = (160,137)PointC = (0,228)

如何使用Android的API来绘制曲线?
请帮助..

How to draw the curve using Android APIs ?
Please Help..

谢谢,

推荐答案

无论我想,我可以通过以下code生产它:

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

protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    PointF mPoint1 = new PointF(w/1.2F, h/1.2F);
    PointF mPoint2 = new PointF(w/24, h/1.2F);
    Path myPath1 = new Path();
    Paint paint  = new Paint();
    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) {

    Path myPath = new Path();
    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.

这篇关于画上一个完美的曲线连接三个点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 01:20