Struct asefile::AsepriteFile

source ·
pub struct AsepriteFile { /* private fields */ }
Expand description

A parsed Aseprite file.

Implementations§

source§

impl AsepriteFile

source

pub fn read_file(path: &Path) -> Result<Self>

Load Aseprite file. Loads full file into memory.

source

pub fn read<R: Read>(input: R) -> Result<AsepriteFile>

Load Aseprite file from any input that implements std::io::Read.

You can use this to read from an in-memory file.

source

pub fn width(&self) -> usize

Width in pixels.

source

pub fn height(&self) -> usize

Height in pixels.

source

pub fn size(&self) -> (usize, usize)

Width and height in pixels.

source

pub fn num_frames(&self) -> u32

Number of animation frames.

source

pub fn num_layers(&self) -> u32

Number of layers.

source

pub fn pixel_format(&self) -> PixelFormat

The pixel format used by the origal file. This library internally represents all images as RGBA.

source

pub fn palette(&self) -> Option<&ColorPalette>

The color palette in the image.

For indexed color images, this includes all colors used by individual cels. However, the final image after layer blending may contain colors outside of this palette (or with different transparency levels).

source

pub fn is_indexed_color(&self) -> bool

Does this file use indexed color format.

source

pub fn transparent_color_index(&self) -> Option<u8>

The color index of the transparent pixel.

source

pub fn layer(&self, id: u32) -> Layer<'_>

Access a layer by ID.

§Panics

Panics if the ID is not valid. ID must be less than number of layers.

source

pub fn layer_by_name(&self, name: &str) -> Option<Layer<'_>>

Access a layer by name.

If multiple layers with the same name exist returns the layer with the lower ID.

source

pub fn layers(&self) -> LayersIter<'_>

An iterator over all layers.

source

pub fn frame(&self, index: u32) -> Frame<'_>

A reference to a single frame.

§Panics

Panics if index is not less than num_frames.

source

pub fn cel(&self, frame: u32, layer: u32) -> Cel<'_>

Get a direct reference to a Cel.

Argument order is x, y if you think of the timeline panel in the GUI.

§Panics

Panics if frame is not less than num_frames or if layer is not less than num_layers.

source

pub fn external_files(&self) -> &ExternalFilesById

A mapping from external file ids to external files.

source

pub fn external_file_by_id(&self, id: &ExternalFileId) -> Option<&ExternalFile>

Get a reference to an external file by ID, if the file exists.

source

pub fn num_tags(&self) -> u32

Total number of tags.

source

pub fn get_tag(&self, tag_id: u32) -> Option<&Tag>

Get a reference to the tag by ID.

source

pub fn tag(&self, tag_id: u32) -> &Tag

Get a reference to the tag by ID.

§Panics

Panics if tag_id is not less than num_tags.

source

pub fn tag_by_name(&self, name: &str) -> Option<&Tag>

Lookup tag by name.

If multiple tags with the same name exist, returns the one with the lower ID.

source

pub fn tilesets(&self) -> &TilesetsById

Access the file’s Tilesets.

source

pub fn tilemap(&self, layer_id: u32, frame: u32) -> Option<Tilemap<'_>>

Get the Tilemap at the given cel.

Returns None if the cel is empty or if it is not a tilemap.

source

pub fn sprite_user_data(&self) -> Option<&UserData>

The user data for the entire sprite, if any exists.

source

pub fn slices(&self) -> &[Slice]

All Slices in the file.

Trait Implementations§

source§

impl Debug for AsepriteFile

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.