From 140ffd89293cdad8963d1fc80db382dc5681229f Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Sat, 4 Jun 2022 16:57:41 +0200 Subject: animation --- .../oneconfig/gui/animations/EaseInOutCubic.java | 23 ++++++++++++++++++++++ .../gui/animations/EaseInQuartReversed.java | 21 -------------------- 2 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutCubic.java delete mode 100644 src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInQuartReversed.java (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/animations') diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutCubic.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutCubic.java new file mode 100644 index 0000000..760f369 --- /dev/null +++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutCubic.java @@ -0,0 +1,23 @@ +package cc.polyfrost.oneconfig.gui.animations; + +public class EaseInOutCubic 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 EaseInOutCubic(int duration, float start, float end, boolean reverse) { + super(duration, start, end, reverse); + } + + /** + * Adapted from https://github.com/jesusgollonet/processing-penner-easing + */ + @Override + protected float animate(float timePassed, float duration, float start, float change) { + if ((timePassed /= duration / 2) < 1) return change / 2 * timePassed * timePassed * timePassed + start; + return change / 2 * ((timePassed -= 2) * timePassed * timePassed + 2) + start; + } +} diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInQuartReversed.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInQuartReversed.java deleted file mode 100644 index 10bf354..0000000 --- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInQuartReversed.java +++ /dev/null @@ -1,21 +0,0 @@ -package cc.polyfrost.oneconfig.gui.animations; - -public class EaseInQuartReversed 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 EaseInQuartReversed(float duration, float start, float end, boolean reverse) { - super(duration, start, end, reverse); - } - - @Override - protected float animate(float timePassed, float duration, float start, float change) { - float x = timePassed / duration; - if (x < 0.25f) return (float) (128 * Math.pow(x, 4) * change + start); - if (x < 0.75f) return (float) ((-128 * Math.pow(x - 0.5, 4) + 1) * change + start); - return (float) (128 * Math.pow(x - 1, 4) * change + start); - } -} -- cgit