When young children learn how to count, they need to understand that the position of the objects doesn't matter. For example, if I show 10 objects in a line, and then move them around to form a circle, there are still 10 objects!
All scripts are implemented in Python. I've only tested this with Python 2.7.12. There are 2 dependencies to external libraries that are not included in the Python standard library:
Pillow
- an imaging library used to create visual representation of the layoutmock
- mocking library used in unit tests
To install all 3rd-party dependencies run:
$ pip install -r requirements.txt
To interact with the layout generator you can use the provided
main.py
CLI script. To list all the available options use -h
command line switch:
$ python main.py -h
usage: main.py [-h] [-t {horizontal_line,random,grid,circle}] [-r RADIUS]
width height num_items
Arrange circles of RADIUS in the selected layout.
positional arguments:
width container width
height container height
num_items number of items to add to container
optional arguments:
-h, --help show this help message and exit
-t {horizontal_line,random,grid,circle}, --layout-type {horizontal_line,random,grid,circle}
type of layout to generate. default: horizontal_line
-r RADIUS, --radius RADIUS
radius of the items. default: 10px
This script prints out coordinates of items laid out in different layouts within the container of specified size. The format of the output is:
[(x0, y0, r0), (x1, y1, r1), (xN, yN, rN), ...]
The layout image is also saved as bitmap file in plot.bmp
and placed
in the current working directory.
If the number of items can't be arranged in the container of specified size or the items would overlap then an error message will be printed.
Example layouts:
$ make test