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; if (stop - start != render_distance * 2 + 1): if (pos - start != render_distance): stop = stop + render_distance - start - pos # elif (stop + render_distance > max): # start = start - (stop + render_distance - max) 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);