6

enter image description here

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...

4

1 回答 1

5

您需要以下方式来获取更新点数组...

  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);
于 2013-09-19T10:33:11.720 回答