请在下面找到我的onDraw方法的代码(。我试图在绘制圆弧后旋转画布(//旋转调用-b)25度,但是我发现圆弧仍然是从0到50 degrees.I期待它被另一个25度移动。Android中的Canvas.rotate()问题。它是如何工作的?
public class CustomView extends View {
public CustomView(Context context) {
super(context);
}
public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
}
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
paint.setColor(Color.RED);
int px = getMeasuredWidth()/2;
int py = getMeasuredHeight()/2;
// radius - min
int radius = 130;
// Defining bounds for the oval for the arc to be drawn
int left = px - radius;
int top = py - radius;
int right = left + (radius * 2);
int bottom = top + (radius * 2);
RectF rectF = new RectF(left, top, right, bottom);
paint.setColor(Color.RED);
paint.setStyle(Style.FILL);
//canvas.rotate(25,px,py);//Rotate call -a
canvas.drawArc(rectF, 0, 50, true, paint);
canvas.rotate(25,px,py);//Rotate call -b
}
}
但是,如果我画弧前放置旋转呼叫(//调用旋转-a)我看到,所描绘的圆弧由25度移更准确。什么这里发生了什么?有人能解释一下吗?
感谢