Finding a point after android canvas rotation

2019-05-31 02:47发布

问题:

Background info:

Using the android canvas and the onDraw() method, I draw a Rect with a small bitmap. Using onTouchEvent() I calculate a rotation on the canvas and do the following.

@Override
protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
        canvas.rotate((float)mAngle, mBorderRect.centerX(), mBorderRect.centerY());
        canvas.drawBitmap(mCloseBitmap, null, mCloseRect, null);    
}

After the canvas is rotated, the Rect still has the same left, top, right, bottom coordinates. So, when I touch the screen it doesn't register that the rect has been touched.

Question:

If I know the angle of rotation and the original XY coordinates, how do I calculate the new XY coordinates after the rotation has occurred? (Math isn't my strong suit)