From 89d6576a7777a2949e04b2c6c8d2eb015a733529 Mon Sep 17 00:00:00 2001 From: nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> Date: Mon, 25 Apr 2022 13:12:22 +0100 Subject: add size, do some config element stuff, fixes for cards, finish mods page and performance page, cleanup and some more --- .../java/io/polyfrost/oneconfig/utils/ColorUtils.java | 17 +++++++++-------- .../java/io/polyfrost/oneconfig/utils/InputUtils.java | 1 + .../java/io/polyfrost/oneconfig/utils/MathUtils.java | 4 +++- 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'src/main/java/io/polyfrost/oneconfig/utils') diff --git a/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java b/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java index dd9a78e..abc36a5 100644 --- a/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java +++ b/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java @@ -10,10 +10,10 @@ public class ColorUtils { public static int getColor(int currentColor, int colorPalette, boolean hover, boolean click) { float[] color = splitColor(currentColor); - if(click) { + if (click) { switch (colorPalette) { case -2: - return new Color(0.9f,0.9f,0.9f,0.2f).getRGB(); + return new Color(0.9f, 0.9f, 0.9f, 0.2f).getRGB(); case -1: return OneConfigConfig.GRAY_500_80; default: @@ -26,7 +26,7 @@ public class ColorUtils { switch (colorPalette) { case -2: - return getColorComponents(color, splitColor(OneConfigConfig.TRANSPARENT), new float[]{0.9f,0.9f,0.9f,0.3f}, hover, 20f); + return getColorComponents(color, splitColor(OneConfigConfig.TRANSPARENT), new float[]{0.9f, 0.9f, 0.9f, 0.3f}, hover, 20f); case -1: return getColorComponents(color, splitColor(OneConfigConfig.TRANSPARENT), splitColor(OneConfigConfig.GRAY_500), hover, 10f); default: @@ -41,9 +41,10 @@ public class ColorUtils { /** * 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 + * @param direction false to move towards initColor, true to move towards finalColor + * @param speed speed of the transition * @return currentColor but with the new color */ public static int smoothColor(int currentColor, int initColor, int finalColor, boolean direction, float speed) { @@ -55,7 +56,7 @@ public class ColorUtils { @Contract(value = "_ -> new", pure = true) private static float @NotNull [] splitColor(int color) { - return new float[] { (color >> 16 & 255) / 255f, (color >> 8 & 255) / 255f, (color & 255) / 255f, (color >> 24 & 255) /255f }; + return new float[]{(color >> 16 & 255) / 255f, (color >> 8 & 255) / 255f, (color & 255) / 255f, (color >> 24 & 255) / 255f}; } private static int getColorComponents(float[] currentColor, float[] initColor, float[] finalColor, boolean hover, float speed) { @@ -70,11 +71,11 @@ public class ColorUtils { private static float smooth(float current, float min, float max, boolean moveToFinal, float speed) { current = MathUtils.easeOut(current, moveToFinal ? 1f : 0f, speed); - if(current <= min) { + if (current <= min) { current = min; } - if(current >= max) { + if (current >= max) { current = max; } return current; diff --git a/src/main/java/io/polyfrost/oneconfig/utils/InputUtils.java b/src/main/java/io/polyfrost/oneconfig/utils/InputUtils.java index d5ad44b..1ce1a30 100644 --- a/src/main/java/io/polyfrost/oneconfig/utils/InputUtils.java +++ b/src/main/java/io/polyfrost/oneconfig/utils/InputUtils.java @@ -6,6 +6,7 @@ import org.lwjgl.input.Mouse; public class InputUtils { /** * function to determine weather the mouse is currently over a specific region. Uses the current nvgScale to fix to any scale. + * * @return true if mouse is over region, false if not. */ public static boolean isAreaHovered(int x, int y, int width, int height) { diff --git a/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java b/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java index dc70eea..1e4857f 100644 --- a/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java +++ b/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java @@ -18,7 +18,9 @@ public class MathUtils { return current * current; } - /** taken from https://github.com/jesusgollonet/processing-penner-easing */ + /** + * taken from https://github.com/jesusgollonet/processing-penner-easing + */ public static float easeInOutCirc(float t, float b, float c, float d) { if ((t /= d / 2) < 1) return -c / 2 * ((float) Math.sqrt(1 - t * t) - 1) + b; return c / 2 * ((float) Math.sqrt(1 - (t -= 2) * t) + 1) + b; -- cgit