Finding a point after android canvas rotation

痞子三分冷 提交于 2019-12-08 07:46:50

问题


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)

来源:https://stackoverflow.com/questions/23689111/finding-a-point-after-android-canvas-rotation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!