mirror of
https://github.com/OMGeeky/pytiled_parser.git
synced 2025-12-28 23:27:23 +01:00
Merge branch 'rf/caster' of github.com:Beefy-Swain/pytiled_parser into rf/caster
This commit is contained in:
@@ -170,6 +170,7 @@ class RawTiledObject(TypedDict):
|
||||
template: Template
|
||||
ellipse: bool
|
||||
point: bool
|
||||
polygon: List[Dict]
|
||||
|
||||
|
||||
RawTiledObjects = List[RawTiledObject]
|
||||
@@ -243,11 +244,27 @@ def _cast_ellipse(raw_tiled_object: RawTiledObject) -> Ellipse:
|
||||
|
||||
|
||||
def _cast_rectangle(raw_tiled_object: RawTiledObject) -> Rectangle:
|
||||
raise NotImplementedError
|
||||
""" Cast the raw_tiled_object to a Rectangle object.
|
||||
|
||||
Args:
|
||||
raw_tiled_object: Raw Tiled object to be casted to a Rectangle
|
||||
|
||||
Returns:
|
||||
Rectangle: The Rectangle object created from the raw_tiled_object
|
||||
"""
|
||||
return Rectangle(**_get_common_attributes(raw_tiled_object).__dict__)
|
||||
|
||||
|
||||
def _cast_point(raw_tiled_object: RawTiledObject) -> Point:
|
||||
raise NotImplementedError
|
||||
""" Cast the raw_tiled_object to a Point object.
|
||||
|
||||
Args:
|
||||
raw_tiled_object: Raw Tiled object to be casted to a Point
|
||||
|
||||
Returns:
|
||||
Point: The Point object created from the raw_tiled_object
|
||||
"""
|
||||
return Point(**_get_common_attributes(raw_tiled_object).__dict__)
|
||||
|
||||
|
||||
def _cast_tile(raw_tiled_object: RawTiledObject) -> Tile:
|
||||
@@ -255,7 +272,20 @@ def _cast_tile(raw_tiled_object: RawTiledObject) -> Tile:
|
||||
|
||||
|
||||
def _cast_polygon(raw_tiled_object: RawTiledObject) -> Polygon:
|
||||
raise NotImplementedError
|
||||
""" Cast the raw_tiled_object to a Polygon object.
|
||||
|
||||
Args:
|
||||
raw_tiled_object: Raw Tiled object to be casted to a Polygon
|
||||
|
||||
Returns:
|
||||
Polygon: The Polygon object created from the raw_tiled_object
|
||||
"""
|
||||
polygon = []
|
||||
if raw_tiled_object.get("polygon"):
|
||||
for point in raw_tiled_object["polygon"]:
|
||||
polygon.append(OrderedPair(point["x"], point["y"]))
|
||||
|
||||
return Polygon(**_get_common_attributes(raw_tiled_object).__dict__, points=polygon)
|
||||
|
||||
|
||||
def _cast_polyline(raw_tiled_object: RawTiledObject) -> Polyline:
|
||||
|
||||
Reference in New Issue
Block a user