package com.example.sample;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import com.torn.toy.R;

public class SampleTouchView extends View implements View.OnTouchListener {
    Paint paint = new Paint();
    //画像読み込み
    Resources res = this.getContext().getResources();
    Bitmap neko = BitmapFactory.decodeResource(res, R.drawable.neko);

    Atom atom = new Atom(50, 50);

    public SampleTouchView(Context context) {
        super(context);
        setOnTouchListener(this);
    }
    //描画処理
    @Override
    public void onDraw(Canvas canvas) {
    	// 画像描画
//        canvas.drawBitmap(neko, 0, 0, paint);
        
        // タッチした点に円を描画
        paint.setColor(Color.GREEN);
    	canvas.drawCircle(atom.x, atom.y, 20, paint);
    }
    
    public void addAtom(float x, float y) {
    	atom.x = x;
    	atom.y = y;
    }

	public boolean onTouch(View v, MotionEvent event) {
		Log.v("tag", event.getX() + "," + event.getY());
		addAtom(event.getX(), event.getY());
		invalidate();
		return true;
	}
}