【发布时间】:2016-05-26 14:54:52
【问题描述】:
我正在尝试在 android 中绘制弧线。 在IOS中,用这种方法真的很容易做到
[path addArcWithCenter: radius: startAngle: endAngle: clockwise:]
在 android 中,我有 3 个点(我的圆心,以及我想在两个点之间画弧线的点):
Point center = new Point(..., ...);
Point p1 = new Point(..., ...);
Point p2 = new Point(..., ...);
int radius = (int) Math.sqrt(Math.pow(p1.x - center.x, 2) + Math.pow(p1.y - center.y, 2));
但是如何使用 Path.addArc 方法在 p1 和 p2 之间绘制弧线? 我已经尝试过 (How to draw Arc between two points on the Canvas?) 中所说的:
RectF oval = new RectF();
oval.set(p2.x - radius, p2.y - radius, p2.x + radius, p2.y + radius);
path.addArc(oval, startAngle, endAngle - startAngle);
// startAngle : angle between horizontal axis and p1 point
// endAngle : angle between horizontal axis and p2 point
但实际上它并没有画出预期的弧线。我不明白 addArc 方法的第一个参数是什么! RectF 应该是什么?
谢谢,
【问题讨论】:
标签: android path android-canvas ondraw