Android上的图形:具有平滑曲线的路径? [英] Graphics on Android: path with smooth curves?
本文介绍了Android上的图形:具有平滑曲线的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想为函数y = x ^ 2绘制图表,如下所示:
I want to draw a chart for a function y=x^2 as follows:
但是曲线不平滑,因为它是一组连接的线.
but the curve is not smooth as it is a set of connected lines.
如何使曲线更平滑?
谢谢
推荐答案
您应仅将 Path.quadTo
与一个 Path
一起使用.如果您已经在执行此操作,那么建议您增加图表上的点数.
You should use Path.quadTo
with only one Path
. If you are already doing this then I suggest increasing the number of points on the graph.
移动到 Path
的开头:
Path.moveTo(x, y)
在中间:
Path.quadTo(lastX, lastY, (x + lastX)/2, (y + lastY)/2)
,最后:
Path.lineTo(x, y)
这篇关于Android上的图形:具有平滑曲线的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文