pub struct SpriteAtlas {
pub image: Arc<ImageAsset>,
pub sheet: SpriteSheet,
}Expand description
An immutable, uniformly sized atlas; unused cells are transparent.
Fields§
§image: Arc<ImageAsset>Single GPU/CPU shared material.
sheet: SpriteSheetSelects cells from custom[0].
Implementations§
Source§impl SpriteAtlas
impl SpriteAtlas
Sourcepub fn new(
images: &[Arc<ImageAsset>],
max_bytes: u64,
) -> Result<Self, ValidationError>
pub fn new( images: &[Arc<ImageAsset>], max_bytes: u64, ) -> Result<Self, ValidationError>
Packs 1..=64 equally sized images under a conservative construction/mipmap budget.
Sourcepub fn new_padded(
images: &[Arc<ImageAsset>],
max_bytes: u64,
) -> Result<Self, ValidationError>
pub fn new_padded( images: &[Arc<ImageAsset>], max_bytes: u64, ) -> Result<Self, ValidationError>
Packs 1..=64 images of any size: every cell is as large as the biggest
image and smaller images are centred on transparent padding, so the
uniform-cell sheet protocol (and CPU/GPU sampling) is unchanged. Sprites
keep their relative pixel scale; a sprite drawn at size spans the whole
cell.
Sourcepub fn random(self, seed: u64) -> Self
pub fn random(self, seed: u64) -> Self
Selects sub-images by stable particle index and seed, so a particle keeps
the same texture for its whole life.
Sourcepub fn style(
&self,
size: f64,
align_to_velocity: bool,
) -> Result<ParticleStyle, ValidationError>
pub fn style( &self, size: f64, align_to_velocity: bool, ) -> Result<ParticleStyle, ValidationError>
Builds a Sprites style that selects cells according to self.sheet.mode
(Custom reads particle.custom[0]) and carries the sheet already.
Trait Implementations§
Auto Trait Implementations§
impl Forget for SpriteAtlas
impl Freeze for SpriteAtlas
impl RefUnwindSafe for SpriteAtlas
impl Send for SpriteAtlas
impl Sync for SpriteAtlas
impl Unpin for SpriteAtlas
impl UnsafeUnpin for SpriteAtlas
impl UnwindSafe for SpriteAtlas
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more