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§

source

type Value: PartialEq + 'static

Value type for this curve.

source

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§

source

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.

source

fn field_accessor(&self) -> &Self::FieldAccessor

Get a field accessor for the targeted field.

Provided Methods§

source

fn read_field<'a>( &self, target: &'a Self::Component ) -> Result<&'a Self::Value, String>

Read the current value from the target field.

source

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.

Implementors§

source§

impl<S, F, C> TypedCurve for KeyframeCurve<S, F, C>
where S: 'static, C: CurveContent<Keyframe = F::View>, F::View: PartialEq + Animatable + Sized + Send + Sync + 'static, F: Send + Sync + 'static + for<'a> AffineFoldRef<'a, S, Error = String> + for<'a> AffineFoldMut<'a, S, Error = String>,

§

type Value = <F as Optics<S>>::View

§

type FieldAccessor = F