diff options
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java new file mode 100644 index 0000000..14e802f --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java @@ -0,0 +1,23 @@ +package cc.polyfrost.oneconfig.gui.animations; + +public class EaseInOutQuad 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 EaseInOutQuad(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 + start;; + return -change / 2 * ((--timePassed) * (timePassed - 2) - 1) + start; + } +} |