Search code examples
androidrotationdrawablerotational-matrices

Rotate Bitmap and New location Android


I have created a canvas and draw a bitmap on it, and animate it every time I touch the canvas

i have set the bounds of the bit map on the start of drawing but after I change the rotation matrix and rotate the bit map it does not change the bounds based on the new matrix

I need to reset the bounds of my bitmap to be able to use it as a clickable object and fire some event when click on it

how can I update the bounds based on the rotation matrix

Thanks in Advance


Solution

  • I have used these equation to re calculate the new position after rotation

    newx = (oldx * cos(angle)) + (oldy * - sin(angle))

    newy = (oldy * sin(angle)) + (oldy * cos(angle))