Wang Set#
This module contains a number of classes related to Wang Sets.
Wang Sets are the underlying data used by Tiled’s terrain system. It is unlikely this module will ever need touched for creating an implementation in a game engine. It is primarily data used by the editor during map creation.
See Tiled’s docs about terrain and also the TMX Reference and the JSON Reference
WangSet#
- class pytiled_parser.wang_set.WangSet(name: str, tile: int, wang_type: str, wang_tiles: Dict[int, WangTile], wang_colors: List[WangColor], class_: Optional[str] = None, properties: Optional[Dict[str, Union[float, Path, str, bool, Color]]] = None)#
A complete Wang Set defining a list of corner and edge [WangColors][pytiled_parser.wang_set.WangColor], and any number of [WangTiles][pytiled_parser.wang_set.WangTile]
[TMX Reference](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#wangset)
[JSON Reference](https://doc.mapeditor.org/en/stable/reference/json-map-format/#wang-set)
- name#
Name of the WangSet
- Type:
str
- properties#
The properties for this wang set
- Type:
Optional[Dict[str, Union[float, pathlib.Path, str, bool, pytiled_parser.common_types.Color]]]
- class_#
The Tiled class of this Wang Set
- Type:
Optional[str]
- tile#
Tile ID of the tile representing this Wang Set
- Type:
int
- wang_colors#
A list of [WangColors][pytiled_parser.wang_set.WangColor]
- Type:
- wang_tiles#
A list of [WangTiles][pytiled_parser.wang_set.WangTile]
- Type:
Dict[int, pytiled_parser.wang_set.WangTile]
- wang_type#
A string noting the type of this wang set
- Type:
str
WangColor#
- class pytiled_parser.wang_set.WangColor(color: Color, name: str, probability: float, tile: int, class_: Optional[str] = None, properties: Optional[Dict[str, Union[float, Path, str, bool, Color]]] = None)#
A color that can be used to define the corner and/or edge of a Wang tile
[TMX Reference](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#wangcolor)
[JSON Reference](https://doc.mapeditor.org/en/stable/reference/json-map-format/#wang-color)
- color#
An RGBA color used to identify this Wang color
- name#
The name for this color
- Type:
str
- probability#
The probability used when randomizing tiles
- Type:
float
- properties#
The properties for this wang color
- Type:
Optional[Dict[str, Union[float, pathlib.Path, str, bool, pytiled_parser.common_types.Color]]]
- class_#
The Tiled class of this Wang Color
- Type:
Optional[str]
- tile#
Tile ID of the tile representing this color
- Type:
int
WangTile#
- class pytiled_parser.wang_set.WangTile(tile_id: int, wang_id: List[int])#
Defines a Wang tile by linking a tile in the tileset to a Wang ID.
[TMX Reference](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/#wangtile)
[JSON Reference](https://doc.mapeditor.org/en/stable/reference/json-map-format/#wang-tile)
- tile_id#
The ID of the tile this WangTile maps to
- Type:
int
- wang_id#
The wang color indexes for this tile. This is a list of IDs referring to colors within the wang set. In the order of top, top right, right, bottom right, bottom, bottom left, left, top left.
- Type:
List[int]