From ed3159373d084c83df78595735336492148e9b2a Mon Sep 17 00:00:00 2001 From: Darren Eberly Date: Fri, 9 Jul 2021 21:06:11 -0400 Subject: [PATCH] Fix color parsing --- pytiled_parser/util.py | 2 +- tests/test_data/map_tests/external_tileset_dif_dir/expected.py | 2 +- tests/test_data/map_tests/no_layers/expected.py | 2 +- tests/test_data/map_tests/template/expected.py | 2 +- tests/test_data/tilesets/image_properties/expected.py | 2 +- tests/test_tiled_object.py | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pytiled_parser/util.py b/pytiled_parser/util.py index 8db180a..75c7d1d 100644 --- a/pytiled_parser/util.py +++ b/pytiled_parser/util.py @@ -20,10 +20,10 @@ def parse_color(color: str) -> Color: return Color(int(color[0:2], 16), int(color[2:4], 16), int(color[4:6], 16), 255) elif len(color) == 8: return Color( - int(color[0:2], 16), int(color[2:4], 16), int(color[4:6], 16), int(color[6:8], 16), + int(color[0:2], 16), ) raise ValueError("Improperly formatted color passed to parse_color") diff --git a/tests/test_data/map_tests/external_tileset_dif_dir/expected.py b/tests/test_data/map_tests/external_tileset_dif_dir/expected.py index 1e86629..61687df 100644 --- a/tests/test_data/map_tests/external_tileset_dif_dir/expected.py +++ b/tests/test_data/map_tests/external_tileset_dif_dir/expected.py @@ -173,7 +173,7 @@ EXPECTED = tiled_map.TiledMap( }, properties={ "bool property - true": True, - "color property": common_types.Color(255, 73, 252, 255), + "color property": common_types.Color(73, 252, 255, 255), "file property": Path("../../../../../../var/log/syslog"), "float property": 1.23456789, "int property": 13, diff --git a/tests/test_data/map_tests/no_layers/expected.py b/tests/test_data/map_tests/no_layers/expected.py index 7bc5ca2..ab8b5ca 100644 --- a/tests/test_data/map_tests/no_layers/expected.py +++ b/tests/test_data/map_tests/no_layers/expected.py @@ -35,7 +35,7 @@ EXPECTED = tiled_map.TiledMap( }, properties={ "bool property - true": True, - "color property": common_types.Color(255, 73, 252, 255), + "color property": common_types.Color(73, 252, 255, 255), "file property": Path("../../../../../../var/log/syslog"), "float property": 1.23456789, "int property": 13, diff --git a/tests/test_data/map_tests/template/expected.py b/tests/test_data/map_tests/template/expected.py index ae8f84a..5cab7fc 100644 --- a/tests/test_data/map_tests/template/expected.py +++ b/tests/test_data/map_tests/template/expected.py @@ -68,7 +68,7 @@ EXPECTED = tiled_map.TiledMap( }, properties={ "bool property - true": True, - "color property": common_types.Color(255, 73, 252, 255), + "color property": common_types.Color(73, 252, 255, 255), "file property": Path("../../../../../../var/log/syslog"), "float property": 1.23456789, "int property": 13, diff --git a/tests/test_data/tilesets/image_properties/expected.py b/tests/test_data/tilesets/image_properties/expected.py index d756b2b..f83a9fb 100644 --- a/tests/test_data/tilesets/image_properties/expected.py +++ b/tests/test_data/tilesets/image_properties/expected.py @@ -18,7 +18,7 @@ EXPECTED = tileset.Tileset( version="1.6", properties={ "bool property": True, - "color property": Color(255, 0, 0, 255), + "color property": Color(0, 0, 255, 255), "float property": 5.6, "int property": 5, "string property": "testing", diff --git a/tests/test_tiled_object.py b/tests/test_tiled_object.py index f202029..10e71c4 100644 --- a/tests/test_tiled_object.py +++ b/tests/test_tiled_object.py @@ -261,7 +261,7 @@ RECTANGLES = [ coordinates=common_types.OrderedPair(39.0678640445606, 131.826759122428), properties={ "bool property": False, - "color property": common_types.Color(255, 170, 0, 0), + "color property": common_types.Color(170, 0, 0, 255), "file property": Path("../../../../../../dev/null"), "float property": 42.1, "int property": 8675309,