pub struct ExpressionLibrary { /* private fields */ }Expand description
A library of named expression presets.
Implementations§
Source§impl ExpressionLibrary
impl ExpressionLibrary
Sourcepub fn add(&mut self, preset: ExpressionPreset)
pub fn add(&mut self, preset: ExpressionPreset)
Add a preset to the library (keyed by preset.name).
Sourcepub fn get(&self, name: &str) -> Option<&ExpressionPreset>
pub fn get(&self, name: &str) -> Option<&ExpressionPreset>
Look up a preset by name.
Sourcepub fn list_names(&self) -> Vec<&str>
pub fn list_names(&self) -> Vec<&str>
Return sorted list of all preset names.
Sourcepub fn list_by_tag(&self, tag: &str) -> Vec<&ExpressionPreset>
pub fn list_by_tag(&self, tag: &str) -> Vec<&ExpressionPreset>
Return all presets that carry the given tag.
Sourcepub fn default_library() -> Self
pub fn default_library() -> Self
Build a default library with ~11 common facial expressions.
Sourcepub fn blend(
&self,
name_a: &str,
name_b: &str,
t: f32,
) -> Option<HashMap<String, f32>>
pub fn blend( &self, name_a: &str, name_b: &str, t: f32, ) -> Option<HashMap<String, f32>>
Linearly interpolate morph weights between two named presets.
t = 0.0 → all weights from name_a; t = 1.0 → all weights from name_b.
Keys not present in a preset are treated as weight 0.0.
Sourcepub fn apply_intensity(preset: &ExpressionPreset) -> HashMap<String, f32>
pub fn apply_intensity(preset: &ExpressionPreset) -> HashMap<String, f32>
Scale a preset’s weights by its intensity field.
Sourcepub fn combine(presets: &[&ExpressionPreset]) -> HashMap<String, f32>
pub fn combine(presets: &[&ExpressionPreset]) -> HashMap<String, f32>
Additively combine multiple presets (clamped to [0, 1]).
Sourcepub fn random_blend(
presets: &[&ExpressionPreset],
seed: u32,
) -> HashMap<String, f32>
pub fn random_blend( presets: &[&ExpressionPreset], seed: u32, ) -> HashMap<String, f32>
Generate a pseudo-random blend of 2–3 presets from the given slice.
Uses a simple LCG seeded by seed to pick indices and mixing weights.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExpressionLibrary
impl RefUnwindSafe for ExpressionLibrary
impl Send for ExpressionLibrary
impl Sync for ExpressionLibrary
impl Unpin for ExpressionLibrary
impl UnsafeUnpin for ExpressionLibrary
impl UnwindSafe for ExpressionLibrary
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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