pub struct PathTrack<T: Copy + LerpAnim> {
pub start_time: f64,
pub duration: f32,
pub easing: OverlayEasing,
pub repeat: RepeatMode,
pub path: Arc<dyn Fn(f32) -> T + Send + Sync>,
}Expand description
Arbitrary-path animation track. path is a closure called with the eased
parameter t in [0, 1] and returns the value for the channel.
Use for any motion that’s more than a straight line: Bezier arcs,
polylines, lissajous, custom shapes. The bezier and polyline helpers
cover the common cases without the consumer writing the curve math.
The closure is stored in an Arc, so cloning the track is cheap (one
atomic bump). The Send + Sync + 'static bound is satisfied by closures
that capture only owned/by-value data.
Fields§
§start_time: f64Absolute time at which the track starts.
duration: f32Length of one cycle in seconds.
easing: OverlayEasingCurve applied to the normalised parameter before the closure runs.
repeat: RepeatModeWhat happens past the end of one cycle.
path: Arc<dyn Fn(f32) -> T + Send + Sync>Evaluator for the path. Called with t in [0, 1] after easing and
repeat resolution. The closure is shared via Arc so the track is
cheap to clone.
Implementations§
Source§impl<T: Copy + LerpAnim> PathTrack<T>
impl<T: Copy + LerpAnim> PathTrack<T>
Sourcepub fn new(
start_time: f64,
duration: f32,
path: impl Fn(f32) -> T + Send + Sync + 'static,
) -> Self
pub fn new( start_time: f64, duration: f32, path: impl Fn(f32) -> T + Send + Sync + 'static, ) -> Self
Construct a track that evaluates the supplied closure at each frame.
Defaults to Linear easing and Once repeat; chain with_easing
or with_repeat to override.
Sourcepub fn with_easing(self, easing: OverlayEasing) -> Self
pub fn with_easing(self, easing: OverlayEasing) -> Self
Builder-style easing setter.
Sourcepub fn with_repeat(self, repeat: RepeatMode) -> Self
pub fn with_repeat(self, repeat: RepeatMode) -> Self
Builder-style repeat-mode setter.
Source§impl PathTrack<[f32; 2]>
impl PathTrack<[f32; 2]>
Sourcepub fn bezier(
start_time: f64,
duration: f32,
control_points: [[f32; 2]; 4],
) -> Self
pub fn bezier( start_time: f64, duration: f32, control_points: [[f32; 2]; 4], ) -> Self
Construct a 2D track that walks a single cubic Bezier from p0 to
p3 with control handles p1 and p2. Evaluates the standard
Bernstein form at the eased parameter.
Sourcepub fn polyline(start_time: f64, duration: f32, points: Vec<[f32; 2]>) -> Self
pub fn polyline(start_time: f64, duration: f32, points: Vec<[f32; 2]>) -> Self
Construct a 2D track that walks a polyline at uniform per-segment
parameter. With N points the path spans N - 1 equal-length
parameter segments; consumers wanting arc-length-uniform motion
should subdivide their polyline ahead of time.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for PathTrack<T>
impl<T> !UnwindSafe for PathTrack<T>
impl<T> Freeze for PathTrack<T>
impl<T> Send for PathTrack<T>
impl<T> Sync for PathTrack<T>
impl<T> Unpin for PathTrack<T>
impl<T> UnsafeUnpin for PathTrack<T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.