我有一个矩形:Rect r = new Rect();.我想将r对象旋转到45度.我检查了解决方案,我发现它可以用矩阵完成:
Matrix m = new Matrix();
// point is the point about which to rotate.
m.setRotate(degrees, point.x, point.y);
m.mapRect(r);
问题是乳清我将r传递给m.mapRect(r);它抱怨r应该来自RectF类型.我成功地做到了:
RectF r2 = new RectF(r);
Matrix m = new Matrix();
// point is the point about which to rotate.
m.setRotate(degrees, point.x, point.y);
m.mapRect(r2);
但问题是我需要从Rect而不是RectF类型的对象.因为我将r对象传递给带有Rect对象的外部类.
有没有另一种方法来旋转矩形r表单类型Rect除了这个方法,没有rotateg整个画布(画布包含一些其他元素)?
先感谢您!
此致,Dimitar Georgiev