forked from pythonarcade/arcade
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 fix is_point_in_poligons and calculate_points for empty images (pyt…
- Loading branch information
Showing
4 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,27 @@ | ||
from uuid import uuid4 | ||
|
||
import PIL | ||
from PIL.Image import Image | ||
|
||
import arcade | ||
|
||
|
||
def test_calculate_points(): | ||
texture = arcade.load_texture(":resources:images/items/coinGold.png") | ||
result = arcade.calculate_points(texture.image) | ||
print(result) | ||
assert result == [(-32, 7), (-17, 28), (7, 32), (29, 15), (32, -7), (17, -28), (-8, -32), (-28, -17)] | ||
|
||
texture = arcade.load_texture(":resources:images/animated_characters/female_person/femalePerson_idle.png") | ||
result = arcade.calculate_points(texture.image) | ||
print(result) | ||
assert result == [(-32, -31), (-22, -18), (-27, -14), (-21, 21), (-8, 31), (10, 31), (25, 17), (29, -16), (22, -18), | ||
(32, -31), (32, -52), (29, -59), (17, -57), (22, -39), (15, -28), (19, -63), (4, -64), (-2, -46), | ||
(-3, -63), (-18, -64), (-15, -30), (-22, -39), (-16, -47), (-18, -59), (-31, -56)] | ||
|
||
|
||
def test_empty_image(): | ||
texture = arcade.Texture(name=str(uuid4()), image=PIL.Image.new("RGBA", (50, 50))) | ||
result = arcade.calculate_points(texture.image) | ||
print(result) | ||
assert result == [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import arcade | ||
|
||
|
||
def test_point_in_rectangle(): | ||
poligon = [ | ||
(0, 0), | ||
(0, 50), | ||
(50, 50), | ||
(50, 0), | ||
] | ||
result = arcade.is_point_in_polygon(25, 25, poligon) | ||
assert result is True | ||
|
||
|
||
def test_point_not_in_empty_poligon(): | ||
poligon = [] | ||
result = arcade.is_point_in_polygon(25, 25, poligon) | ||
assert result is False |