doodles-py/src/doodles/layouts.py

14 lines
395 B
Python
Raw Normal View History

2024-04-22 03:10:04 +00:00
def make_grid(iterable, cols, rows, width, height, *, x_offset=0, y_offset=0):
"""
Arranges the objects in iterable in a grid with the given parameters.
"""
try:
for c in range(cols):
for r in range(rows):
doodle = next(iterable)
2024-04-22 05:11:55 +00:00
doodle.pos(width * c + x_offset, height * r + y_offset)
2024-04-22 03:10:04 +00:00
except StopIteration:
pass