Skip to content

Commit c34742a

Browse files
committed
new release adding arbitrary number of pie slices and arbitrary offset
1 parent 1e28e1b commit c34742a

9 files changed

+151
-43
lines changed

Diff for: dist/weavingspace-0.0.3.6.tar.gz

-81.8 KB
Binary file not shown.

Diff for: dist/weavingspace-0.0.4.tar.gz

81.6 KB
Binary file not shown.

Diff for: layouts/tiling-explorer.grid.json

+58-18
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,37 @@
3030
0,
3131
10,
3232
6,
33-
10
33+
8
3434
]
3535
},
3636
{
3737
"position": [
3838
0,
39-
20,
39+
18,
4040
6,
4141
2
4242
]
4343
},
4444
{
4545
"position": [
4646
0,
47-
22,
47+
20,
4848
6,
4949
2
5050
]
5151
},
5252
{
5353
"position": [
5454
0,
55-
24,
55+
23,
5656
6,
5757
19
5858
]
5959
},
6060
{
6161
"position": [
6262
0,
63-
43,
63+
42,
6464
6,
6565
5
6666
]
@@ -70,45 +70,45 @@
7070
6,
7171
10,
7272
6,
73-
8
73+
7
7474
]
7575
},
7676
{
7777
"position": [
7878
6,
79-
18,
79+
17,
8080
6,
8181
2
8282
]
8383
},
8484
{
8585
"position": [
8686
6,
87-
20,
87+
19,
8888
6,
8989
2
9090
]
9191
},
9292
{
9393
"position": [
9494
6,
95-
22,
95+
21,
9696
6,
9797
2
9898
]
9999
},
100100
{
101101
"position": [
102102
6,
103-
24,
103+
23,
104104
6,
105-
18
105+
19
106106
]
107107
},
108108
{
109109
"position": [
110110
6,
111-
45,
111+
42,
112112
6,
113113
5
114114
]
@@ -118,37 +118,77 @@
118118
12,
119119
10,
120120
6,
121-
5
121+
6
122122
]
123123
},
124124
{
125125
"position": [
126126
12,
127-
15,
127+
17,
128128
6,
129129
2
130130
]
131131
},
132132
{
133133
"position": [
134134
12,
135-
17,
135+
19,
136136
6,
137137
2
138138
]
139139
},
140140
{
141141
"position": [
142142
12,
143-
19,
143+
23,
144144
6,
145-
18
145+
19
146146
]
147147
},
148148
{
149149
"position": [
150150
12,
151-
37,
151+
42,
152+
6,
153+
5
154+
]
155+
},
156+
{
157+
"position": [
158+
18,
159+
10,
160+
6,
161+
9
162+
]
163+
},
164+
{
165+
"position": [
166+
18,
167+
19,
168+
6,
169+
2
170+
]
171+
},
172+
{
173+
"position": [
174+
18,
175+
21,
176+
6,
177+
2
178+
]
179+
},
180+
{
181+
"position": [
182+
18,
183+
23,
184+
6,
185+
19
186+
]
187+
},
188+
{
189+
"position": [
190+
18,
191+
42,
152192
6,
153193
5
154194
]

Diff for: pyproject.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ find = {}
77

88
[project]
99
name = "weavingspace"
10-
version = "0.0.3.6"
10+
version = "0.0.4"
1111
authors = [
1212
{ name="David O'Sullivan", email="[email protected]" },
13-
{ name="Luke Bergmann" },
1413
]
1514
description = "A package for making tiled mapping layers"
1615
requires-python = ">=3.12"

Diff for: tiling-explorer.py

+72-8
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _(mo):
113113
mo.md(
114114
r"""
115115
## Hexagon and square slices
116-
We can slice base hexagon or square tilings into pie segments, with a fractional offset from the base polygon corner.
116+
Pie slices of hexagons or squares, with an offset specifying how far along from start to midpoint of the first segment slices should start.
117117
"""
118118
)
119119
return
@@ -125,7 +125,7 @@ def _(mo):
125125
options=["hex-slice", "square-slice"],
126126
value="hex-slice"
127127
)
128-
mo.md(f"#### Slice or dissection? {hex_or_square_slice}")
128+
mo.md(f"#### Hex or square? {hex_or_square_slice}")
129129
return (hex_or_square_slice,)
130130

131131

