aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui/animations
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-18 10:13:39 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-18 10:13:39 +0200
commita929901f2dfb135cbb72036b5e49b4fdb38fe24a (patch)
tree6edf7913fd2375dd98e07fe053c9a21d6a4b8322 /src/main/java/cc/polyfrost/oneconfig/gui/animations
parentd01767620ee480308dfc03185e6a12d7d1e494f3 (diff)
downloadOneConfig-a929901f2dfb135cbb72036b5e49b4fdb38fe24a.tar.gz
OneConfig-a929901f2dfb135cbb72036b5e49b4fdb38fe24a.tar.bz2
OneConfig-a929901f2dfb135cbb72036b5e49b4fdb38fe24a.zip
some stuff
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/animations')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java6
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java12
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutCubic.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java8
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java9
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseOutQuad.java4
6 files changed, 21 insertions, 26 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java
index a5cfae0..30fcc4e 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/Animation.java
@@ -3,7 +3,7 @@ package cc.polyfrost.oneconfig.gui.animations;
import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
public abstract class Animation {
- protected final boolean reverse;
+ private final boolean reverse;
private final float duration;
private final float start;
private final float change;
@@ -34,7 +34,7 @@ public abstract class Animation {
public float get(float deltaTime) {
timePassed += deltaTime;
if (timePassed >= duration) timePassed = duration;
- return animate(timePassed, duration, start, change);
+ return animate(timePassed / duration) * change + start;
}
/**
@@ -58,5 +58,5 @@ public abstract class Animation {
return reverse;
}
- protected abstract float animate(float timePassed, float duration, float start, float change);
+ protected abstract float animate(float x);
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java
index dc5bc26..7363ed6 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java
@@ -1,15 +1,23 @@
package cc.polyfrost.oneconfig.gui.animations;
public class DummyAnimation extends Animation {
+ protected final float value;
+
/**
* @param value The value that is returned
*/
public DummyAnimation(float value) {
super(value, value, value, false);
+ this.value = value;
+ }
+
+ @Override
+ public float get(float deltaTime) {
+ return value;
}
@Override
- protected float animate(float timePassed, float duration, float start, float change) {
- return start;
+ protected float animate(float x) {
+ return x;
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutCubic.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutCubic.java
index 760f369..1de3346 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutCubic.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutCubic.java
@@ -12,12 +12,8 @@ public class EaseInOutCubic extends Animation {
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(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;
+ protected float animate(float x) {
+ return x < 0.5 ? 4 * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 3) / 2);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java
index f43c75d..3855eac 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java
@@ -12,12 +12,8 @@ public class EaseInOutQuad extends Animation {
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(float timePassed, float duration, float start, float change) {
- if ((timePassed /= duration / 2) < 1) return change / 2 * timePassed * timePassed + start;
- return -change / 2 * ((--timePassed) * (timePassed - 2) - 1) + start;
+ protected float animate(float x) {
+ return x < 0.5 ? 2 * x * x : (float) (1 - Math.pow(-2 * x + 2, 2) / 2);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java
index 9c3abe9..c397d4b 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java
@@ -12,13 +12,8 @@ public class EaseInOutQuart extends Animation {
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(float timePassed, float 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;
+ protected float animate(float x) {
+ return x < 0.5 ? 8 * x * x * x * x : (float) (1 - Math.pow(-2 * x + 2, 4) / 2);
}
}
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseOutQuad.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseOutQuad.java
index 6cc97bf..8c7bff2 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseOutQuad.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseOutQuad.java
@@ -16,7 +16,7 @@ public class EaseOutQuad extends Animation {
* Adapted from <a href="https://github.com/jesusgollonet/processing-penner-easing">https://github.com/jesusgollonet/processing-penner-easing</a>
*/
@Override
- protected float animate(float timePassed, float duration, float start, float change) {
- return -change * (timePassed /= duration) * (timePassed - 2) + start;
+ protected float animate(float x) {
+ return 1 - (1 - x) * (1 - x);
}
}