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-12 20:30:06 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-12 20:30:06 +0200
commitbcdb9ed93960b972d137de17ef0253d3e83deb38 (patch)
tree012bb702dcd0faf967e71c0caf1f7793949f03eb /src/main/java/cc/polyfrost/oneconfig/gui/animations
parent2f9d500c97291cdaa09b0f3afc96551e675280fe (diff)
downloadOneConfig-bcdb9ed93960b972d137de17ef0253d3e83deb38.tar.gz
OneConfig-bcdb9ed93960b972d137de17ef0253d3e83deb38.tar.bz2
OneConfig-bcdb9ed93960b972d137de17ef0253d3e83deb38.zip
some small fixes
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui/animations')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java27
1 files changed, 11 insertions, 16 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 0c62443..8734c2c 100644
--- a/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java
+++ b/src/main/java/cc/polyfrost/oneconfig/gui/animations/ColorAnimation.java
@@ -3,8 +3,8 @@ package cc.polyfrost.oneconfig.gui.animations;
import cc.polyfrost.oneconfig.utils.color.ColorPalette;
public class ColorAnimation {
- private int speed = 100;
private ColorPalette palette;
+ private final int duration;
/**
* 0 = nothing
* 1 = hovered
@@ -17,14 +17,19 @@ public class ColorAnimation {
private Animation blueAnimation;
private Animation alphaAnimation;
- public ColorAnimation(ColorPalette palette) {
+ public ColorAnimation(ColorPalette palette, int duration) {
this.palette = palette;
+ this.duration = duration;
redAnimation = new DummyAnimation(palette.getNormalColorf()[0]);
greenAnimation = new DummyAnimation(palette.getNormalColorf()[1]);
blueAnimation = new DummyAnimation(palette.getNormalColorf()[2]);
alphaAnimation = new DummyAnimation(palette.getNormalColorf()[3]);
}
+ public ColorAnimation(ColorPalette palette) {
+ this(palette, 100);
+ }
+
/**
* Return the current color at the current time, according to a EaseInOut quadratic animation.
*
@@ -36,25 +41,15 @@ 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(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);
+ redAnimation = new EaseInOutQuad(duration, redAnimation.get(), newColors[0], false);
+ greenAnimation = new EaseInOutQuad(duration, greenAnimation.get(), newColors[1], false);
+ blueAnimation = new EaseInOutQuad(duration, blueAnimation.get(), newColors[2], false);
+ alphaAnimation = new EaseInOutQuad(duration, 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.
*/