Debian Codegraph @

tests/android/webview/screen.py

raw
1 class Screen:
2 def __init__(
3 self, x: int, y: int, width: int, height: int, frame: object = None, scale: float = 1.0
4 ) -> None:
5 self.x = int(x)
6 self.y = int(y)
7 self.width = int(width)
8 self.height = int(height)
9 self.frame = frame
10 self.scale = float(scale)
11
12 @property
13 def physical_x(self) -> int:
14 """X coordinate in physical pixels."""
15 return int(self.x * self.scale)
16
17 @property
18 def physical_y(self) -> int:
19 """Y coordinate in physical pixels."""
20 return int(self.y * self.scale)
21
22 @property
23 def physical_width(self) -> int:
24 """Width in physical pixels."""
25 return int(self.width * self.scale)
26
27 @property
28 def physical_height(self) -> int:
29 """Height in physical pixels."""
30 return int(self.height * self.scale)
31
32 @property
33 def dpi(self) -> int:
34 """DPI (dots per inch) for this screen."""
35 return int(self.scale * 96)
36
37 def __str__(self) -> str:
38 return repr(self)
39
40 def __repr__(self) -> str:
41 scale_str = f' {self.scale:.2f}x' if self.scale != 1.0 else ''
42 return f'{self.width}x{self.height} at {self.x},{self.y}{scale_str}'