Struct lux::graphics::NonUniformSpriteSheet [] [src]

pub struct NonUniformSpriteSheet<K: Hash + Eq> {
    pub sprite: Sprite,
    pub mapping: HashMap<K, Sprite>,
}

A uniform sprite sheet is a sprite sheet that has parts of the original sprite broken up into chunks that are associated to a Key.

A NonUniformSpriteSheet can be obtained by calling as_non_uniform_sprite_sheet on a Sprite object.

Fields

sprite

The sprite that this sprite sheet indexes into

mapping

The mapping from a key to a subsprite

Methods

impl<K: Eq + Hash> NonUniformSpriteSheet<K>

A non-uniform spritesheet is a sprite-sheet that is indexable by arbitrary keys.

fn associate(&mut self, key: K, pos: (u32, u32), size: (u32, u32))

Associates a key with a sprite location.

fn get<Q: ?Sized>(&self, key: &Q) -> Sprite where Q: Hash + Eq + Debug, K: Borrow<Q>

Gets the sprite that is associated with a key.

Failure

Fails if the key doesn't associate to something yet.

fn get_opt<Q: ?Sized>(&self, key: &Q) -> Option<Sprite> where Q: Hash + Eq, K: Borrow<Q>

Same as get but returns None instead of failing if the key doesn't associate to anything.

Trait Implementations

Derived Implementations

impl<K: Debug + Hash + Eq> Debug for NonUniformSpriteSheet<K> where K: Debug

fn fmt(&self, __arg_0: &mut Formatter) -> Result

impl<K: Clone + Hash + Eq> Clone for NonUniformSpriteSheet<K> where K: Clone

fn clone(&self) -> NonUniformSpriteSheet<K>

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