Struct scribl_curves::TimeSpan[][src]

pub struct TimeSpan { /* fields omitted */ }

An interval of times.

Implementations

impl TimeSpan[src]

pub fn new(start: Time, end: Time) -> TimeSpan[src]

Creates a new TimeSpan representing the closed interval [start, end].

Panics

Panics if start > end.

pub fn start(&self) -> Time[src]

The starting time of this TimeSpan.

pub fn end(&self) -> Time[src]

The ending time of this TimeSpan.

pub fn interpolate_to(&self, time: Time, other: TimeSpan) -> Time[src]

Interpolates from a time in this timespan to a time in other.

Panics

Panics if time doesn't belong to this TimeSpan.

Example

use scribl_curves::{Time, TimeSpan};
let me = TimeSpan::new(Time::from_micros(0), Time::from_micros(100));
let other = TimeSpan::new(Time::from_micros(0), Time::from_micros(10));

assert_eq!(me.interpolate_to(Time::from_micros(50), other), Time::from_micros(5));
assert_eq!(me.interpolate_to(Time::from_micros(59), other), Time::from_micros(5));
assert_eq!(me.interpolate_to(Time::from_micros(78), other), Time::from_micros(7));

Trait Implementations

impl Clone for TimeSpan[src]

impl Copy for TimeSpan[src]

impl Data for TimeSpan[src]

impl Debug for TimeSpan[src]

impl<'de> Deserialize<'de> for TimeSpan[src]

impl Eq for TimeSpan[src]

impl Hash for TimeSpan[src]

impl Ord for TimeSpan[src]

impl PartialEq<TimeSpan> for TimeSpan[src]

impl PartialOrd<TimeSpan> for TimeSpan[src]

impl Serialize for TimeSpan[src]

impl StructuralEq for TimeSpan[src]

impl StructuralPartialEq for TimeSpan[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AnyEq for T where
    T: PartialEq<T> + Any

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> RoundFrom<T> for T

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.