Skip to content

instructions

pleat.instructions

Edge instructions that describe how to attach tiles to border edges during tiling growth.

attatch_tile_instruction

attatch_tile_instruction(
    proto_tile: "ProtoTile", label: object = None
) -> "callable"

Return a callable that builds a fresh tile graph from proto_tile and glues it to a given edge.

The newly created tile graph may itself carry instructions on its border edges, which will be executed when those edges are reached during growth. This allows recursive growth patterns to be encoded in a single proto-tile graph.

Parameters:

Name Type Description Default
proto_tile 'ProtoTile'

A tile object that can build a tile graph via make_graph().

required
label object

If given, the label of the edge in the tile graph to glue to the border edge. If None, an arbitrary edge is used.

None

Returns:

Type Description
'callable'

A callable (graph, edge) -> None that performs the gluing.

Source code in pleat/instructions.py
def attatch_tile_instruction(proto_tile: "ProtoTile", label: object = None) -> "callable":
    """Return a callable that builds a fresh tile graph from ``proto_tile`` and glues it to a given edge.

    The newly created tile graph may itself carry instructions on its border
    edges, which will be executed when those edges are reached during growth.
    This allows recursive growth patterns to be encoded in a single proto-tile
    graph.

    Args:
        proto_tile: A tile object that can build a tile graph via ``make_graph()``.
        label: If given, the label of the edge in the tile graph to glue to
            the border edge. If None, an arbitrary edge is used.

    Returns:
        A callable ``(graph, edge) -> None`` that performs the gluing.
    """

    def instruction(graph: "HalfEdgeGraph", edge: "HalfEdge") -> None:
        tile, edge_dict = proto_tile.make_graph()
        if label is not None:
            tile_edge = edge_dict[label]
        else:
            # just take any edge
            tile_edge = next(iter(edge_dict.values()))
        graph.glue_graph_e2e(tile, edge, tile_edge)

    return instruction