factoriax.playground.ui.window

factoriax.playground.ui.window#

Window sizing utilities for pygame applications.

factoriax.playground.ui.window.auto_ui_scale(base_size: int = 1024) → int#

Pick the highest UI scale where the canvas fits the monitor.

Returns the largest integer s in {3, 2, 1} such that base_size * s fits within 80% of the monitor on both axes.

Parameters:

base_size – Logical base resolution (default 1024).

Return type:

Integer scale factor (1, 2, or 3).

factoriax.playground.ui.window.calculate_window_size(base_width: int, base_height: int, scale_factor: float = 0.8) → tuple[int, int]#

Calculate window size using integer scaling for crisp pixel art.

Uses the largest integer scale factor that fits within scale_factor (default 80%) of the screen.

Parameters:
  • base_width – Base render width in pixels.

  • base_height – Base render height in pixels.

  • scale_factor – Fraction of screen to use (0.0 to 1.0).

Return type:

(window_width, window_height) in pixels.