Tilemap

Tilemap :: # (opaque)

Tilemap module - Tiled TMX data, tileset drawing, and grid queries.

empty_raw_map : TilemapRawMap

Empty parsed map value, useful as a deliberate fallback.

empty : Tilemap

Empty configured tilemap, useful when an optional map fails to load. Unlike building empty_raw_map, this value cannot fail validation.

load_tmx! : Str => Try(TilemapRawMap, [NotFound, ReadFailed, ParseFailed, Unsupported, ..])

Parse a Tiled TMX map. The returned data is an allocation-efficient set of flat lists with index ranges for nested properties, objects, and tile data.

from_raw : TilemapRawMap -> TilemapBuilder

Begin configuring a drawable and queryable tilemap from parsed TMX data.

raw_map : Tilemap -> TilemapRawMap

Access the parsed flat-map data backing a configured tilemap.

layer_role_for : Tilemap, TilemapRawLayer -> TilemapLayerRole

Resolve a layer's configured semantic role; unmatched layers are drawn.

object_role_for : Tilemap, TilemapRawObject -> TilemapObjectRole

Resolve an object's configured semantic role; unmatched objects are unknown.

objects : Tilemap -> List(TilemapRawObject)

Return every parsed object in source order.

objects_named : Tilemap, Str -> List(TilemapRawObject)

Return objects whose Tiled name matches exactly.

objects_typed : Tilemap, Str -> List(TilemapRawObject)

Return objects whose Tiled type matches exactly.

objects_with_role : Tilemap, TilemapObjectRole -> List(TilemapRawObject)

Return objects matching a configured semantic role.

first_object : Tilemap, TilemapObjectRole -> Try(TilemapRawObject, [NotFound, ..])

Return the first object matching a configured semantic role.

object_center : TilemapRawObject -> Vec2

Return an object's center in map-local coordinates.

object_rect : TilemapRawObject -> Rect

Return an object's bounding rectangle in map-local coordinates.

object_circle : TilemapRawObject -> Circle

Approximate an object as a circle centered in its bounds.

object_world_center : Tilemap, TilemapRawObject -> Vec2

Return an object's center translated by the tilemap origin.

object_world_rect : Tilemap, TilemapRawObject -> Rect

Return an object's bounds translated by the tilemap origin.

property_named : TilemapRawMap, U64, U64, Str -> Try(TilemapRawProperty, [NotFound, ..])

Look up a property within an explicit flat-list range.

object_property : TilemapRawMap, TilemapRawObject, Str -> Try(TilemapRawProperty, [NotFound, ..])

Look up a property attached to an object.

layer_property : TilemapRawMap, TilemapRawLayer, Str -> Try(TilemapRawProperty, [NotFound, ..])

Look up a property attached to a layer.

property_str : TilemapRawMap, TilemapRawObject, Str, Str -> Str

Read an object's string property, or return the supplied default.

property_f32 : TilemapRawMap, TilemapRawObject, Str, F32 -> F32

Read an object's numeric property, or return the supplied default.

property_i64 : TilemapRawMap, TilemapRawObject, Str, I64 -> I64

Read an object's integer property, or return the supplied default.

property_bool : TilemapRawMap, TilemapRawObject, Str, Bool -> Bool

Read an object's boolean property, or return the supplied default.

cell_at_world : Tilemap, Vec2 -> Try(TilemapCell, [OutOfBounds, ..])

Convert a world-space position to a map cell, accounting for map origin.

cell_range_for_world_rect : Tilemap, Rect -> Try(TilemapCellRange, [OutOfBounds, ..])

Return the inclusive cell range overlapping a world-space rectangle's half-open area. The arithmetic is O(1), allocation-free, and clamps the range to map bounds.

gid_at : Tilemap, Str, TilemapCell -> Try(U64, [NotFound, OutOfBounds, ..])

Read the cleaned tile GID at a named layer and cell.

solid_cell : Tilemap, TilemapCell -> Bool

Whether any layer configured as solid contains a tile in this cell.

draw_layer! : Tilemap, Frame, Str => {  }

Draw one named visible layer without camera culling.

draw_layer_in! : Tilemap, Frame, Str, Rect => {  }

Draw only cells intersecting world_view. This is the preferred hot path for maps larger than the viewport. One hosted effect draws the complete selected range; no per-tile effect or temporary List is created.

draw_layers! : Tilemap, Frame, TilemapDrawRole => {  }

Draw every visible layer configured with the Drawn role.

draw_layers_in! : Tilemap, Frame, TilemapDrawRole, Rect => {  }

Draw visible configured layers culled to a world-space viewport.

draw_all! : Tilemap, Frame => {  }

Draw every visible tile layer, regardless of configured role.

draw_all_in! : Tilemap, Frame, Rect => {  }

Draw every visible tile layer culled to a world-space viewport.

viewport_for_camera : Camera2D, Vec2 -> Rect

Compute the world-space axis-aligned bounds visible through a 2D camera, including non-centered offsets and rotation. This is pure and allocates no temporary list.

flip_for_gid : U64 -> TilemapFlip

Decode Tiled horizontal, vertical, and diagonal flip flags.

clean_gid : U64 -> U64

Remove Tiled flip flags from a packed global tile ID.

RawMap : TilemapRawMap

Parsed TMX data stored in flat lists to avoid a heap allocation per nested item.

RawLayer : TilemapRawLayer

Parsed tile-layer metadata and a range into the map GID list.

RawObject : TilemapRawObject

Parsed Tiled object metadata and ranges into point and property lists.

RawProperty : TilemapRawProperty

Parsed Tiled property with tagged scalar storage.

RawTileset : TilemapRawTileset

Parsed tileset metadata and its property range.

RawPoint : TilemapRawPoint

Parsed object point in map-local coordinates.

Cell : TilemapCell

Zero-based tile column and row.

CellRange : TilemapCellRange

Inclusive rectangular range of map cells.

Flip : TilemapFlip

Decoded Tiled tile-transform flags.

LayerRole : TilemapLayerRole

Application-level behavior assigned to a named layer.

ObjectRole : TilemapObjectRole

Application-level behavior assigned to an object name or type.

Builder : TilemapBuilder

Immutable tilemap configuration builder.