Class ColorHelper

java.lang.Object
com.jtattoo.plaf.ColorHelper

public final class ColorHelper extends Object
A helper class for handling color values. Author Michael Hagen
  • Method Details

    • brighter

      public static Color brighter(Color c, double p)
      Creates a color that is the brighter version of the color parameter c.
      Parameters:
      c - the color
      p - the factor of the brightness in percent from 0 to 100
      Returns:
      a new color value that is a brighter version of the color parameter c
    • createColor

      public static Color createColor(int r, int g, int b)
      Creates a color object.
      Parameters:
      r - the Red component
      g - the Green component
      b - the Blue component
      Returns:
      a color object
    • createColorArr

      public static Color[] createColorArr(Color c1, Color c2, int steps)
      Creates an array of color values. The colors created will be a gradient from color c1 to color c1 with a count of steps values.
      Parameters:
      c1 - the starting color
      c2 - the ending color
      steps - the number of steps between c1 and c2 (the size of the created array)
      Returns:
      the array of color values
    • darker

      public static Color darker(Color c, double p)
      Creates a color that is the darker version of the color parameter c.
      Parameters:
      c - the color
      p - the factor to shade the color c in percent from 0 to 100
      Returns:
      a new color value that is a darker version of the color parameter c
    • getGrayValue

      public static int getGrayValue(Color c)
      Returns a value between 0 and 255 which represents the gray value of the color parameter.
      Parameters:
      c - the color you want to calculate the gray value
      Returns:
      the gray value
    • getGrayValue

      public static int getGrayValue(Color[] ca)
      Returns a value between 0 and 255 which represents the median gray value of the color array.
      Parameters:
      ca - the color array you want to calculate the gray value
      Returns:
      the gray value
    • median

      public static Color median(Color c1, Color c2)
      Returns a color value which is the media between the colors c1 and c1
      Parameters:
      c1 - the first color
      c2 - the second color
      Returns:
      the median color value of the two colors c1 and c1
    • toGray

      public static Color toGray(Color c)
      Returns a gray version of the color parameter c, which means all parts (r,g,b) do have the same value.
      Parameters:
      c - the color
      Returns:
      a gray version of the color parameter c.