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.