-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Closes #1828 * More fixes * pep8
- Loading branch information
Showing
4 changed files
with
56 additions
and
54 deletions.
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 was deleted.
Oops, something went wrong.
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,35 @@ | ||
""" | ||
Test syncing atlas textures back into PIL images. | ||
""" | ||
from PIL import Image, ImageDraw | ||
import arcade | ||
|
||
|
||
def _create_image_with_rect(rect) -> Image.Image: | ||
# Create an image with a centered square | ||
im = Image.new("RGBA", (10, 10), (0, 0, 0, 0)) | ||
draw = ImageDraw.Draw(im) | ||
draw.rectangle(rect, fill=(255, 0, 0, 255)) | ||
return im | ||
|
||
|
||
def test_update_texture_image_from_atlas(): | ||
# Original image | ||
im = _create_image_with_rect((1, 1, 4, 4)) | ||
im = im.transpose(Image.FLIP_TOP_BOTTOM) | ||
|
||
atlas = arcade.TextureAtlas((256, 256), border=10) | ||
tex = arcade.Texture(im) | ||
atlas.add(tex) | ||
|
||
# Check that the original image matches | ||
atlas_im = atlas.read_texture_image_from_atlas(tex) | ||
assert atlas_im.tobytes() == im.tobytes() | ||
|
||
# Render new content and verify this content | ||
with atlas.render_into(tex) as area: | ||
area.clear() | ||
arcade.draw_lrbt_rectangle_filled(1, 5, 1, 5, arcade.color.RED) | ||
|
||
atlas_im = atlas.read_texture_image_from_atlas(tex) | ||
assert atlas_im.tobytes() == im.tobytes() |