pub struct AsepriteFile<'a> {
pub file: File<'a>,
pub layers: Vec<Layer>,
pub frames: Vec<Frame>,
pub tags: Vec<Tag>,
pub images: Vec<Image<'a>>,
}Expand description
This can be used to load an Aseprite file.
Fields§
§file: File<'a>Parsed low-level file representation.
layers: Vec<Layer>All layers in the file in order
frames: Vec<Frame>All frames in the file in order
All tags in the file
images: Vec<Image<'a>>All images in the file
Implementations§
Source§impl AsepriteFile<'_>
impl AsepriteFile<'_>
Sourcepub fn load(data: &[u8]) -> Result<AsepriteFile<'_>, LoadSpriteError>
pub fn load(data: &[u8]) -> Result<AsepriteFile<'_>, LoadSpriteError>
Load a aseprite file from a byte slice
Get tag names
Sourcepub fn image_count(&self) -> usize
pub fn image_count(&self) -> usize
Get image count
Sourcepub fn select_layers(
&self,
predicate: impl Fn(&Layer) -> bool,
) -> LayerSelection
pub fn select_layers( &self, predicate: impl Fn(&Layer) -> bool, ) -> LayerSelection
Convert layer names into a LayerSelection for use with
render_frame.
The premise is used to select the layers which should be included.
Sourcepub fn select_layers_by_name(&self, names: &[&str]) -> LayerSelection
pub fn select_layers_by_name(&self, names: &[&str]) -> LayerSelection
Convert layer names into a LayerSelection for use with
render_frame.
The returned selection marks a layer as visible if its name appears
in names. Call this once and reuse the result across frames.
Sourcepub fn combined_frame_image(
&self,
frame_index: usize,
target: &mut [u8],
) -> Result<u64, LoadImageError>
👎Deprecated: Use render_frame instead.
pub fn combined_frame_image( &self, frame_index: usize, target: &mut [u8], ) -> Result<u64, LoadImageError>
render_frame instead.Render a frame for a given frame index. This combines all visible layers into a buffer.
Returns a hash describing the image, since cels can be reused in multiple frames.
Sourcepub fn render_frame(
&self,
frame_index: usize,
target: &mut [u8],
layers: &LayerSelection,
) -> Result<(), LoadImageError>
pub fn render_frame( &self, frame_index: usize, target: &mut [u8], layers: &LayerSelection, ) -> Result<(), LoadImageError>
Render a frame for a given frame index. This combines layers depending on the layer selection into a buffer.
The target buffer must be at least width * height * 4 bytes.
Pixels are written as RGBA8.
Sourcepub fn load_image(
&self,
index: usize,
target: &mut [u8],
) -> Result<(), LoadImageError>
pub fn load_image( &self, index: usize, target: &mut [u8], ) -> Result<(), LoadImageError>
Get image loader for a given image index
Sourcepub fn slices(&self) -> &[SliceChunk<'_>]
pub fn slices(&self) -> &[SliceChunk<'_>]
Return all slice chunks from the source file.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for AsepriteFile<'a>
impl<'a> RefUnwindSafe for AsepriteFile<'a>
impl<'a> Send for AsepriteFile<'a>
impl<'a> Sync for AsepriteFile<'a>
impl<'a> Unpin for AsepriteFile<'a>
impl<'a> UnsafeUnpin for AsepriteFile<'a>
impl<'a> UnwindSafe for AsepriteFile<'a>
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more