tileset_spec
pleat.tileset_spec ¶
Declarative tileset format: a dict mapping tile names to per-edge gluing references.
A :data:TilesetSpec is a dict[str, list[tuple[str, int]]]. Each key is a
tile name (one or more lowercase letters by convention). Each list entry
describes one edge of that tile in cyclic order: the tuple (neighbor, j)
means "this edge is glued to edge j of tile neighbor".
Example::
spec = {
"a": [("b", 1), ("b", 1), ("b", 1)], # triangle, 3 edges
"b": [("a", 0)] * 6, # hexagon, 6 edges
}
The spec currently assumes regular Euclidean polygons with unit edge length.
A future extension could add per-edge length / angle fields to cover
non-regular or non-Euclidean tilings, but full flexibility will always remain
the domain of hand-built :class:~pleat.prototiles.ProtoTile constructions.
On disk the format uses dotted strings ("b.1"); on read the older compact
form ("b1") is also accepted for backwards compatibility with the original
notebook output.
parse_edge_ref ¶
Parse a YAML edge reference like "b.1" or "b1" into ("b", 1).
Source code in pleat/tileset_spec.py
spec_from_yaml ¶
Parse YAML text into a :data:TilesetSpec. Accepts both dotted and compact forms.
spec_to_yaml ¶
Render a :data:TilesetSpec as YAML text in canonical dotted form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
TilesetSpec
|
The spec to serialise. |
required |
header
|
str | None
|
Optional comment line (e.g. |
None
|
Source code in pleat/tileset_spec.py
tileset_from_spec ¶
Build a list of :class:RegularEuclideanTile with mutual edge instructions from a spec.
The returned list is sorted by decreasing polygon order (hexagons before
triangles, etc.) to match the convention used by the rest of the package
when picking a base tile for :func:~pleat.example_graphs.from_tiles.