File: Broken/Core/BrokenResolution.py
¶
Broken.Core.BrokenResolution ¶
BrokenResolution ¶
Source code in Broken/Core/BrokenResolution.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
round ¶
round(
*numbers: Number, multiple: int = 2
) -> Union[int, tuple[int, ...]]
Round to the nearest multiple of 2, returns a single value or a tuple of values
Source code in Broken/Core/BrokenResolution.py
11 12 13 14 15 |
|
fit ¶
fit(
old: Optional[tuple[int, int]] = None,
new: Optional[tuple[int, int]] = None,
max: Optional[tuple[int, int]] = None,
ar: Optional[float] = None,
scale: float = 1.0,
multiple: int = 2,
) -> tuple[int, int]
Fit, Scale and optionally force Aspect Ratio on a base to a (un)limited target resolution
This method solves the following problem
"A window is at some initial size (ow, oh) and a resize was asked to (nw, nh); what final resolution the window should be, optionally enforcing an aspect ratio (ar), and limited by the monitor resolution (mw, mh)?"
To which, the behavior is as follows in the two branches: No aspect ratio (ar=None) is send: - Returns the original resolution overridden by any new (nw, nh)
1 2 3 4 |
|
Notes¶
1 |
|
Parameters¶
old : tuple[int, int] or None Old resolution new : tuple[int, int] or None New resolution max : tuple[int, int] or None Maximum resolution scale : float or None Scale factor ar : float or None Force aspect ratio, if any
Returns¶
(int, int) The new best-fit width and height
Source code in Broken/Core/BrokenResolution.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|