pub struct SpriteSheet {
pub cell_width: u32,
pub cell_height: u32,
pub cols: u32,
pub rows: u32,
pub sheet_width: u32,
pub sheet_height: u32,
pub data: Vec<u8>,
pub timestamps_ms: Vec<u64>,
}Expand description
A sprite sheet: a single wide RGBA image that tiles multiple thumbnails left-to-right, top-to-bottom.
Each cell in the sprite sheet corresponds to one thumbnail at a known timestamp. The sheet is intended for use with an accompanying VTT file so that video players can display scrubber previews.
Fields§
§cell_width: u32Width of each individual thumbnail cell in pixels.
cell_height: u32Height of each individual thumbnail cell in pixels.
cols: u32Number of columns in the sheet.
rows: u32Number of rows in the sheet.
sheet_width: u32Total width of the assembled image (cols * cell_width).
sheet_height: u32Total height of the assembled image (rows * cell_height).
data: Vec<u8>Raw RGBA pixel data (row-major, top-to-bottom).
timestamps_ms: Vec<u64>Timestamps (ms) for each cell, in row-major order.
Implementations§
Source§impl SpriteSheet
impl SpriteSheet
Sourcepub fn from_thumbnails(thumbnails: &[Thumbnail], cols: u32) -> Option<Self>
pub fn from_thumbnails(thumbnails: &[Thumbnail], cols: u32) -> Option<Self>
Assembles a sprite sheet from a collection of Thumbnails.
Thumbnails are laid out left-to-right, top-to-bottom. All thumbnails must have the same dimensions; if they differ they are silently scaled to the first thumbnail’s dimensions using nearest-neighbour sampling.
Returns None when thumbnails is empty.
Sourcepub fn cell_origin(&self, idx: usize) -> (u32, u32)
pub fn cell_origin(&self, idx: usize) -> (u32, u32)
Returns the pixel coordinate (x, y) of the top-left corner of the
cell at idx within the sprite sheet.
Sourcepub fn to_vtt(&self, sprite_url: &str) -> String
pub fn to_vtt(&self, sprite_url: &str) -> String
Generates a WebVTT cue file (.vtt) for this sprite sheet.
§Arguments
sprite_url– URL of the sprite sheet image referenced from the VTT.
The returned string is a complete WebVTT document that can be written to disk and served alongside the sprite sheet image.
Sourcepub fn cell_count(&self) -> usize
pub fn cell_count(&self) -> usize
Returns the total number of cells in the sprite sheet.
Trait Implementations§
Source§impl Clone for SpriteSheet
impl Clone for SpriteSheet
Source§fn clone(&self) -> SpriteSheet
fn clone(&self) -> SpriteSheet
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SpriteSheet
impl RefUnwindSafe for SpriteSheet
impl Send for SpriteSheet
impl Sync for SpriteSheet
impl Unpin for SpriteSheet
impl UnsafeUnpin for SpriteSheet
impl UnwindSafe for SpriteSheet
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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