Reputation: 91
I have a shape e-g, Rectanle and i want to rotate it at an angle X and want to get the updated rotated points of shape.
Currently for rotation of object i am using canvas.rotate, but the original points remains the same; not the rotated one. I am using this code.
canvas.save();
canvas.rotate(angle, Pivate.x, Pivate.y);
canvas.drawRect(left, top, right, bottom, redPaint);
canvas.restore();
Any help will be appreciated...
Upvotes: 6
Views: 1004
Reputation: 9217
You need the following way to get update array of points...
float[] ptArr = new float[] { 20, 30, 60, 30, 60, 45, 20, 45};
Matrix m = new Matrix();
m.preRotate(angle, px, py); // where px and py is pivot point.
m.mapPoints(ptArr);
//at this point your array will be updated.
canvas.drawPoints(ptArr, mPaint);
Upvotes: 5