aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java
blob: 55c1cad805ed88bced386035a781eaaa89aaf1b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package cc.polyfrost.oneconfig.gui.animations;

public class EaseInOutQuart extends Animation{

    /**
     * @param duration The duration of the animation
     * @param start    The start of the animation
     * @param end      The end of the animation
     * @param reverse  Reverse the animation
     */
    public EaseInOutQuart(int duration, float start, float end, boolean reverse) {
        super(duration, start, end, reverse);
    }

    /**
     * Adapted from <a href="https://github.com/jesusgollonet/processing-penner-easing">https://github.com/jesusgollonet/processing-penner-easing</a>
     */
    @Override
    protected float animate(long timePassed, int duration, float start, float change) {
        if ((timePassed /= duration / 2) < 1) return change / 2 * timePassed * timePassed * timePassed * timePassed + start;
        return -change / 2 * ((timePassed -= 2) * timePassed * timePassed * timePassed - 2) + start;
    }
}