|
7 | 7 | from arcade.texture_atlas.atlas_default import DefaultTextureAtlas |
8 | 8 |
|
9 | 9 |
|
10 | | -def test_region_coordinates(ctx): |
11 | | - """Test region class.""" |
| 10 | +def test_region_coordinates_simple(ctx): |
| 11 | + """Basic region test.""" |
12 | 12 | atlas = DefaultTextureAtlas(size=(8, 8), border=0, auto_resize=False) |
13 | 13 | region = AtlasRegion(atlas=atlas, x=0, y=0, width=8, height=8) |
14 | 14 | assert region.x == 0 |
15 | 15 | assert region.y == 0 |
16 | 16 | assert region.width == 8 |
17 | 17 | assert region.height == 8 |
18 | 18 | # Simulate the half pixel location |
19 | | - a, b = 0.5 / 8, 1 - 0.5 / 8 |
| 19 | + a, b = 0, 1.0 |
20 | 20 | assert region.texture_coordinates == ( |
21 | 21 | a, a, |
22 | 22 | b, a, |
23 | 23 | a, b, |
24 | 24 | b, b, |
25 | 25 | ) |
26 | | - # Above raw values: |
27 | | - # ( |
28 | | - # 0.0625, 0.0625, |
29 | | - # 0.9375, 0.0625, |
30 | | - # 0.0625, 0.9375, |
31 | | - # 0.9375, 0.9375) |
32 | | - # ) |
| 26 | + |
| 27 | + |
| 28 | +def test_region_coordinates_complex(ctx): |
| 29 | + """A more complex region test.""" |
| 30 | + atlas = DefaultTextureAtlas(size=(16, 16), border=0, auto_resize=False) |
| 31 | + region = AtlasRegion(atlas=atlas, x=1, y=2, width=8, height=6) |
| 32 | + assert region.x == 1 |
| 33 | + assert region.y == 2 |
| 34 | + assert region.width == 8 |
| 35 | + assert region.height == 6 |
| 36 | + assert region.texture_coordinates == (0.0625, 0.125, 0.5625, 0.125, 0.0625, 0.5, 0.5625, 0.5) |
33 | 37 |
|
34 | 38 |
|
35 | 39 | def test_verify_size(ctx): |
36 | 40 | im_data = ImageData(PIL.Image.new("RGBA", (8, 8))) |
37 | | - texture = Texture(im_data) |
38 | 41 | region = AtlasRegion(atlas=ctx.default_atlas, x=0, y=0, width=8, height=8) |
39 | 42 |
|
40 | 43 | region.verify_image_size(im_data) |
|
0 commit comments