Changes to API

Should make integration with game engines easier in general.

Puts the burden of color parsing on Pytiled. As well as formatting layer data into a two dimensional list from a straight one dimensional.
This commit is contained in:
Darren Eberly
2021-02-21 00:58:30 -05:00
parent ed825c5b71
commit 674b4b50c4
24 changed files with 700 additions and 738 deletions

View File

@@ -10,56 +10,70 @@ EXPECTED = [
id=1,
size=common_types.Size(8, 6),
offset=common_types.OrderedPair(1, 3),
properties={"test": "test property",},
properties={
"test": "test property",
},
data=[
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
[
1,
2,
3,
4,
5,
6,
7,
8,
],
[
9,
10,
11,
12,
13,
14,
15,
16,
],
[
17,
18,
19,
20,
21,
22,
23,
24,
],
[
25,
26,
27,
28,
29,
30,
31,
32,
],
[
33,
34,
35,
36,
37,
38,
39,
40,
],
[
41,
42,
43,
44,
45,
46,
47,
48,
],
],
),
layer.LayerGroup(
@@ -94,7 +108,7 @@ EXPECTED = [
visible=True,
id=3,
image=Path("../../images/tile_04.png"),
transparent_color=common_types.Color("#000000"),
transparent_color=common_types.Color(0, 0, 0, 255),
),
layer.ImageLayer(
name="Image Layer 2",

View File

@@ -10,54 +10,66 @@ EXPECTED = [
id=1,
size=common_types.Size(8, 6),
data=[
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
[
1,
2,
3,
4,
5,
6,
7,
8,
],
[
9,
10,
11,
12,
13,
14,
15,
16,
],
[
17,
18,
19,
20,
21,
22,
23,
24,
],
[
25,
26,
27,
28,
29,
30,
31,
32,
],
[
33,
34,
35,
36,
37,
38,
39,
40,
],
[
41,
42,
43,
44,
45,
46,
47,
48,
],
],
),
layer.LayerGroup(
@@ -92,6 +104,6 @@ EXPECTED = [
visible=True,
id=3,
image=Path("../../images/tile_04.png"),
transparent_color=common_types.Color("#000000"),
transparent_color=common_types.Color(0, 0, 0, 255),
),
]

View File

@@ -10,54 +10,66 @@ EXPECTED = [
id=1,
size=common_types.Size(8, 6),
data=[
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
[
1,
2,
3,
4,
5,
6,
7,
8,
],
[
9,
10,
11,
12,
13,
14,
15,
16,
],
[
17,
18,
19,
20,
21,
22,
23,
24,
],
[
25,
26,
27,
28,
29,
30,
31,
32,
],
[
33,
34,
35,
36,
37,
38,
39,
40,
],
[
41,
42,
43,
44,
45,
46,
47,
48,
],
],
),
layer.LayerGroup(
@@ -92,6 +104,6 @@ EXPECTED = [
visible=True,
id=3,
image=Path("../../images/tile_04.png"),
transparent_color=common_types.Color("#000000"),
transparent_color=common_types.Color(0, 0, 0, 255),
),
]

View File

@@ -10,54 +10,66 @@ EXPECTED = [
id=1,
size=common_types.Size(8, 6),
data=[
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
[
1,
2,
3,
4,
5,
6,
7,
8,
],
[
9,
10,
11,
12,
13,
14,
15,
16,
],
[
17,
18,
19,
20,
21,
22,
23,
24,
],
[
25,
26,
27,
28,
29,
30,
31,
32,
],
[
33,
34,
35,
36,
37,
38,
39,
40,
],
[
41,
42,
43,
44,
45,
46,
47,
48,
],
],
),
layer.LayerGroup(
@@ -92,6 +104,6 @@ EXPECTED = [
visible=True,
id=3,
image=Path("../../images/tile_04.png"),
transparent_color=common_types.Color("#000000"),
transparent_color=common_types.Color(0, 0, 0, 255),
),
]

View File

@@ -10,82 +10,116 @@ EXPECTED = [
id=1,
size=common_types.Size(16, 16),
offset=common_types.OrderedPair(163.089434111595, 116.462603878116),
properties={"test": "test property",},
properties={
"test": "test property",
},
chunks=[
layer.Chunk(
coordinates=common_types.OrderedPair(0, 0),
size=common_types.Size(4, 8),
data=[
1,
2,
3,
4,
9,
10,
11,
12,
17,
18,
19,
20,
25,
26,
27,
28,
33,
34,
35,
36,
41,
42,
43,
44,
0,
0,
0,
0,
0,
0,
0,
0,
[
1,
2,
3,
4,
],
[
9,
10,
11,
12,
],
[
17,
18,
19,
20,
],
[
25,
26,
27,
28,
],
[
33,
34,
35,
36,
],
[
41,
42,
43,
44,
],
[
0,
0,
0,
0,
],
[
0,
0,
0,
0,
],
],
),
layer.Chunk(
coordinates=common_types.OrderedPair(4, 0),
size=common_types.Size(4, 8),
data=[
5,
6,
7,
8,
13,
14,
15,
16,
21,
22,
23,
24,
29,
30,
31,
32,
37,
38,
39,
40,
45,
46,
47,
48,
0,
0,
0,
0,
0,
0,
0,
0,
[
5,
6,
7,
8,
],
[
13,
14,
15,
16,
],
[
21,
22,
23,
24,
],
[
29,
30,
31,
32,
],
[
37,
38,
39,
40,
],
[
45,
46,
47,
48,
],
[
0,
0,
0,
0,
],
[
0,
0,
0,
0,
],
],
),
],

View File

@@ -10,268 +10,30 @@ EXPECTED = [
id=1,
size=common_types.Size(16, 16),
offset=common_types.OrderedPair(1, 3),
properties={"test": "test property",},
properties={
"test": "test property",
},
chunks=[
layer.Chunk(
coordinates=common_types.OrderedPair(0, 0),
size=common_types.Size(16, 16),
data=[
1,
2,
3,
4,
5,
6,
7,
8,
0,
0,
0,
0,
0,
0,
0,
0,
9,
10,
11,
12,
13,
14,
15,
16,
0,
0,
0,
0,
0,
0,
0,
0,
17,
18,
19,
20,
21,
22,
23,
24,
0,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