diff options
| author | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-04-21 14:19:44 +0100 |
|---|---|---|
| committer | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-04-21 14:19:44 +0100 |
| commit | 260d48126cbedb4341c5c5865bfd8e605f90955a (patch) | |
| tree | 563f65d65d708f24df33759c411b0f2338c1933e /src/main/java/io/polyfrost/oneconfig/utils | |
| parent | 30df910cf3b2f5b0683ce01e391c35829d8a5850 (diff) | |
| download | OneConfig-260d48126cbedb4341c5c5865bfd8e605f90955a.tar.gz OneConfig-260d48126cbedb4341c5c5865bfd8e605f90955a.tar.bz2 OneConfig-260d48126cbedb4341c5c5865bfd8e605f90955a.zip | |
more gui things like text field and button
Diffstat (limited to 'src/main/java/io/polyfrost/oneconfig/utils')
| -rw-r--r-- | src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java | 25 | ||||
| -rw-r--r-- | src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java | 9 |
2 files changed, 22 insertions, 12 deletions
diff --git a/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java b/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java index f45f9a5..b8d56bd 100644 --- a/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java +++ b/src/main/java/io/polyfrost/oneconfig/utils/ColorUtils.java @@ -15,37 +15,40 @@ public class ColorUtils { default: case 0: return OneConfigConfig.GRAY_400_80; + case 1: + return OneConfigConfig.BLUE_600_80; } } switch (colorPalette) { case -1: - return getColorComponents(color, splitColor(OneConfigConfig.TRANSPARENT), splitColor(OneConfigConfig.GRAY_500), hover); + return getColorComponents(color, splitColor(OneConfigConfig.TRANSPARENT), splitColor(OneConfigConfig.GRAY_500), hover, 10f); default: case 0: - return getColorComponents(color, splitColor(OneConfigConfig.GRAY_500), splitColor(OneConfigConfig.GRAY_400), hover); // OK hopefully this works + return getColorComponents(color, splitColor(OneConfigConfig.GRAY_500), splitColor(OneConfigConfig.GRAY_400), hover, 130f); + case 1: + return getColorComponents(color, splitColor(OneConfigConfig.BLUE_600), splitColor(OneConfigConfig.BLUE_500), hover, 150f); } } private static float[] splitColor(int color) { - Color c = new Color(color, true); - return new float[] {c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, c.getAlpha() / 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) { - currentColor[0] = smooth(currentColor[0], initColor[0], finalColor[0], hover); - currentColor[1] = smooth(currentColor[1], initColor[1], finalColor[1], hover); - currentColor[2] = smooth(currentColor[2], initColor[2], finalColor[2], hover); - currentColor[3] = smooth(currentColor[3], initColor[3], finalColor[3], hover); + 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 new Color(currentColor[0], currentColor[1], currentColor[2], currentColor[3]).getRGB(); } - private static float smooth(float current, float min, float max, boolean moveToFinal) { - current = MathUtils.easeOut(current, moveToFinal ? 1f : 0f); + 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) { current = min; } diff --git a/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java b/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java index 7d64170..547e286 100644 --- a/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java +++ b/src/main/java/io/polyfrost/oneconfig/utils/MathUtils.java @@ -7,7 +7,14 @@ public class MathUtils { public static float easeOut(float current, float goal) { if (Math.floor(Math.abs(goal - current) / (float) 0.01) > 0) { - return current + (goal - current) / (float) 100.0; // this number here controls the speed uh oh + return current + (goal - current) / (float) 100.0; + } else { + return goal; + } + } + public static float easeOut(float current, float goal, float speed) { + if (Math.floor(Math.abs(goal - current) / (float) 0.01) > 0) { + return current + (goal - current) / speed; } else { return goal; } |
