bevy/crates/bevy_sprite
ickshonpe e663d45e94
TextureAtlasBuilder padding (#9494)
# Objective

`TextureAtlas` supports pregenerated texture atlases with padding, but
`TextureAtlasBuilder` can't add padding when it creates a new atlas.

fixes #8150

## Solution

Add a method `padding` to `TextureAtlasBuilder` that sets the amount of
padding to add around each texture.

When queueing the textures to be copied, add the padding value to the
size of each source texture. Then when copying the source textures to
the output atlas texture subtract the same padding value from the sizes
of the target rects.

unpadded:
<img width="961" alt="texture_atlas_example"
src="https://github.com/bevyengine/bevy/assets/27962798/8cf02442-dc3e-4429-90f1-543bc9270d8b">

padded:
<img width="961" alt="texture_atlas_example_with_padding"
src="https://github.com/bevyengine/bevy/assets/27962798/da347bcc-b083-4650-ba0c-86883853764f">


---

## Changelog
`TextureAtlasBuilder`
* Added support for building texture atlases with padding.
* Adds a `padding` method to `TextureAtlasBuilder` that can be used to
set an amount of padding to add between the sprites of the generated
texture atlas.

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2023-09-08 15:02:48 +00:00
..
src TextureAtlasBuilder padding (#9494) 2023-09-08 15:02:48 +00:00
Cargo.toml Bump Version after Release (#9106) 2023-07-10 21:19:27 +00:00