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-11 11:16:01 +0100
committernextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com>2022-06-11 11:16:01 +0100
commit6239cf215a789a21e702cb793706ca0fa5a4bcca (patch)
tree6cc87eb30fe4606d54481b955dc76e6861299d9d /src/main/java/cc/polyfrost/oneconfig/gui/animations
parent1ab7422957a76158883e0449ed593ac216c9ef80 (diff)
downloadOneConfig-6239cf215a789a21e702cb793706ca0fa5a4bcca.tar.gz
OneConfig-6239cf215a789a21e702cb793706ca0fa5a4bcca.tar.bz2
OneConfig-6239cf215a789a21e702cb793706ca0fa5a4bcca.zip
Slideyboi, a couple fixes, replace print calls and test feature
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/animations')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java19
1 files changed, 15 insertions, 4 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 98b2377..0c62443 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java
@@ -3,6 +3,7 @@ package cc.polyfrost.oneconfig.gui.animations;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
public class ColorAnimation {
+ private int speed = 100;
private ColorPalette palette;
/**
* 0 = nothing
@@ -35,15 +36,25 @@ public class ColorAnimation {
int state = pressed ? 2 : hovered ? 1 : 0;
if (state != prevState) {
float[] newColors = pressed ? palette.getPressedColorf() : hovered ? palette.getHoveredColorf() : palette.getNormalColorf();
- redAnimation = new EaseInOutQuad(100, redAnimation.get(), newColors[0], false);
- greenAnimation = new EaseInOutQuad(100, greenAnimation.get(), newColors[1], false);
- blueAnimation = new EaseInOutQuad(100, blueAnimation.get(), newColors[2], false);
- alphaAnimation = new EaseInOutQuad(100, alphaAnimation.get(), newColors[3], false);
+ redAnimation = new EaseInOutQuad(speed, redAnimation.get(), newColors[0], false);
+ greenAnimation = new EaseInOutQuad(speed, greenAnimation.get(), newColors[1], false);
+ blueAnimation = new EaseInOutQuad(speed, blueAnimation.get(), newColors[2], false);
+ alphaAnimation = new EaseInOutQuad(speed, alphaAnimation.get(), newColors[3], false);
prevState = state;
}
return ((int) (alphaAnimation.get() * 255) << 24) | ((int) (redAnimation.get() * 255) << 16) | ((int) (greenAnimation.get() * 255) << 8) | ((int) (blueAnimation.get() * 255));
}
+ /** Set the speed in milliseconds for the animation. */
+ public void setSpeed(int speed) {
+ this.speed = speed;
+ }
+
+ /** Get the speed in milliseconds for the animation. */
+ public int getSpeed() {
+ return speed;
+ }
+
/**
* 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.
*/