Skip to content

Commit 12e498e

Browse files
committed
Support for layer tint colors
1 parent 136af76 commit 12e498e

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

pytiled_parser/layer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class Layer:
6262
size: Optional[Size] = None
6363
offset: Optional[OrderedPair] = None
6464
properties: Optional[properties_.Properties] = None
65+
tint_color: Optional[Color] = None
6566

6667

6768
TileLayerGrid = List[List[int]]
@@ -202,6 +203,7 @@ class RawLayer(TypedDict):
202203
properties: List[properties_.RawProperty]
203204
startx: int
204205
starty: int
206+
tintcolor: str
205207
transparentcolor: str
206208
type: str
207209
visible: bool
@@ -358,6 +360,9 @@ def _get_common_attributes(raw_layer: RawLayer) -> Layer:
358360
raw_layer["parallaxx"], raw_layer["parallaxy"]
359361
)
360362

363+
if raw_layer.get("tintcolor") is not None:
364+
common_attributes.tint_color = parse_color(raw_layer["tintcolor"])
365+
361366
return common_attributes
362367

363368

tests/test_data/layer_tests/all_layer_types/expected.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
properties={
1515
"test": "test property",
1616
},
17+
tint_color=common_types.Color(170, 255, 255, 255),
1718
data=[
1819
[
1920
1,
@@ -83,6 +84,7 @@
8384
visible=True,
8485
id=4,
8586
parallax_factor=common_types.OrderedPair(2.3, 1.2),
87+
tint_color=common_types.Color(0, 0, 255, 255),
8688
layers=[
8789
layer.ObjectLayer(
8890
name="Object Layer 1",
@@ -111,6 +113,7 @@
111113
id=3,
112114
image=Path("../../images/tile_04.png"),
113115
transparent_color=common_types.Color(0, 0, 0, 255),
116+
tint_color=common_types.Color(255, 0, 0, 255),
114117
),
115118
layer.ImageLayer(
116119
name="Image Layer 2",

tests/test_data/layer_tests/all_layer_types/map.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"type":"string",
1919
"value":"test property"
2020
}],
21+
"tintcolor":"#aaffff",
2122
"type":"tilelayer",
2223
"visible":true,
2324
"width":8,
@@ -53,6 +54,7 @@
5354
"opacity":1,
5455
"parallaxx":2.3,
5556
"parallaxy":1.2,
57+
"tintcolor":"#0000ff",
5658
"type":"group",
5759
"visible":true,
5860
"x":0,
@@ -63,6 +65,7 @@
6365
"image":"..\/..\/images\/tile_04.png",
6466
"name":"Image Layer 1",
6567
"opacity":1,
68+
"tintcolor":"#ff0000",
6669
"transparentcolor":"#000000",
6770
"type":"imagelayer",
6871
"visible":true,

0 commit comments

Comments
 (0)