All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.teamwizardry.librarianlib.math.Animation.kt Maven / Gradle / Ivy

There is a newer version: 5.0.0-alpha.10
Show newest version
package com.teamwizardry.librarianlib.math

/**
 * The base interface for animations.
 */
public interface Animation {
    /**
     * The end time of the animation. May be [Float.POSITIVE_INFINITY] for animations that loop indefinitely or use some
     * other function that never ends.
     */
    public val end: Float

    /**
     * Get the value of the animation at the specified time. The time should be expressed in ticks, with the animation
     * starting at 0.
     */
    public fun animate(time: Float): T

    /**
     * Can be called when the animation is started.
     *
     * While calling this method is recommended, as it can facilitate richer animation functionality, it is not strictly
     * required, so animation implementations should not rely on this method being called.
     */
    public fun onStarted()

    /**
     * Can be called when the animation is completed or interrupted, returning the final value of the animation. This is
     * used to ensure animations land _precisely_ at their final value, as opposed to a frame or two before the final
     * value. The passed time will likely be after [end], and may be considerably so.
     *
     * While calling this method is recommended, as it facilitates richer animation functionality, it is not strictly
     * required, so animation implementations should not rely on this method being called.
     */
    public fun onStopped(time: Float): T
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy