开发者

maintains position in any rotation

开发者 https://www.devze.com 2023-01-31 15:38 出处:网络
I have done some drawing on one layer now I want to draw same thing on another layer.So I have stored all the points of drawing that user has drawn on first layer.And then using convertPoint: toLayer

I have done some drawing on one layer now I want to draw same thing on another layer.So I have stored all the points of drawing that user has drawn on first layer.And then using convertPoint: toLayer: method converting stored point into points of another layer. And its working.But creates problem in orientation. If I have done 开发者_运维知识库drawing in portrait. Then it will work only for portrait in landscape position will be change. So please suggest any way to get out of this.

Thanks


Normalise your stored points, such that the x, y positions are relative to a surface of size 0..1, 0..1 (divide the x, y by the width and height of the current surface). Then, whenever you want to change the size of the underlying surface, multiply each point by this new surface's width and height. All points will now appear in the same relative positions regardless of the surface dimensions.

Note the above will scale (going from portrait to landscape, the Y will be compressed and the X expanded). If you don't want to do this, you will need to take physical dimensions of the surface on-screen into account too. That is, normalise your points to some physical dimension instead.

Note: I have no idea what system, language, package, library, etc. you are using as you don't state in your question!

0

精彩评论

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

关注公众号