以下に示す画像などの画像があります。
この画像には、幅Wと高さLのサイズのパーツ 1 と、幅wと高さhのパーツ 2 (小さい部分) の2 つのパーツがあります (パーツ 1 をソース、パーツ 2 を宛先と呼びます)。1 番目の長方形の座標を (左上隅から測定して): 上:100 左: 10 右: 200 下: 300 とし、2 番目の長方形の座標を (左上隅から測定して): 上 50 左: 500 とします。下: 100 右: 700
画像がソースから宛先に移動してズームインするように、ソースから宛先にアニメーション化したいと考えています。
したがって、最初の画面は次のようになります。
私の2番目の画像は次のようになります。
これら 2 つの間をトゥイーンするにはどうすればよいですか? 私のコード(アニメーションなし)は次のようになります。
public class SuperGame extends View implements OnGestureListener
{
int sreenHeight, screenWidth;
int drawCount = 0;
Bitmap bg;
public SuperGame(Context context, Bitmap bmp)
{
this.screenWidth = getContext().getResources().getDisplayMetrics().widthPixels;
this.screenHeight = getContext().getResources().getDisplayMetrics().heightPixels;
bg = BitmapFactory.decodeResource(getResources(),R.drawable.bg_img);
}
@Override
/* this function triggers the image change
*/
public boolean onDown(MotionEvent e) {
invalidate(0,0,screenWidth, screenHeight);
return true;
}
@Override
public void onDraw(Canvas canvas)
{
Rect dest = new Rect(0,0,screenWidth, screenHeight);
if (count==0) //draw the first image part
{
count=1;
Rect src = new Rect(100,10,200,300);//coordinates of rectangle 1
canvas.drawBitmap(bg, src, dest, new Paint());
}
else //draw the second image part - (I'd like to show movement/ transition between these)
{
Rect src = new Rect(50,500,100,700);//coordinates of rectangle 2
count=0;
canvas.drawBitmap(bg, src, dest, new Paint());
}
}
}
トランジションをアニメーション化するにはどうすればよいですか (これにはズームインと翻訳が含まれます)。