pub struct Interval { /* private fields */ }Expand description
A half-open interval [start, start + duration) on a timeline.
This is the single definition of “time range to progress” shared by
SceneContext::progress_in, SceneContext::ease_in and crate::Tween.
Comparisons use integer ticks; a zero duration jumps from zero to one at start.
use motion_core::prelude::*;
use motion_core::Interval;
let interval = Interval::new(Time::ZERO + 1.seconds(), 2.seconds());
assert_eq!(interval.progress(Time::ZERO), 0.0);
assert_eq!(interval.progress(Time::ZERO + 2.seconds()), 0.5);
assert_eq!(interval.progress(Time::ZERO + 5.seconds()), 1.0);Implementations§
Source§impl Interval
impl Interval
Sourcepub const fn new(start: Time, duration: Duration) -> Self
pub const fn new(start: Time, duration: Duration) -> Self
Creates an interval starting at start and lasting duration.
Sourcepub fn contains(&self, time: Time) -> bool
pub fn contains(&self, time: Time) -> bool
Reports whether time lies in [start, start + duration).
Wide integer differences allow queries across opposite signed tick extremes.
Trait Implementations§
impl Copy for Interval
impl Eq for Interval
impl StructuralPartialEq for Interval
Auto Trait Implementations§
impl Forget for Interval
impl Freeze for Interval
impl Move for Interval
impl RefUnwindSafe for Interval
impl Send for Interval
impl Sync for Interval
impl Unpin for Interval
impl UnsafeUnpin for Interval
impl UnwindSafe for Interval
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