如何绘制二次曲线或三角曲线(例如sin(x)
) on a Canvas http://developer.android.com/reference/android/graphics/Canvas.html?
像你一样,我需要从point(x1, y1)
to point (x2, y2)
。我做了一些搜索,这导致我找到了 Path 类(android.graphics.Path
)。 Path 有多种绘制线条的方法。创建路径后,您可以使用绘制方法来绘制实际的线。路径可以旋转、变换、保存和添加。此类还可以绘制圆弧、圆形和矩形。
http://developer.android.com/reference/android/graphics/Path.html http://developer.android.com/reference/android/graphics/Path.html
设置路径起点→mPath.moveTo(x1, y1);
设置常数和终点 →mPath.quadTo(cx, cy, x2, y2);
将路径转换为直线 →canvas.drawPath(mPath, mPaint);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)