Class ColorUtils


  • public class ColorUtils
    extends java.lang.Object
    A helper class with utility methods for color related operations.
    • Constructor Summary

      Constructors 
      Constructor Description
      ColorUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static com.jme3.math.ColorRGBA fromHex​(java.lang.String hex)  
      static com.jme3.math.ColorRGBA fromHex​(java.lang.String hex, boolean linearSpace)
      Returns a ColorRGBA object from the passed hex string.
      static com.jme3.math.ColorRGBA fromRGBA​(int red, int green, int blue, int alpha)
      Returns a ColorRGBA object from the passed red, green, blue, alpha values.
      static com.jme3.math.ColorRGBA fromRGBA​(int red, int green, int blue, int alpha, boolean linearSpace)
      Returns a ColorRGBA object from the passed red, green, blue, alpha values.
      static java.lang.String toHex​(com.jme3.math.ColorRGBA color)
      Returns the hexadecimal representation of the supplied color object
      static java.lang.String toHex​(com.jme3.math.ColorRGBA color, boolean includeAlphaChannel)
      Returns the hexadecimal representation of the supplied color
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ColorUtils

        public ColorUtils()
    • Method Detail

      • fromHex

        public static com.jme3.math.ColorRGBA fromHex​(java.lang.String hex)
      • toHex

        public static java.lang.String toHex​(com.jme3.math.ColorRGBA color)
        Returns the hexadecimal representation of the supplied color object
        Parameters:
        color - the color
        Returns:
        hexadecimal string representation of the color
      • toHex

        public static java.lang.String toHex​(com.jme3.math.ColorRGBA color,
                                             boolean includeAlphaChannel)
        Returns the hexadecimal representation of the supplied color
        Parameters:
        color - the color
        includeAlphaChannel - whether or not the alpha channel should be returned
        Returns:
        hexadecimal string
      • fromHex

        public static com.jme3.math.ColorRGBA fromHex​(java.lang.String hex,
                                                      boolean linearSpace)
        Returns a ColorRGBA object from the passed hex string. When the color is not in linear space, the values will be gamma corrected to be stored in linear space. GAMMA value is 2.2 When the color is picked from a color picker or GUI, the linearSpace boolean should probably be set to false.
        Parameters:
        hex - the hex string
        linearSpace - if the color is in linear space
        Returns:
        the color derived from the hex, or null when the parsing did not succeed
      • fromRGBA

        public static com.jme3.math.ColorRGBA fromRGBA​(int red,
                                                       int green,
                                                       int blue,
                                                       int alpha)
        Returns a ColorRGBA object from the passed red, green, blue, alpha values.
        Parameters:
        red - red value
        green - green value
        blue - blue value
        alpha - alpha value
        Returns:
        the color from the given input or null
      • fromRGBA

        public static com.jme3.math.ColorRGBA fromRGBA​(int red,
                                                       int green,
                                                       int blue,
                                                       int alpha,
                                                       boolean linearSpace)
        Returns a ColorRGBA object from the passed red, green, blue, alpha values. When the color is not in linear space, the values will be gamma corrected to be stored in linear space. GAMMA value is 2.2 When the color is picked from a color picker or GUI, the linearSpace boolean should probably be set to false.
        Parameters:
        red - red value
        green - green value
        blue - blue value
        alpha - alpha value
        linearSpace - is the color in linear space
        Returns:
        the color from the given input or null