def convert_point(self,point=(0,0),from_view=None,to_view=None):
'''fixed convert point for fullscreen application.
works for any present type
existing function in fullscreen reports relative to portrait
TODO: does not work if from_view or to_view has been Transformed'''
(w,h)=ui.get_screen_size()
#detect what convert_point things rotation is.
origin=ui.convert_point((0,0),from_view,to_view )
xaxis=ui.convert_point((1,0),from_view,to_view )
xaxis=[xaxis[j]-origin[j] for j in (0,1)]
yaxis=ui.convert_point((0,1),from_view,to_view )
yaxis=[yaxis[j]-origin[j] for j in (0,1)]
pt_c=ui.convert_point(tuple(point),from_view,to_view)
pt=[0,0]
if from_view is not None:
pt[0]=( (xaxis[0]==-1)*h
+ xaxis[0]*pt_c[0]
+ (yaxis[0]==1)*w
- yaxis[0]*pt_c[1])
pt[1] = ( (xaxis[1]==1)*h
- xaxis[1]*pt_c[0]
+ (yaxis[1]==-1)*w
+ yaxis[1]*pt_c[1])
else: #just get corrected origin, and subtract out
origin_offset=self.convert_point((0,0),to_view,from_view)
pt[0]= point[0] - origin_offset[0]
pt[1]= point[1] - origin_offset[1]
return tuple(pt)
fixed_convert_and_kbframe.py 文件源码
python
阅读 26
收藏 0
点赞 0
评论 0
评论列表
文章目录