Skip to main content

Interpolate

Trait Interpolate 

Source
pub trait Interpolate: Sized {
    // Required method
    fn interpolate(from: Self, to: Self, phase: f32) -> Self;
}
Expand description

A value that AnimationPhase can interpolate.

Implemented for f32, Pixels, Rems, Rgba and Hsla. RGB colors interpolate channel by channel; Hsla takes the shorter path around the hue wheel.

§Examples

use gpui::{Interpolate, Pixels, px};

assert_eq!(f32::interpolate(10.0, 20.0, 0.25), 12.5);
assert_eq!(Pixels::interpolate(px(0.), px(8.), 0.5), px(4.));

Required Methods§

Source

fn interpolate(from: Self, to: Self, phase: f32) -> Self

Returns the value at phase, where 0.0 is from and 1.0 is to.

Phases outside 0.0..=1.0 extrapolate.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Interpolate for f32

Source§

fn interpolate(from: Self, to: Self, phase: f32) -> Self

Implementors§