aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/gui/animations
diff options
context:
space:
mode:
authornextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-06-05 10:36:43 +0100
committernextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-06-05 10:36:43 +0100
commit087f5404658a1543834f16a89e3436f8399297f6 (patch)
tree4b6d18abbc2e6f3083e664786dbbef98bb142a33 /src/main/java/cc/polyfrost/oneconfig/gui/animations
parent3e472ea407d128de61820fc167e08b8fe24186c9 (diff)
downloadOneConfig-087f5404658a1543834f16a89e3436f8399297f6.tar.gz
OneConfig-087f5404658a1543834f16a89e3436f8399297f6.tar.bz2
OneConfig-087f5404658a1543834f16a89e3436f8399297f6.zip
Reformat code and OC-38
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/animations')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java15
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java2
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java5
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java5
4 files changed, 21 insertions, 6 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java b/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java
index a9ef863..98b2377 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java
@@ -1,7 +1,6 @@
package cc.polyfrost.oneconfig.gui.animations;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
-import cc.polyfrost.oneconfig.utils.color.ColorUtils;
public class ColorAnimation {
private ColorPalette palette;
@@ -25,6 +24,13 @@ public class ColorAnimation {
alphaAnimation = new DummyAnimation(palette.getNormalColorf()[3]);
}
+ /**
+ * Return the current color at the current time, according to a EaseInOut quadratic animation.
+ *
+ * @param hovered the hover state of the element
+ * @param pressed the pressed state of the element
+ * @return the current color
+ */
public int getColor(boolean hovered, boolean pressed) {
int state = pressed ? 2 : hovered ? 1 : 0;
if (state != prevState) {
@@ -38,6 +44,13 @@ public class ColorAnimation {
return ((int) (alphaAnimation.get() * 255) << 24) | ((int) (redAnimation.get() * 255) << 16) | ((int) (greenAnimation.get() * 255) << 8) | ((int) (blueAnimation.get() * 255));
}
+ /**
+ * Return the current alpha of the color. This method is used to get the alpha of pressed buttons that have text/icons on them, so they also darken accordingly.
+ */
+ public float getAlpha() {
+ return alphaAnimation.get(0);
+ }
+
public ColorPalette getPalette() {
return palette;
}
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 bc97aca..dc5bc26 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/DummyAnimation.java
@@ -1,6 +1,6 @@
package cc.polyfrost.oneconfig.gui.animations;
-public class DummyAnimation extends Animation{
+public class DummyAnimation extends Animation {
/**
* @param value The value that is returned
*/
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 9af6557..7b4ba7f 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuad.java
@@ -1,6 +1,6 @@
package cc.polyfrost.oneconfig.gui.animations;
-public class EaseInOutQuad extends Animation{
+public class EaseInOutQuad extends Animation {
/**
* @param duration The duration of the animation
@@ -17,7 +17,8 @@ public class EaseInOutQuad extends Animation{
*/
@Override
protected float animate(float timePassed, float duration, float start, float change) {
- if ((timePassed /= duration / 2) < 1) return change / 2 * timePassed * timePassed + start;;
+ if ((timePassed /= duration / 2) < 1) return change / 2 * timePassed * timePassed + start;
+ ;
return -change / 2 * ((--timePassed) * (timePassed - 2) - 1) + start;
}
}
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 a21aa73..9c3abe9 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/EaseInOutQuart.java
@@ -1,6 +1,6 @@
package cc.polyfrost.oneconfig.gui.animations;
-public class EaseInOutQuart extends Animation{
+public class EaseInOutQuart extends Animation {
/**
* @param duration The duration of the animation
@@ -17,7 +17,8 @@ public class EaseInOutQuart extends Animation{
*/
@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;
+ if ((timePassed /= duration / 2) < 1)
+ return change / 2 * timePassed * timePassed * timePassed * timePassed + start;
return -change / 2 * ((timePassed -= 2) * timePassed * timePassed * timePassed - 2) + start;
}
}