diff --git a/.gitignore b/.gitignore index 8a9b319..1200298 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,6 @@ venv.bak/ # mypy .mypy_cache/ .idea/ + +# VS Code Directory +.vscode \ No newline at end of file diff --git a/tests/test_data/simple_objects.json b/tests/test_data/simple_objects.json index df9342e..1da91c1 100644 --- a/tests/test_data/simple_objects.json +++ b/tests/test_data/simple_objects.json @@ -122,7 +122,7 @@ { "height":0, "id":9, - "name":"name: polyline", + "name":"name: polygon", "polygon":[ { "x":0, @@ -145,7 +145,7 @@ "y":16.3692167784472 }], "rotation":0, - "type":"polyline", + "type":"polygon", "visible":true, "width":0, "x":89.485051722178, @@ -154,7 +154,7 @@ { "height":0, "id":10, - "name":"name: polyline - invisible", + "name":"name: polygon - invisible", "polygon":[ { "x":0, @@ -169,7 +169,7 @@ "y":-10.2580425144936 }], "rotation":0, - "type":"polyline", + "type":"polygon", "visible":false, "width":0, "x":133.791065135842, @@ -178,7 +178,7 @@ { "height":0, "id":11, - "name":"name: polyline - rotated", + "name":"name: polygon - rotated", "polygon":[ { "x":0, @@ -205,7 +205,7 @@ "y":8.29373650107991 }], "rotation":123, - "type":"polyline", + "type":"polygon", "visible":true, "width":0, "x":152.779356598841, @@ -214,7 +214,7 @@ { "height":0, "id":12, - "name":"name: polyline - not closed", + "name":"name: polyline", "polyline":[ { "x":0, @@ -235,6 +235,54 @@ "x":124.187791292486, "y":90.1398203933159 }, + { + "height":0, + "id":31, + "name":"name: polyline - invisible", + "polyline":[ + { + "x":0, + "y":0 + }, + { + "x":-9, + "y":20.3333333333333 + }, + { + "x":5, + "y":23.6666666666667 + }], + "rotation":0, + "type":"polyline", + "visible":false, + "width":0, + "x":140, + "y":163.333333333333 + }, + { + "height":0, + "id":32, + "name":"name: polyline - rotated", + "polyline":[ + { + "x":0, + "y":0 + }, + { + "x":10.3333333333333, + "y":13 + }, + { + "x":-5.33333333333331, + "y":19.6666666666667 + }], + "rotation":0, + "type":"polyline", + "visible":true, + "width":0, + "x":192.333333333333, + "y":128.666666666667 + }, { "gid":79, "height":32, @@ -531,10 +579,10 @@ "y":0 }], "nextlayerid":3, - "nextobjectid":31, + "nextobjectid":33, "orientation":"orthogonal", "renderorder":"right-down", - "tiledversion":"1.3.1", + "tiledversion":"1.3.5", "tileheight":32, "tilesets":[ { diff --git a/tests/test_tiled_object.py b/tests/test_tiled_object.py index 2ca7806..ea8a989 100644 --- a/tests/test_tiled_object.py +++ b/tests/test_tiled_object.py @@ -7,7 +7,83 @@ import pytest from pytiled_parser import common_types, properties, tiled_object -ELLIPSES = [] +ELLIPSES = [ + ( + """ + { + "ellipse":true, + "height":18.5517790155735, + "id":6, + "name":"name: ellipse", + "rotation":0, + "type":"ellipse", + "visible":true, + "width":57.4013868364215, + "x":37.5400704785722, + "y":81.1913152210981 + } + """, + tiled_object.Ellipse( + id_=6, + size=common_types.Size(57.4013868364215, 18.5517790155735), + name="name: ellipse", + rotation=0, + type="ellipse", + visible=True, + coordinates=common_types.OrderedPair(37.5400704785722, 81.1913152210981), + ), + ), + ( + """ + { + "ellipse":true, + "height":31.4288962146186, + "id":7, + "name":"name: ellipse - invisible", + "rotation":0, + "type":"ellipse", + "visible":false, + "width":6.32943048766625, + "x":22.6986472661134, + "y":53.9092872570194 + } + """, + tiled_object.Ellipse( + id_=7, + size=common_types.Size(6.32943048766625, 31.4288962146186), + name="name: ellipse - invisible", + rotation=0, + type="ellipse", + visible=True, + coordinates=common_types.OrderedPair(22.6986472661134, 53.9092872570194), + ), + ), + ( + """ + { + "ellipse":true, + "height":24.2264408321018, + "id":8, + "name":"name: ellipse - rotated", + "rotation":111, + "type":"ellipse", + "visible":true, + "width":29.6828464249176, + "x":35.7940206888712, + "y":120.040923041946 + } + """, + tiled_object.Ellipse( + id_=8, + size=common_types.Size(29.6828464249176, 24.2264408321018), + name="name: ellipse - rotated", + rotation=111, + type="ellipse", + visible=True, + coordinates=common_types.OrderedPair(35.7940206888712, 120.040923041946), + ), + ), +] RECTANGLES = [ ( @@ -206,7 +282,197 @@ TILE_IMAGES = [] POLYGONS = [] -POLYLINES = [] +POLYLINES = [ + ( + """ + { + "height":0, + "id":9, + "name":"name: polyline", + "polygon":[ + { + "x":0, + "y":0 + }, + { + "x":19.424803910424, + "y":27.063771740366 + }, + { + "x":19.6430601341366, + "y":3.05558713197681 + }, + { + "x":-2.61907468455156, + "y":15.9327043310219 + }, + { + "x":25.317721950665, + "y":16.3692167784472 + }], + "rotation":0, + "type":"polyline", + "visible":true, + "width":0, + "x":89.485051722178, + "y":38.6313515971354 + } + """, + tiled_object.Polyline( + id_=9, + name="name: polyline", + points=[ + common_types.OrderedPair(0, 0), + common_types.OrderedPair(19.424803910424, 27.063771740366), + common_types.OrderedPair(19.6430601341366, 3.05558713197681), + common_types.OrderedPair(-2.61907468455156, 15.9327043310219), + common_types.OrderedPair(25.317721950665, 16.3692167784472), + ], + rotation=0, + type="polyline", + visible=True, + coordinates=common_types.OrderedPair(89.485051722178, 38.6313515971354), + ), + ), + ( + """ + { + "height":0, + "id":10, + "name":"name: polyline - invisible", + "polygon":[ + { + "x":0, + "y":0 + }, + { + "x":-12.8771171990451, + "y":7.63896782994203 + }, + { + "x":-14.8414232124588, + "y":-10.2580425144936 + }], + "rotation":0, + "type":"polyline", + "visible":false, + "width":0, + "x":133.791065135842, + "y":24.4446970558145 + } + """, + tiled_object.Polyline( + id_=10, + name="name: polyline - invisible", + points=[ + common_types.OrderedPair(0, 0), + common_types.OrderedPair(-12.8771171990451, 7.63896782994203), + common_types.OrderedPair(-14.8414232124588, -10.2580425144936), + ], + rotation=0, + type="polyline", + visible=False, + coordinates=common_types.OrderedPair(133.791065135842, 24.4446970558145), + ), + ), + ( + """ + { + "height":0, + "id":11, + "name":"name: polyline - rotated", + "polygon":[ + { + "x":0, + "y":0 + }, + { + "x":-12.8771171990451, + "y":0 + }, + { + "x":-6.98419915880413, + "y":7.63896782994203 + }, + { + "x":-13.9683983176083, + "y":16.8057292258725 + }, + { + "x":3.71035580311468, + "y":15.277935659884 + }, + { + "x":-3.71035580311471, + "y":8.29373650107991 + }], + "rotation":123, + "type":"polyline", + "visible":true, + "width":0, + "x":152.779356598841, + "y":19.8613163578493 + } + """, + tiled_object.Polyline( + id_=11, + name="name: polyline - rotated", + points=[ + common_types.OrderedPair(0, 0), + common_types.OrderedPair(-12.8771171990451, 0), + common_types.OrderedPair(-6.98419915880413, 7.63896782994203), + common_types.OrderedPair(-13.9683983176083, 16.8057292258725), + common_types.OrderedPair(3.71035580311468, 15.277935659884), + common_types.OrderedPair(-3.71035580311471, 8.29373650107991), + ], + rotation=123, + type="polyline", + visible=True, + coordinates=common_types.OrderedPair(152.779356598841, 19.8613163578493), + ), + ), + ( + """ + { + "height":0, + "id":12, + "name":"name: polyline - not closed", + "polyline":[ + { + "x":0, + "y":0 + }, + { + "x":-13.3136296464704, + "y":41.0321700579743 + }, + { + "x":21.3891099238377, + "y":16.8057292258725 + }], + "rotation":0, + "type":"polyline", + "visible":true, + "width":0, + "x":124.187791292486, + "y":90.1398203933159 + } + """, + tiled_object.Polyline( + id_=12, + name="name: polyline - not closed", + points=[ + common_types.OrderedPair(0, 0), + common_types.OrderedPair(-13.3136296464704, 41.0321700579743), + common_types.OrderedPair(21.3891099238377, 16.8057292258725), + ], + rotation=0, + type="polyline", + visible=True, + coordinates=common_types.OrderedPair(124.187791292486, 90.1398203933159), + ), + ), +] TEXTS = []