easy-tiler is a Python library for creating images of patterns made of tiles on a grid. It leverages Pycairo to produce high-quality PNG and SVG outputs.
Whether you're looking to generate geometric art, architectural patterns, or simple tiling textures, easy-tiler provides a flexible API and CLI to configure tile shapes, colors, and grid geometry.
from easy_tiler.io import save_png, save_svg
from easy_tiler.factories import make_tile_factory
from easy_tiler.grid import Grid
# Define a 8x6 grid with 80x80px cells
grid = Grid(8, 6, x_size=80, y_size=80)
# Create a factory for polygon tiles (default is a square)
factory = make_tile_factory(tile_type='polygon', bg='white', fg='random', sides=4, outline=False)
# Save as PNG and SVG
save_png('output.png', grid, factory)
save_svg('output.svg', grid, factory)This would produce an image of 8x6 squares with random colors, similar to the image below.
- Multiple Tile Types: Support for regular polygons (triangles, squares, etc.), Truchet tiles, Riley tiles, and Puck (circle-based) tiles.
- Configurable Grids: Define grid size, cell size, and origin.
- Advanced Geometry: Apply skew angles (shear) and shifts to create dynamic and complex tiling patterns.
- Pycairo Backend: High-performance rendering with support for transparency and vector/raster export.
- CLI Tool: Early-stage CLI for quick experimentation.
easy-tiler requires Python 3.13 or higher.
If you use uv, you can install the dependencies and the tool directly:
uv syncYou can install the dependencies manually using pip:
pip install pycairo pillow numpyHere is a simple example to render a grid of squares:
from easy_tiler.io import save_png, save_svg
from easy_tiler.factories import make_tile_factory
from easy_tiler.grid import Grid
# Define a 10x10 grid with 80x80px cells
grid = Grid(10, 10, x_size=80, y_size=80)
# Create a factory for polygon tiles (default is a square)
factory = make_tile_factory(tile_type='polygon', bg='white', fg='black', sides=4, outline=False)
# Save as PNG and SVG
save_png('output.png', grid, factory)
save_svg('output.svg', grid, factory)You can run the CLI entry point directly:
python -m easy_tilerOr, if installed:
easy-tiler- Build system: Uses
uv_build. - Linting & Formatting: Uses
Ruff. - Testing: Uses
pytest.
To run tests:
pytestThis project is authored by Joseph Barraud. See pyproject.toml for metadata.
