terminal_menu/utils.py

24 lines
705 B
Python
Raw Normal View History

2023-05-27 06:40:09 -04:00
def render(pos: int, min: int, max: int, render_distance: int, elements: list):
start = pos - render_distance;
if (start < min):
start = min;
stop = pos + render_distance + 1;
if (stop > max):
stop = max;
i = 0;
y = pos - start;
if (y < min):
y = pos ;
return (start, stop, y);
def get_sizes(size1: int, size2: int, total_size: int, aim_ratio: float):
if (size1 + size2 < total_size):
return (size1, size2);
if (size1 > total_size * aim_ratio):
size1 = total_size * aim_ratio;
if (size2 > total_size - size1):
size2 = total_size - size1;
size1 = int(size1);
size2 = int(size2)
return (size1, size2);