Support for layer tint colors

This commit is contained in:
Darren Eberly
2021-03-31 20:41:59 -04:00
parent 136af7692f
commit 12e498e03f
3 changed files with 11 additions and 0 deletions

View File

@@ -62,6 +62,7 @@ class Layer:
size: Optional[Size] = None
offset: Optional[OrderedPair] = None
properties: Optional[properties_.Properties] = None
tint_color: Optional[Color] = None
TileLayerGrid = List[List[int]]
@@ -202,6 +203,7 @@ class RawLayer(TypedDict):
properties: List[properties_.RawProperty]
startx: int
starty: int
tintcolor: str
transparentcolor: str
type: str
visible: bool
@@ -358,6 +360,9 @@ def _get_common_attributes(raw_layer: RawLayer) -> Layer:
raw_layer["parallaxx"], raw_layer["parallaxy"]
)
if raw_layer.get("tintcolor") is not None:
common_attributes.tint_color = parse_color(raw_layer["tintcolor"])
return common_attributes

View File

@@ -14,6 +14,7 @@ EXPECTED = [
properties={
"test": "test property",
},
tint_color=common_types.Color(170, 255, 255, 255),
data=[
[
1,
@@ -83,6 +84,7 @@ EXPECTED = [
visible=True,
id=4,
parallax_factor=common_types.OrderedPair(2.3, 1.2),
tint_color=common_types.Color(0, 0, 255, 255),
layers=[
layer.ObjectLayer(
name="Object Layer 1",
@@ -111,6 +113,7 @@ EXPECTED = [
id=3,
image=Path("../../images/tile_04.png"),
transparent_color=common_types.Color(0, 0, 0, 255),
tint_color=common_types.Color(255, 0, 0, 255),
),
layer.ImageLayer(
name="Image Layer 2",

View File

@@ -18,6 +18,7 @@
"type":"string",
"value":"test property"
}],
"tintcolor":"#aaffff",
"type":"tilelayer",
"visible":true,
"width":8,
@@ -53,6 +54,7 @@
"opacity":1,
"parallaxx":2.3,
"parallaxy":1.2,
"tintcolor":"#0000ff",
"type":"group",
"visible":true,
"x":0,
@@ -63,6 +65,7 @@
"image":"..\/..\/images\/tile_04.png",
"name":"Image Layer 1",
"opacity":1,
"tintcolor":"#ff0000",
"transparentcolor":"#000000",
"type":"imagelayer",
"visible":true,