0

I have a bitmap drawn on a canvas attached to a View with clipChildren = false. So, I am drawing this bitmap outside the view bounds on the canvas.

canvas.drawBitmap(mBitmap, null, rect1, null);

Also, I have defined a destination Rect (rect1) for my bitmap which encapsulates its bounds and position. So far so good.

Now onTouch / onSwipe on this View, I want to animate this bitmap which I can only do frame by frame by post invalidating the view and redrawing in onDraw.

I also have another Rect (rect2), which should be the new destination Rect of my bitmap post animation.

Question : How can I animate from rect1 to rect2 by re-drawing the bitmap frame by frame on canvas ?

Help me!

Community
  • 1
  • 1
himanshurb
  • 1,115
  • 1
  • 12
  • 22
  • Why don't you interpolate a temp/variable rect from rect 1 to rect 2 coordinates ? http://en.wikipedia.org/wiki/Linear_interpolation#Linear_interpolation_between_two_known_points – Snicolas Apr 22 '14 at 15:29
  • Currently I am trying that only. Is there anything else possible because my basic problem is to translate and scale my bitmap simultaneously (rect2 is smaller than rect1 and at a diff location). Any suggestions ? – himanshurb Apr 22 '14 at 15:34
  • If you interpolate the coordinates, it will also interpolate the size. Show this code and modify your question. – Snicolas Apr 22 '14 at 15:35
  • Thanks. I will post as soon as I am done. I will interpolate with a min step dx and dy value, depending upon the animation duration. – himanshurb Apr 22 '14 at 15:37

0 Answers0