Trait libre_pvz_animation::curve::TypedCurve
source · pub trait TypedCurve: Curve {
type Value: PartialEq + 'static;
type FieldAccessor: for<'a> AffineFoldRef<'a, Self::Component, View = Self::Value, Error = String> + for<'a> AffineFoldMut<'a, Self::Component, View = Self::Value, Error = String>;
// Required methods
fn sample(&self, segment: Segment, frame: f32) -> Option<Self::Value>;
fn field_accessor(&self) -> &Self::FieldAccessor;
// Provided methods
fn read_field<'a>(
&self,
target: &'a Self::Component
) -> Result<&'a Self::Value, String> { ... }
fn update_field(
&self,
target: impl AnyComponent<Self::Component>,
value: Self::Value
) -> Result<(), String> { ... }
}
Expand description
Animation curve with known single variable type.
Required Associated Types§
sourcetype FieldAccessor: for<'a> AffineFoldRef<'a, Self::Component, View = Self::Value, Error = String> + for<'a> AffineFoldMut<'a, Self::Component, View = Self::Value, Error = String>
type FieldAccessor: for<'a> AffineFoldRef<'a, Self::Component, View = Self::Value, Error = String> + for<'a> AffineFoldMut<'a, Self::Component, View = Self::Value, Error = String>
Field accessor.
Required Methods§
sourcefn sample(&self, segment: Segment, frame: f32) -> Option<Self::Value>
fn sample(&self, segment: Segment, frame: f32) -> Option<Self::Value>
Sample the curve at specific frame index.
To support looping, we require sample
be well-defined for any positive frame number. The
curve should behave as if the first frame immediately follows the last frame. However, it
is okay for this sampling function to assume start + frame <= end + 1
will always hold.
sourcefn field_accessor(&self) -> &Self::FieldAccessor
fn field_accessor(&self) -> &Self::FieldAccessor
Get a field accessor for the targeted field.
Provided Methods§
sourcefn read_field<'a>(
&self,
target: &'a Self::Component
) -> Result<&'a Self::Value, String>
fn read_field<'a>( &self, target: &'a Self::Component ) -> Result<&'a Self::Value, String>
Read the current value from the target field.
sourcefn update_field(
&self,
target: impl AnyComponent<Self::Component>,
value: Self::Value
) -> Result<(), String>
fn update_field( &self, target: impl AnyComponent<Self::Component>, value: Self::Value ) -> Result<(), String>
Update the field in the component with a new value.
Object Safety§
This trait is not object safe.