aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/cc/polyfrost/oneconfig/utils
diff options
context:
space:
mode:
authorDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-04 13:36:46 +0200
committerDeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com>2022-06-04 13:36:46 +0200
commita4d135ebb02c6fea87c8f9275a8a07338999d84b (patch)
treea8bafe2e44307255e9c9eef14a9baf6d26e37c73 /src/main/java/cc/polyfrost/oneconfig/utils
parent07741d92fa6ea636b8292bb35706c25e5e6a72cc (diff)
downloadOneConfig-a4d135ebb02c6fea87c8f9275a8a07338999d84b.tar.gz
OneConfig-a4d135ebb02c6fea87c8f9275a8a07338999d84b.tar.bz2
OneConfig-a4d135ebb02c6fea87c8f9275a8a07338999d84b.zip
OC-66 done
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/utils')
-rw-r--r--src/main/java/cc/polyfrost/oneconfig/utils/color/ColorUtils.java55
1 files changed, 0 insertions, 55 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorUtils.java
index a419766..ebf0100 100644
--- a/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorUtils.java
+++ b/src/main/java/cc/polyfrost/oneconfig/utils/color/ColorUtils.java
@@ -1,64 +1,9 @@
package cc.polyfrost.oneconfig.utils.color;
-import cc.polyfrost.oneconfig.utils.MathUtils;
-
/**
* A class to help with color manipulation.
*/
public final class ColorUtils {
-
- public static int getColor(int currentColor, ColorPalette colorPalette, boolean hover, boolean click) {
- float[] color = splitColor(currentColor);
- if (click) {
- return colorPalette.getPressedColor();
- }
-
- return getColorComponents(color, colorPalette.getNormalColorf(), colorPalette.getHoveredColorf(), hover, 20f);
- }
-
- /**
- * Smooths the transition of a color between two colors.
- *
- * @param currentColor the current color (also the one you want to change)
- * @param direction false to move towards initColor, true to move towards finalColor
- * @param speed speed of the transition
- */
- public static int smoothColor(int currentColor, int initColor, int finalColor, boolean direction, float speed) {
- float[] init = splitColor(initColor);
- float[] finalC = splitColor(finalColor);
- float[] current = splitColor(currentColor);
- return getColorComponents(current, init, finalC, direction, speed);
- }
-
- private static float[] splitColor(int color) {
- return new float[]{getRed(color) / 255f, getGreen(color) / 255f, getBlue(color) / 255f, getAlpha(color) / 255f};
- }
-
- private static int getColorComponents(float[] currentColor, float[] initColor, float[] finalColor, boolean hover, float speed) {
- currentColor[0] = smooth(currentColor[0], initColor[0], finalColor[0], hover, speed);
- currentColor[1] = smooth(currentColor[1], initColor[1], finalColor[1], hover, speed);
- currentColor[2] = smooth(currentColor[2], initColor[2], finalColor[2], hover, speed);
- currentColor[3] = smooth(currentColor[3], initColor[3], finalColor[3], hover, speed);
-
- return ((int) (currentColor[3] * 255) << 24) |
- ((int) (currentColor[0] * 255) << 16) |
- ((int) (currentColor[1] * 255) << 8) |
- ((int) (currentColor[2] * 255));
-
- }
-
- private static float smooth(float current, float min, float max, boolean moveToFinal, float speed) {
- current = MathUtils.easeOut(current, moveToFinal ? max : min, speed);
- if (current < min) {
- current = min;
- }
-
- if (current > max) {
- current = max;
- }
- return current;
- }
-
/**
* Get the red component of an RGB color.
*