@@ -157,19 +157,19 @@ def _(
157157
t_inset,
158158
tile_rotate,
159159
):
160-
hex = TileUnit(tiling_type=hex_or_square_slice.value,
160+
slices = TileUnit(tiling_type=hex_or_square_slice.value,
161161
n=n_slices.value, offset=offset_slices.value) \
162162
.transform_scale(math.sqrt(aspect.value), 1/math.sqrt(aspect.value)) \
163163
.transform_rotate(tile_rotate.value) \
164164
.inset_tiles(t_inset.value) \
165165
.inset_prototile(p_inset.value)
166-
plot_tiles(hex)
167-
return (hex,)
166+
plot_tiles(slices)
167+
return (slices,)
168168

169169

170170
@app.cell
171-
def _(hex, hex_or_square_slice, mo, n_slices, offset_slices):
172-
_download_button = mo.download(data=hex.tiles.to_json().encode('utf-8'),
171+
def _(hex_or_square_slice, mo, n_slices, offset_slices, slices):
172+
_download_button = mo.download(data=slices.tiles.to_json().encode('utf-8'),
173173
filename=f'{hex_or_square_slice.value}-{n_slices.value}-{offset_slices.value:.3f}_tile_unit.json',
174174
mimetype='text/plain', label='Download')
175175
mo.md(f'Click to download **square/hex slice** tile unit {_download_button}')
@@ -178,7 +178,71 @@ def _(hex, hex_or_square_slice, mo, n_slices, offset_slices):
178178

179179
@app.cell(hide_code=True)
180180
def _(mo):
181-
mo.md(r"""## Laves tilings and their Archimedean duals""")
181+
mo.md(
182+
"""
183+
## Hex dissections
184+
4, 7 and 9 dissections of the hexagon in two different varieties.
185+
"""
186+
)
187+
return
188+
189+
190+
@app.cell(hide_code=True)
191+
def _(list_to_dict, mo):
192+
n_pieces = mo.ui.dropdown(
193+
options = list_to_dict([4, 7, 9]),
194+
value = "7"
195+
)
196+
mo.md(f"#### Number of pieces  {n_pieces}")
197+
return (n_pieces,)
198+
199+
200+
@app.cell(hide_code=True)
201+
def _(mo):
202+
dissection_offset = mo.ui.switch(value = True)
203+
mo.md(f"#### Start from corners?  {dissection_offset}")
204+
return (dissection_offset,)
205+
206+
207+
@app.cell(hide_code=True)
208+
def _(
209+
TileUnit,
210+
aspect,
211+
dissection_offset,
212+
math,
213+
n_pieces,
214+
p_inset,
215+
plot_tiles,
216+
t_inset,
217+
tile_rotate,
218+
):
219+
pieces = TileUnit(tiling_type="hex-dissection",
220+
n=n_pieces.value, offset=0 if dissection_offset.value else 1) \
221+
.transform_scale(math.sqrt(aspect.value), 1/math.sqrt(aspect.value)) \
222+
.transform_rotate(tile_rotate.value) \
223+
.inset_tiles(t_inset.value) \
224+
.inset_prototile(p_inset.value)
225+
plot_tiles(pieces)
226+
return (pieces,)
227+
228+
229+
@app.cell
230+
def _(dissection_offset, mo, n_pieces, pieces):
231+
_download_button = mo.download(data=pieces.tiles.to_json().encode('utf-8'),
232+
filename=f'hex-dissection-{n_pieces.value}-{dissection_offset.value}_tile_unit.json',
233+
mimetype='text/plain', label='Download')
234+
mo.md(f'Click to download **Hex dissection** tile unit {_download_button}')
235+
return
236+
237+
238+
@app.cell(hide_code=True)
239+
def _(mo):
240+
mo.md(
241+
r"""
242+
## Laves tilings and their Archimedean duals
243+
The Laves tilings are monohedral. They are dual to the Archimedean tilings by regular polygons. We support 7 of the 11 possible tilings.
244+
"""
245+
)
182246
return
183247

184248

Diff for: tiling-explorer/index.html

+3-3
Large diffs are not rendered by default.

Diff for: weavingspace.egg-info/PKG-INFO

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
Metadata-Version: 2.2
22
Name: weavingspace
3-
Version: 0.0.3.6
3+
Version: 0.0.4
44
Summary: A package for making tiled mapping layers
5-
Author: Luke Bergmann
65
Author-email: David O'Sullivan <[email protected]>
76
Project-URL: Homepage, https://github.com/DOSull/weaving-space
87
Project-URL: Repository, https://github.com/DOSull/weaving-space

Diff for: weavingspace/tiling_geometries.py

+16-10
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,17 @@ def setup_cairo(unit:"TileUnit") -> None:
127127

128128

129129
def setup_hex_slice(unit:"TileUnit") -> None:
130-
"""Tilings from radial slices of a hexagon into 2, 3, 4, 6 or 12 slices.
130+
"""Arbitrary number of radial slices of a hexagon, with an optional
131+
offset starting point.
131132
132133
The supplied unit should have offset and n set.
133134
134-
self.offset == 1 starts at midpoints, 0 at hexagon corners
135-
self.n is the number of slices and should be 2, 3, 4, 6 or 12.
136-
137-
Again, construction avoids intersection operations where possible.
135+
Places unit.n points equally spaced around the perimeter of the hexagon.
136+
Slices are formed by connecting some sequence of these points (and any
137+
intervening hexagon corners) and the hexagon centre to form a pie slice.
138+
unit.offset = 0 starts from corner 0. unit.offset starts half way between
139+
corner 0 and corner 1. Other values of unit.offset scale linear between
140+
these.
138141
139142
Args:
140143
unit (TileUnit): the TileUnit to setup.
@@ -150,14 +153,17 @@ def setup_hex_slice(unit:"TileUnit") -> None:
150153

151154

152155
def setup_square_slice(unit:"TileUnit") -> None:
153-
"""Tilings from radial slices of a square into 2, 4, or 8 slices.
156+
"""Arbitrary number of radial slices of a square, with an optional
157+
offset starting point.
154158
155159
The supplied unit should have offset and n set.
156160
157-
self.offset == 1 starts at midpoints, 0 at corners
158-
self.n is the number of slices and should be 2, 4, or 8.
159-
160-
Again, construction avoids intersection operations where possible.
161+
Places unit.n points equally spaced around the perimeter of the square.
162+
Slices are formed by connecting some sequence of these points (and any
163+
intervening squares corners) and the square centre to form a pie slice.
164+
unit.offset = 0 starts from corner 0. unit.offset starts half way between
165+
corner 0 and corner 1. Other values of unit.offset scale linear between
166+
these.
161167
162168
Args:
163169
unit (TileUnit): the TileUnit to setup.

0 commit comments

Comments
 (0)