mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-10 04:00:23 +08:00
元素屏幕坐标乘以像素比
This commit is contained in:
parent
08831e7ce8
commit
dcfa1ff2a1
@ -1516,21 +1516,24 @@ class Locations(object):
|
|||||||
"""返回元素左上角在屏幕上坐标,左上角为(0, 0)"""
|
"""返回元素左上角在屏幕上坐标,左上角为(0, 0)"""
|
||||||
vx, vy = self._ele.page.rect.viewport_location
|
vx, vy = self._ele.page.rect.viewport_location
|
||||||
ex, ey = self.viewport_location
|
ex, ey = self.viewport_location
|
||||||
return vx + ex, ey + vy
|
pr = self._ele.page.run_js('return window.devicePixelRatio;')
|
||||||
|
return int((vx + ex) * pr), int((ey + vy) * pr)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def screen_midpoint(self):
|
def screen_midpoint(self):
|
||||||
"""返回元素中点在屏幕上坐标,左上角为(0, 0)"""
|
"""返回元素中点在屏幕上坐标,左上角为(0, 0)"""
|
||||||
vx, vy = self._ele.page.rect.viewport_location
|
vx, vy = self._ele.page.rect.viewport_location
|
||||||
ex, ey = self.viewport_midpoint
|
ex, ey = self.viewport_midpoint
|
||||||
return vx + ex, ey + vy
|
pr = self._ele.page.run_js('return window.devicePixelRatio;')
|
||||||
|
return int((vx + ex) * pr), int((ey + vy) * pr)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def screen_click_point(self):
|
def screen_click_point(self):
|
||||||
"""返回元素中点在屏幕上坐标,左上角为(0, 0)"""
|
"""返回元素中点在屏幕上坐标,左上角为(0, 0)"""
|
||||||
vx, vy = self._ele.page.rect.viewport_location
|
vx, vy = self._ele.page.rect.viewport_location
|
||||||
ex, ey = self.viewport_click_point
|
ex, ey = self.viewport_click_point
|
||||||
return vx + ex, ey + vy
|
pr = self._ele.page.run_js('return window.devicePixelRatio;')
|
||||||
|
return int((vx + ex) * pr), int((ey + vy) * pr)
|
||||||
|
|
||||||
def _get_viewport_rect(self, quad):
|
def _get_viewport_rect(self, quad):
|
||||||
"""按照类型返回在可视窗口中的范围
|
"""按照类型返回在可视窗口中的范围
|
||||||
|
Loading…
x
Reference in New Issue
Block a user