Rocker
Rocker

Reputation: 681

Canvas and bitmap

I have a canvas and I am drawing bitmap into it and moving that bitmap using onTouchEvent method. My problem is that the bitmap I move sometimes go out of the canvas region so how to solve this problem related to boundry of canvas. Please help me out on this and Thanks in advance.

Upvotes: 1

Views: 865

Answers (2)

Lumis
Lumis

Reputation: 21639

When you move the finger over the screen, you set the x,y drawing coordinates for your bitmap. Since you can know the size of the canvas from onSizeChanged method, you just need to make an if statement which will change the drawing coordinates of this bitmap only if the finger is within the area you want.

Upvotes: 1

Dat Tran
Dat Tran

Reputation: 136

From the distance of current position and the base position calculate from your algorithm, you could able to manage this problem. It's only your algorithm problem.

Upvotes: 0

Related Questions