I spent way to much time on this, but it will come in useful for my app.
My idea was to set the point and draw around it, so all you have to do is change linex and liney
How else did you get on?
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
paint.setColor(mContext.getResources().getColor(R.color.black));
Path path = new Path();
int left = 50;
int top = 50;
int right = getWidth()- 50;
int bottom = getHeight()-50;
int linex = getWidth()/2;
int liney = getHeight();
int openSize = 20;
RectF rectf = new RectF(left, top, right, bottom);
int angle = (int) angle(new Point(getWidth()/2, getHeight()/2), new Point(linex,liney));
int startAngle = angle + (openSize/2);
int sweepAngle = 360 - openSize;
path.arcTo(rectf, startAngle, sweepAngle);
path.lineTo(linex, liney);
path.close();
canvas.drawPath(path, paint);
}
private double angle(Point point1, Point point2) {
double deltaX = (point1.x - point2.x);
double deltaY = (point1.y - point2.y);
double angle = Math.toDegrees(Math.atan2(deltaY, deltaX));
if (angle < 0) {
angle += 360;
}
if (angle > 360) {
angle -= 360;
}
// Compensate for 0
angle -= 180;
return angle;
}