Class ColorUtils

java.lang.Object
ActiverseUtils.ColorUtils

public class ColorUtils extends Object
ColorUtils - Utility functions for color manipulation
Version:
1.4.1
Author:
Knivier
  • Constructor Details

    • ColorUtils

      public ColorUtils()
  • Method Details

    • darken

      public static Color darken(Color color, double percent)
      Darkens a color by a percentage
      Parameters:
      color - The color to darken
      percent - Percentage to darken (0.0 to 1.0)
      Returns:
      Darkened color
    • lighten

      public static Color lighten(Color color, double percent)
      Lightens a color by a percentage
      Parameters:
      color - The color to lighten
      percent - Percentage to lighten (0.0 to 1.0)
      Returns:
      Lightened color
    • blend

      public static Color blend(Color color1, Color color2, double ratio)
      Blends two colors
      Parameters:
      color1 - First color
      color2 - Second color
      ratio - Blend ratio (0.0 = all color1, 1.0 = all color2)
      Returns:
      Blended color
    • withAlpha

      public static Color withAlpha(Color color, int alpha)
      Sets the alpha (transparency) of a color
      Parameters:
      color - The color
      alpha - Alpha value (0-255)
      Returns:
      Color with new alpha
    • rgbToHsv

      public static float[] rgbToHsv(Color color)
      Converts RGB to HSV
      Parameters:
      color - RGB color
      Returns:
      float array [hue (0-360), saturation (0-1), value (0-1)]
    • hsvToRgb

      public static Color hsvToRgb(float hue, float saturation, float value)
      Creates a color from HSV values
      Parameters:
      hue - Hue (0-360 degrees)
      saturation - Saturation (0.0-1.0)
      value - Value/brightness (0.0-1.0)
      Returns:
      RGB color