gpt4 book ai didi

android - 画出连接三点的完美曲线

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:00:29 27 4
gpt4 key购买 nike

我想在屏幕上画一条连接三点的曲线

PointA = (480,46)
PointB = (160,137)
PointC = (0,228)

如何使用Android API绘制曲线?

最佳答案

无论我想要什么,我都可以使用以下代码生成它:

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;
}

这将找到屏幕的两侧(横向模式)并在屏幕上绘制一条完美的曲线。

关于android - 画出连接三点的完美曲线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3811529/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com