easy-tiler 1.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,208 @@
1
+ Metadata-Version: 2.3
2
+ Name: easy-tiler
3
+ Version: 1.0.3
4
+ Summary: Library for tiling and patterns
5
+ Author: Joseph Barraud
6
+ Author-email: Joseph Barraud <joseph.barraud@gmail.com>
7
+ Requires-Dist: pycairo>=1.23.0
8
+ Requires-Dist: pillow>=12.3.0
9
+ Requires-Dist: numpy>=2.5.2
10
+ Requires-Dist: colorcet>=3.1.0
11
+ Requires-Dist: pypalettes>=0.2.1
12
+ Requires-Dist: pyyaml>=6.0.3
13
+ Requires-Python: >=3.13
14
+ Description-Content-Type: text/markdown
15
+
16
+ # easy-tiler
17
+
18
+ [![Ruff](https://github.com/jobar8/easy-tiler/actions/workflows/ruff.yml/badge.svg)](https://github.com/jobar8/easy-tiler/actions/workflows/ruff.yml)
19
+ [![Pytest](https://github.com/jobar8/easy-tiler/actions/workflows/pytest.yml/badge.svg)](https://github.com/jobar8/easy-tiler/actions/workflows/pytest.yml)
20
+ [![Publish to PyPI](https://github.com/jobar8/easy-tiler/actions/workflows/release.yml/badge.svg)](https://github.com/jobar8/easy-tiler/actions/workflows/release.yml)
21
+
22
+ **easy-tiler** is a Python library for creating images of patterns made of tiles on a grid. It leverages [Pycairo](https://pycairo.readthedocs.io/) to produce high-quality PNG and SVG outputs.
23
+
24
+ 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.
25
+
26
+ ## Examples
27
+
28
+ ### Polygon Tiles
29
+
30
+ ```python
31
+ from easy_tiler.io import save_png, save_svg
32
+ from easy_tiler.factories import make_tile_factory
33
+ from easy_tiler.grid import Grid
34
+
35
+ # Define a 8x6 grid with 80x80px cells
36
+ grid = Grid(8, 6, x_size=80, y_size=80)
37
+
38
+ # Create a factory for polygon tiles (default is a square)
39
+ factory = make_tile_factory(
40
+ tile_type='polygon', secondary_color='white', primary_color='random', sides=4, gridlines=False
41
+ )
42
+
43
+ # Save as PNG and SVG
44
+ save_png('output.png', grid, factory)
45
+ save_svg('output.svg', grid, factory)
46
+ ```
47
+
48
+ This would produce an image of 8x6 squares with random colors, similar to the image below.
49
+
50
+ ![Polygon Tiles](examples/images/example_v1.png)
51
+
52
+ ### Sequence of Tiles
53
+
54
+ Use `make_sequence_factory` to repeat a sequence of tile rotations across each row. The
55
+ foreground and background colors can also be selected from a palette for each position in
56
+ the sequence.
57
+
58
+ ```python
59
+ from easy_tiler.factories import make_sequence_factory
60
+ from easy_tiler.grid import Grid
61
+ from easy_tiler.io import save_png, save_svg
62
+
63
+ # Define a 12x10 grid with 60x60px cells
64
+ grid = Grid(12, 10, x_size=60, y_size=60)
65
+
66
+ # Repeat four Riley tile rotations with palette-based colors
67
+ factory = make_sequence_factory(
68
+ tile_type='riley',
69
+ tile_sequence=[2, 2, 3, 3, 1, 0],
70
+ primary_color='sequence',
71
+ secondary_color='roll',
72
+ palette='ColorsOfTheWind',
73
+ )
74
+
75
+ save_png('sequence_demo.png', grid, factory)
76
+ save_svg('sequence_demo.svg', grid, factory)
77
+ ```
78
+
79
+ Here, `tile_sequence` controls the repeating rotation pattern, while `primary_color='sequence'` and
80
+ `secondary_color='roll'` vary the tile colors across the sequence. This would produce an images similar this
81
+ one:
82
+
83
+ ![Sequence Patterns](examples/images/sequence_demo.png)
84
+
85
+ ## Key Features
86
+
87
+ - **Multiple Tile Types**: Support for regular polygons (triangles, squares, etc.), Truchet tiles, Riley tiles, and Puck (circle-based) tiles.
88
+ - **Configurable Grids**: Define grid size, cell size, and origin.
89
+ - **Advanced Geometry**: Apply skew angles (shear) and shifts to create dynamic and complex tiling patterns.
90
+ - **Pycairo Backend**: High-performance rendering with support for transparency and vector/raster export.
91
+ - **CLI Tool**: Render configured PNG and SVG patterns from YAML.
92
+
93
+ ## Installation
94
+
95
+ `easy-tiler` requires Python 3.13 or higher.
96
+
97
+ ### From PyPI
98
+
99
+ Install the released package from PyPI with [uv](https://github.com/astral-sh/uv):
100
+
101
+ ```bash
102
+ uv tool install easy-tiler
103
+ ```
104
+
105
+ Or use pip:
106
+
107
+ ```bash
108
+ pip install easy-tiler
109
+ ```
110
+
111
+ ### From a cloned repository
112
+
113
+ To install `easy-tiler` with `uv sync`, first clone the repository and run the command from the repository root:
114
+
115
+ ```bash
116
+ git clone https://github.com/jobar8/easy-tiler.git
117
+ cd easy-tiler
118
+ uv sync
119
+ ```
120
+
121
+ ## Quick Start
122
+
123
+ ### Python API
124
+
125
+ Here is a simple example to render a grid of squares:
126
+
127
+ ```python
128
+ from easy_tiler.io import save_png, save_svg
129
+ from easy_tiler.factories import make_tile_factory
130
+ from easy_tiler.grid import Grid
131
+
132
+ # Define a 10x10 grid with 80x80px cells
133
+ grid = Grid(10, 10, x_size=80, y_size=80)
134
+
135
+ # Create a factory for polygon tiles (default is a square)
136
+ factory = make_tile_factory(
137
+ tile_type='polygon', secondary_color='white', primary_color='black', sides=4, gridlines=False
138
+ )
139
+
140
+ # Save as PNG and SVG
141
+ save_png('output.png', grid, factory)
142
+ save_svg('output.svg', grid, factory)
143
+ ```
144
+
145
+ ### CLI Usage
146
+
147
+ Create a YAML file with grid, factory, and output settings:
148
+
149
+ ```yaml
150
+ grid:
151
+ width: 8
152
+ height: 6
153
+ x_size: 80
154
+ y_size: 80
155
+
156
+ factory:
157
+ type: tile # tile, sequence, node, or form
158
+ tile_type: circle
159
+ primary_color: [blue, red, green, brown]
160
+ secondary_color: white
161
+ radius: 0.3
162
+ stroke: true
163
+ stroke_color: black
164
+ palette: FridaKahlo
165
+ num_colors: 5
166
+
167
+ output:
168
+ path: images/circle-pattern # output basename, relative to this YAML file
169
+ formats: [png, svg] # either, or both
170
+ scale: 1
171
+ background_col: white
172
+ ```
173
+
174
+ Run the installed command with the config path:
175
+
176
+ ```bash
177
+ easy-tiler pattern.yaml
178
+ ```
179
+
180
+ The output section's `formats` defaults to `[png, svg]`. The selected formats are
181
+ written with matching extensions; `output.path` is a basename, and its parent
182
+ directory is created if needed. Paths that are not absolute are resolved relative
183
+ to the YAML file. Output settings also accept `scale` and `background_col`.
184
+
185
+ The `factory.type` setting selects `make_tile_factory`, `make_sequence_factory`,
186
+ `make_node_factory`, or `make_form_factory`. Their remaining options are passed
187
+ to the corresponding factory; factory-specific options include `tile_sequence`,
188
+ `node_sequence`, `a`, `b`, `c`, `rotation_mod`, and `color_mod`. Tile shape
189
+ options such as `radius`, `side_length`, `sides`, and `arrow_width`, along with
190
+ color options such as `primary_color`, `secondary_color`, `palette`, `stroke`,
191
+ and `stroke_color`, can be configured as shown above. A node sequence is written
192
+ as a 2D YAML list.
193
+
194
+ ## Development
195
+
196
+ - **Build system**: Uses `uv_build`.
197
+ - **Linting & Formatting**: Uses `Ruff`.
198
+ - **Testing**: Uses `pytest`.
199
+
200
+ To run tests:
201
+
202
+ ```bash
203
+ pytest
204
+ ```
205
+
206
+ ## License
207
+
208
+ This project is authored by Joseph Barraud and is licensed under the Apache License, Version 2.0. See [LICENSE.txt](LICENSE.txt) for the full license text.
@@ -0,0 +1,193 @@
1
+ # easy-tiler
2
+
3
+ [![Ruff](https://github.com/jobar8/easy-tiler/actions/workflows/ruff.yml/badge.svg)](https://github.com/jobar8/easy-tiler/actions/workflows/ruff.yml)
4
+ [![Pytest](https://github.com/jobar8/easy-tiler/actions/workflows/pytest.yml/badge.svg)](https://github.com/jobar8/easy-tiler/actions/workflows/pytest.yml)
5
+ [![Publish to PyPI](https://github.com/jobar8/easy-tiler/actions/workflows/release.yml/badge.svg)](https://github.com/jobar8/easy-tiler/actions/workflows/release.yml)
6
+
7
+ **easy-tiler** is a Python library for creating images of patterns made of tiles on a grid. It leverages [Pycairo](https://pycairo.readthedocs.io/) to produce high-quality PNG and SVG outputs.
8
+
9
+ 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.
10
+
11
+ ## Examples
12
+
13
+ ### Polygon Tiles
14
+
15
+ ```python
16
+ from easy_tiler.io import save_png, save_svg
17
+ from easy_tiler.factories import make_tile_factory
18
+ from easy_tiler.grid import Grid
19
+
20
+ # Define a 8x6 grid with 80x80px cells
21
+ grid = Grid(8, 6, x_size=80, y_size=80)
22
+
23
+ # Create a factory for polygon tiles (default is a square)
24
+ factory = make_tile_factory(
25
+ tile_type='polygon', secondary_color='white', primary_color='random', sides=4, gridlines=False
26
+ )
27
+
28
+ # Save as PNG and SVG
29
+ save_png('output.png', grid, factory)
30
+ save_svg('output.svg', grid, factory)
31
+ ```
32
+
33
+ This would produce an image of 8x6 squares with random colors, similar to the image below.
34
+
35
+ ![Polygon Tiles](examples/images/example_v1.png)
36
+
37
+ ### Sequence of Tiles
38
+
39
+ Use `make_sequence_factory` to repeat a sequence of tile rotations across each row. The
40
+ foreground and background colors can also be selected from a palette for each position in
41
+ the sequence.
42
+
43
+ ```python
44
+ from easy_tiler.factories import make_sequence_factory
45
+ from easy_tiler.grid import Grid
46
+ from easy_tiler.io import save_png, save_svg
47
+
48
+ # Define a 12x10 grid with 60x60px cells
49
+ grid = Grid(12, 10, x_size=60, y_size=60)
50
+
51
+ # Repeat four Riley tile rotations with palette-based colors
52
+ factory = make_sequence_factory(
53
+ tile_type='riley',
54
+ tile_sequence=[2, 2, 3, 3, 1, 0],
55
+ primary_color='sequence',
56
+ secondary_color='roll',
57
+ palette='ColorsOfTheWind',
58
+ )
59
+
60
+ save_png('sequence_demo.png', grid, factory)
61
+ save_svg('sequence_demo.svg', grid, factory)
62
+ ```
63
+
64
+ Here, `tile_sequence` controls the repeating rotation pattern, while `primary_color='sequence'` and
65
+ `secondary_color='roll'` vary the tile colors across the sequence. This would produce an images similar this
66
+ one:
67
+
68
+ ![Sequence Patterns](examples/images/sequence_demo.png)
69
+
70
+ ## Key Features
71
+
72
+ - **Multiple Tile Types**: Support for regular polygons (triangles, squares, etc.), Truchet tiles, Riley tiles, and Puck (circle-based) tiles.
73
+ - **Configurable Grids**: Define grid size, cell size, and origin.
74
+ - **Advanced Geometry**: Apply skew angles (shear) and shifts to create dynamic and complex tiling patterns.
75
+ - **Pycairo Backend**: High-performance rendering with support for transparency and vector/raster export.
76
+ - **CLI Tool**: Render configured PNG and SVG patterns from YAML.
77
+
78
+ ## Installation
79
+
80
+ `easy-tiler` requires Python 3.13 or higher.
81
+
82
+ ### From PyPI
83
+
84
+ Install the released package from PyPI with [uv](https://github.com/astral-sh/uv):
85
+
86
+ ```bash
87
+ uv tool install easy-tiler
88
+ ```
89
+
90
+ Or use pip:
91
+
92
+ ```bash
93
+ pip install easy-tiler
94
+ ```
95
+
96
+ ### From a cloned repository
97
+
98
+ To install `easy-tiler` with `uv sync`, first clone the repository and run the command from the repository root:
99
+
100
+ ```bash
101
+ git clone https://github.com/jobar8/easy-tiler.git
102
+ cd easy-tiler
103
+ uv sync
104
+ ```
105
+
106
+ ## Quick Start
107
+
108
+ ### Python API
109
+
110
+ Here is a simple example to render a grid of squares:
111
+
112
+ ```python
113
+ from easy_tiler.io import save_png, save_svg
114
+ from easy_tiler.factories import make_tile_factory
115
+ from easy_tiler.grid import Grid
116
+
117
+ # Define a 10x10 grid with 80x80px cells
118
+ grid = Grid(10, 10, x_size=80, y_size=80)
119
+
120
+ # Create a factory for polygon tiles (default is a square)
121
+ factory = make_tile_factory(
122
+ tile_type='polygon', secondary_color='white', primary_color='black', sides=4, gridlines=False
123
+ )
124
+
125
+ # Save as PNG and SVG
126
+ save_png('output.png', grid, factory)
127
+ save_svg('output.svg', grid, factory)
128
+ ```
129
+
130
+ ### CLI Usage
131
+
132
+ Create a YAML file with grid, factory, and output settings:
133
+
134
+ ```yaml
135
+ grid:
136
+ width: 8
137
+ height: 6
138
+ x_size: 80
139
+ y_size: 80
140
+
141
+ factory:
142
+ type: tile # tile, sequence, node, or form
143
+ tile_type: circle
144
+ primary_color: [blue, red, green, brown]
145
+ secondary_color: white
146
+ radius: 0.3
147
+ stroke: true
148
+ stroke_color: black
149
+ palette: FridaKahlo
150
+ num_colors: 5
151
+
152
+ output:
153
+ path: images/circle-pattern # output basename, relative to this YAML file
154
+ formats: [png, svg] # either, or both
155
+ scale: 1
156
+ background_col: white
157
+ ```
158
+
159
+ Run the installed command with the config path:
160
+
161
+ ```bash
162
+ easy-tiler pattern.yaml
163
+ ```
164
+
165
+ The output section's `formats` defaults to `[png, svg]`. The selected formats are
166
+ written with matching extensions; `output.path` is a basename, and its parent
167
+ directory is created if needed. Paths that are not absolute are resolved relative
168
+ to the YAML file. Output settings also accept `scale` and `background_col`.
169
+
170
+ The `factory.type` setting selects `make_tile_factory`, `make_sequence_factory`,
171
+ `make_node_factory`, or `make_form_factory`. Their remaining options are passed
172
+ to the corresponding factory; factory-specific options include `tile_sequence`,
173
+ `node_sequence`, `a`, `b`, `c`, `rotation_mod`, and `color_mod`. Tile shape
174
+ options such as `radius`, `side_length`, `sides`, and `arrow_width`, along with
175
+ color options such as `primary_color`, `secondary_color`, `palette`, `stroke`,
176
+ and `stroke_color`, can be configured as shown above. A node sequence is written
177
+ as a 2D YAML list.
178
+
179
+ ## Development
180
+
181
+ - **Build system**: Uses `uv_build`.
182
+ - **Linting & Formatting**: Uses `Ruff`.
183
+ - **Testing**: Uses `pytest`.
184
+
185
+ To run tests:
186
+
187
+ ```bash
188
+ pytest
189
+ ```
190
+
191
+ ## License
192
+
193
+ This project is authored by Joseph Barraud and is licensed under the Apache License, Version 2.0. See [LICENSE.txt](LICENSE.txt) for the full license text.
@@ -0,0 +1,41 @@
1
+ [project]
2
+ name = "easy-tiler"
3
+ version = "1.0.3"
4
+ description = "Library for tiling and patterns"
5
+ readme = "README.md"
6
+ requires-python = ">=3.13"
7
+ dependencies = [
8
+ "pycairo>=1.23.0",
9
+ "pillow>=12.3.0",
10
+ "numpy>=2.5.2",
11
+ "colorcet>=3.1.0",
12
+ "pypalettes>=0.2.1",
13
+ "pyyaml>=6.0.3",
14
+ ]
15
+
16
+ [[project.authors]]
17
+ name = "Joseph Barraud"
18
+ email = "joseph.barraud@gmail.com"
19
+
20
+ [project.scripts]
21
+ easy-tiler = "easy_tiler:main"
22
+
23
+ [dependency-groups]
24
+ dev = [
25
+ "ipykernel>=7.2.0",
26
+ "pytest>=9.1.1",
27
+ "ruff>=0.15.4",
28
+ ]
29
+
30
+ [build-system]
31
+ requires = ["uv_build>=0.13.1,<0.14"]
32
+ build-backend = "uv_build"
33
+
34
+ [tool.ruff]
35
+ line-length = 100
36
+ target-version = "py313"
37
+ preview = true
38
+
39
+ [tool.ruff.format]
40
+ quote-style = "single"
41
+ preview = true
@@ -0,0 +1,41 @@
1
+ [project]
2
+ name = "easy-tiler"
3
+ version = "1.0.3"
4
+ description = "Library for tiling and patterns"
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Joseph Barraud", email = "joseph.barraud@gmail.com" }
8
+ ]
9
+ requires-python = ">=3.13"
10
+ dependencies = [
11
+ "pycairo>=1.23.0",
12
+ "pillow>=12.3.0",
13
+ "numpy>=2.5.2",
14
+ "colorcet>=3.1.0",
15
+ "pypalettes>=0.2.1",
16
+ "pyyaml>=6.0.3",
17
+ ]
18
+
19
+ [project.scripts]
20
+ easy-tiler = "easy_tiler:main"
21
+
22
+ [dependency-groups]
23
+ dev = [
24
+ "ipykernel>=7.2.0",
25
+ "pytest>=9.1.1",
26
+ "ruff>=0.15.4",
27
+ ]
28
+
29
+ [build-system]
30
+ requires = ["uv_build>=0.13.1,<0.14"]
31
+ build-backend = "uv_build"
32
+
33
+ [tool.ruff]
34
+ line-length = 100
35
+ target-version = "py313"
36
+ preview = true
37
+
38
+ [tool.ruff.format]
39
+ # Prefer single quotes over double quotes.
40
+ quote-style = "single"
41
+ preview = true
@@ -0,0 +1,56 @@
1
+ from .colors import ColorConfig
2
+ from .grid import Grid
3
+ from .renderer import Renderer
4
+ from .tiles import (
5
+ ArcTile,
6
+ ArrowTile,
7
+ BumpTile,
8
+ CairoTile,
9
+ CircleTile,
10
+ CornerTile,
11
+ DoughnutTile,
12
+ PentagonTile,
13
+ PuckTile,
14
+ RectangleTile,
15
+ RegularPolygonTile,
16
+ RileyTile,
17
+ SmithTile,
18
+ SquareTile,
19
+ TileBase,
20
+ TileConfig,
21
+ TriangleTile,
22
+ TruchetTile,
23
+ )
24
+
25
+
26
+ def main() -> None:
27
+ """Run the easy-tiler command."""
28
+ from .cli import main as cli_main
29
+
30
+ cli_main()
31
+
32
+
33
+ __all__ = [
34
+ 'ArcTile',
35
+ 'ArrowTile',
36
+ 'BumpTile',
37
+ 'CairoTile',
38
+ 'CircleTile',
39
+ 'ColorConfig',
40
+ 'CornerTile',
41
+ 'DoughnutTile',
42
+ 'Grid',
43
+ 'PentagonTile',
44
+ 'PuckTile',
45
+ 'RectangleTile',
46
+ 'RegularPolygonTile',
47
+ 'Renderer',
48
+ 'RileyTile',
49
+ 'SmithTile',
50
+ 'SquareTile',
51
+ 'TileBase',
52
+ 'TileConfig',
53
+ 'TriangleTile',
54
+ 'TruchetTile',
55
+ 'main',
56
+ ]