-
Notifications
You must be signed in to change notification settings - Fork 0
Window size
Omega Core edited this page May 19, 2024
·
8 revisions
code found in 'screenSize.py'
First element we'll discuss is the display window size. Although this may seem a simple part, we decided to do a more complicated implementation to let the user customize the size. The default window size is 1000px x 1500px
, which were the values use throughout the development.
Limitations were introduced, so that the user doesn't give an unethical dimension. Insead of clipping the input values to the margins, we tried to keep the aspect ratio the user gave, like a downscale of the values:
# snippet from 'screenSize.py'
def set(self,
width: int | None = None,
height: int | None = None):
# check width
if width is None:
self.width = default_screen_width
elif width > max_screen_width: # larged than max value --> resize
self.height = int(max_screen_width * height / width) # maintain ratio
self.width = max_screen_width
elif width < min_screen_width: # smaller than min value --> resize again
self.height = int(min_screen_width * height / width) # also maintain ratio
self.width = min_screen_width
else: self.width = width
# similar for height
In extreme cases, resizing can still get one of the values out of bounds. In this case, forget about the ratio, at least get them into the interval:
# recalculate if ratio isn't maintainable
if self.width > max_screen_width:
self.width = max_screen_width
elif self.width < min_screen_width:
self.width = min_screen_width
# similar for height