Add support for image tile sub-rect

This commit is contained in:
Darren Eberly
2022-08-13 00:13:19 -04:00
parent 95ed454e95
commit 58deab5f78
9 changed files with 88 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -105,6 +105,8 @@ EXPECTED = tiled_map.TiledMap(
image_width=32,
properties={"float property": 2.2},
class_="tile",
width=32,
height=32,
),
1: tileset.Tile(
id=1,
@@ -147,6 +149,8 @@ EXPECTED = tiled_map.TiledMap(
),
],
),
width=32,
height=32,
properties={"string property": "testing"},
class_="tile",
),
@@ -159,6 +163,8 @@ EXPECTED = tiled_map.TiledMap(
image_width=32,
properties={"bool property": True},
class_="tile",
width=32,
height=32,
),
3: tileset.Tile(
id=3,
@@ -167,6 +173,8 @@ EXPECTED = tiled_map.TiledMap(
.resolve(),
image_height=32,
image_width=32,
width=32,
height=32,
class_="tile",
),
},

View File

@@ -106,6 +106,8 @@ EXPECTED = tiled_map.TiledMap(
.resolve(),
image_height=32,
image_width=32,
width=32,
height=32
)
},
tile_count=1,

View File

@@ -7,12 +7,12 @@ EXPECTED = tileset.Tileset(
margin=0,
spacing=0,
name="tileset",
tile_count=4,
tiled_version="1.6.0",
tile_count=5,
tiled_version="1.9.1",
tile_height=32,
tile_width=32,
firstgid=1,
version="1.6",
version="1.9",
type="tileset",
grid=tileset.Grid(orientation="orthogonal", width=1, height=1),
tiles={
@@ -29,6 +29,8 @@ EXPECTED = tileset.Tileset(
image_width=32,
properties={"float property": 2.2},
class_="tile",
width=32,
height=32,
),
1: tileset.Tile(
id=1,
@@ -67,6 +69,8 @@ EXPECTED = tileset.Tileset(
),
properties={"string property": "testing"},
class_="tile",
width=32,
height=32,
),
2: tileset.Tile(
id=2,
@@ -75,6 +79,8 @@ EXPECTED = tileset.Tileset(
image_width=32,
properties={"bool property": True},
class_="tile",
width=32,
height=32,
),
3: tileset.Tile(
id=3,
@@ -82,6 +88,18 @@ EXPECTED = tileset.Tileset(
image_height=32,
image_width=32,
class_="tile",
width=32,
height=32,
),
4: tileset.Tile(
id=4,
image=Path("../../images/tile_05.png"),
image_height=32,
image_width=64,
x=32,
y=0,
width=32,
height=32
)
},
)

View File

@@ -8,8 +8,8 @@
"margin":0,
"name":"tileset",
"spacing":0,
"tilecount":4,
"tiledversion":"1.9.0",
"tilecount":5,
"tiledversion":"1.9.1",
"tileheight":32,
"tiles":[
{
@@ -108,8 +108,18 @@
"image":"..\/..\/images\/tile_04.png",
"imageheight":32,
"imagewidth":32
},
{
"height":32,
"id":4,
"image":"..\/..\/images\/tile_05.png",
"imageheight":32,
"imagewidth":64,
"width":32,
"x":32,
"y":0
}],
"tilewidth":32,
"type":"tileset",
"version":"1.8"
"version":"1.9"
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.9" tiledversion="1.9.0" name="tileset" tilewidth="32" tileheight="32" tilecount="4" columns="0">
<tileset version="1.9" tiledversion="1.9.1" name="tileset" tilewidth="32" tileheight="32" tilecount="5" columns="0">
<grid orientation="orthogonal" width="1" height="1"/>
<tile id="0" class="tile">
<properties>
@@ -34,4 +34,7 @@
<tile id="3" class="tile">
<image width="32" height="32" source="../../images/tile_04.png"/>
</tile>
<tile id="4" x="32" y="0" width="32" height="32">
<image width="64" height="32" source="../../images/tile_05.png"/>
</tile>
</tileset>