Skip to main content

Atlas

Struct Atlas 

Source
pub struct Atlas { /* private fields */ }
Expand description

An atlas the cook made: its pages, and its sprites by name, each with its frames on the pages and its clips. A game loads it, then its pages as the Textures they are (Atlas::load_pages).

It needs no GPU, so Asset::finalize needs nothing in its context, and a game can make it before its window opens, with AssetServer::load_now. It has no placeholder: a sprite that is not there has no region to stand in for.

Implementations§

Source§

impl Atlas

Source

pub fn pages(&self) -> &[AtlasPage]

The pages: the packed pages, then the tile sets’.

Source

pub fn page(&self, frame: &AtlasFrame) -> Option<&AtlasPage>

The page of frame.

Source

pub fn load_pages( &self, server: &mut AssetServer, scope: Scope, ) -> Vec<Handle<Texture>>

Loads every page with server, in scope, as a Texture, and returns their handles in the order of Atlas::pages, so that a frame’s texture is handles[frame.page()]. Load the pages in the scope the atlas was loaded in, so that unloading it frees them too.

Source

pub fn sprites(&self) -> &[AtlasSprite]

The sprites, in byte order of their names.

Source

pub fn sprite(&self, name: &str) -> Option<&AtlasSprite>

The sprite named name: the image’s path in the source assets without .png, such as sprites/person.

Trait Implementations§

Source§

impl Asset for Atlas

Source§

const EXTENSIONS: &'static [&'static str]

The extensions, without the dot, that a path of this type ends in.
Source§

type Decoded = Atlas

What Asset::decode makes.
Source§

fn decode(bytes: &[u8], ctx: &DecodeCtx<'_>) -> Result<Atlas, AssetError>

Decodes a file’s bytes. Read more
Source§

fn finalize(decoded: Atlas, _: &mut FinalizeCtx<'_>) -> Result<Self, AssetError>

Makes the asset from what Asset::decode made. Read more
Source§

fn placeholder(ctx: &mut FinalizeCtx<'_>) -> Result<Self, AssetError>

Makes the stand-in for an asset that failed to load, when the server shows placeholders (OnFailure::Placeholder). None by default. Read more
Source§

fn release(self, ctx: &mut FinalizeCtx<'_>) -> Result<(), AssetError>

Frees what the asset holds outside the server, such as its GPU texture, once every scope it was loaded in is unloaded. The next AssetServer::finish_completed_loads calls it, with that frame’s context; a placeholder is freed the same way. A reload’s finish calls it too, on the value, or the placeholder, that the reload replaces, while the handle stays and names the new value. By default the asset is only dropped. Read more
Source§

impl Clone for Atlas

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Atlas

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Atlas

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Atlas

Auto Trait Implementations§

§

impl Forget for Atlas

§

impl Freeze for Atlas

§

impl Move for Atlas

§

impl RefUnwindSafe for Atlas

§

impl Send for Atlas

§

impl Sync for Atlas

§

impl Unpin for Atlas

§

impl UnsafeUnpin for Atlas

§

impl UnwindSafe for Atlas

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.