开发者

Canvas and bitmap

开发者 https://www.devze.com 2023-04-12 05:10 出处:网络
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开发者_JS百科 canvas region so how to solv

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开发者_JS百科 canvas region so how to solve this problem related to boundry of canvas. Please help me out on this and Thanks in advance.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号