MCPcopy Create free account
hub / github.com/PerroEngine/Perro / parse_ease_value

Function parse_ease_value

perro_source/core/perro_animation/src/panim/fields.rs:511–526  ·  view source on GitHub ↗
(value: &SceneValue, line_no: usize)

Source from the content-addressed store, hash-verified

509 let norm = raw.to_ascii_lowercase().replace(['-', ' '], "_");
510 match norm.as_str() {
511 "step" => Ok(AnimationInterpolation::Step),
512 "interpolate" | "linear" | "lerp" | "slerp" => Ok(AnimationInterpolation::Linear),
513 _ => Err(format!(
514 "line {}: unknown interpolation `{}` (expected `step` or `interpolate`)",
515 line_no, raw
516 )),
517 }
518}
519
520fn parse_ease_value(value: &SceneValue, line_no: usize) -> Result<AnimationEase, String> {
521 let raw = as_text(value)
522 .ok_or_else(|| format!("line {}: ease expects text", line_no))?
523 .trim();
524 let norm = raw.to_ascii_lowercase().replace(['-', ' '], "_");
525 match norm.as_str() {
526 "linear" => Ok(AnimationEase::Linear),
527 "ease_in" | "easein" | "in" => Ok(AnimationEase::EaseIn),
528 "ease_out" | "easeout" | "out" => Ok(AnimationEase::EaseOut),
529 "ease_in_out" | "easeinout" | "in_out" => Ok(AnimationEase::EaseInOut),

Callers 2

parse_animation_blockMethod · 0.85

Calls 2

as_textFunction · 0.85
as_strMethod · 0.45

Tested by

no test coverage detected