diff options
author | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-05-22 14:57:45 +0100 |
---|---|---|
committer | nextdaydelivery <79922345+nxtdaydelivery@users.noreply.github.com> | 2022-05-22 14:57:45 +0100 |
commit | ffcb16e4c7f0f4414c69541238178ce3a128bb74 (patch) | |
tree | 0806698ae4fecfba85146aa8e24f4cc0067ed4ef /src/main/java/cc/polyfrost/oneconfig/utils | |
parent | 89af4c9fe007e0c4d8ed8edae541b9377e12d8d0 (diff) | |
download | OneConfig-ffcb16e4c7f0f4414c69541238178ce3a128bb74.tar.gz OneConfig-ffcb16e4c7f0f4414c69541238178ce3a128bb74.tar.bz2 OneConfig-ffcb16e4c7f0f4414c69541238178ce3a128bb74.zip |
color selector and loads of stuffs
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/utils')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java | 15 | ||||
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java | 21 |
2 files changed, 30 insertions, 6 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java index 400dc39..ae5753a 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/ColorUtils.java @@ -25,18 +25,18 @@ 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, 50f); case -1: - return getColorComponents(color, splitColor(OneConfigConfig.TRANSPARENT), splitColor(OneConfigConfig.GRAY_500), hover, 10f); + return getColorComponents(color, splitColor(OneConfigConfig.TRANSPARENT), splitColor(OneConfigConfig.GRAY_500), hover, 50f); default: case 0: - return getColorComponents(color, splitColor(OneConfigConfig.GRAY_600), splitColor(OneConfigConfig.GRAY_300), hover, 25f); + return getColorComponents(color, splitColor(OneConfigConfig.GRAY_600), splitColor(OneConfigConfig.GRAY_300), hover, 50f); case 1: return getColorComponents(color, splitColor(OneConfigConfig.PRIMARY_600), splitColor(OneConfigConfig.PRIMARY_500), hover, 150f); case 2: return getColorComponents(color, splitColor(OneConfigConfig.GRAY_500), splitColor(OneConfigConfig.GRAY_300), hover, 50f); case 3: - return getColorComponents(color, splitColor(OneConfigConfig.GRAY_500), splitColor(OneConfigConfig.GRAY_300), hover, 25f); + return getColorComponents(color, splitColor(OneConfigConfig.GRAY_500), splitColor(OneConfigConfig.GRAY_300), hover, 150f); } } @@ -52,7 +52,7 @@ public class ColorUtils { float[] init = splitColor(initColor); float[] finalC = splitColor(finalColor); float[] current = splitColor(currentColor); - return getColorComponents(current, init, finalC, direction, speed); + return getColorComponents(current, init, finalC, direction, speed + 100f); } private static float[] splitColor(int color) { @@ -65,7 +65,10 @@ public class ColorUtils { 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(); + return ((int) (currentColor[3] * 255) << 24) | + ((int) (currentColor[0] * 255) << 16) | + ((int) (currentColor[1] * 255) << 8) | + ((int) (currentColor[2] * 255)); } diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java b/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java index 7263a19..73a8a13 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/IOUtils.java @@ -1,9 +1,11 @@ package cc.polyfrost.oneconfig.utils; +import java.awt.*; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; +import java.net.URI; import java.net.URL; import java.nio.Buffer; import java.nio.ByteBuffer; @@ -52,4 +54,23 @@ public final class IOUtils { } } + public static void browseLink(String uri) { + try { + browseLink(new URI(uri)); + } catch (Exception e) { + e.printStackTrace(); + System.err.println("Invalid URI: " + uri); + } + } + public static void browseLink(URI uri) { + if(Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) { + try { + Desktop.getDesktop().browse(uri); + } catch (IOException e) { + e.printStackTrace(); + System.err.println("Failed to open URL in browser: " + uri); + } + } + } + }
\ No newline at end of file |