Class Colors


  • public class Colors
    extends java.lang.Object
    Utilities to manipulate and convert colors.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Colors.Conversion
      Type of color conversion to use when converting to/from sRGB and linear spaces.
      static interface  Colors.LinearColor  
      static class  Colors.RgbaType
      Types of RGBA colors.
      static class  Colors.RgbType
      Types of RGB colors.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static float[] cct​(float temperature)
      Converts a correlated color temperature to a linear RGB color in sRGB space.
      static float[] illuminantD​(float temperature)
      Converts a CIE standard illuminant series D to a linear RGB color in sRGB space.
      static float[] toLinear​(Colors.Conversion conversion, float[] rgb)
      Converts an RGB color in sRGB space to an RGB color in linear space.
      static float[] toLinear​(Colors.RgbaType type, float[] rgba)
      Converts an RGBA color to linear space, with pre-multiplied alpha.
      static float[] toLinear​(Colors.RgbaType type, float r, float g, float b, float a)
      Converts an RGBA color to linear space, with pre-multiplied alpha.
      static float[] toLinear​(Colors.RgbType type, float[] rgb)
      Converts an RGB color to linear space, the conversion depends on the specified type.
      static float[] toLinear​(Colors.RgbType type, float r, float g, float b)
      Converts an RGB color to linear space, the conversion depends on the specified type.
      • Methods inherited from class java.lang.Object

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

      • toLinear

        @NonNull
        @Size(3L)
        public static float[] toLinear​(@NonNull
                                       Colors.RgbType type,
                                       float r,
                                       float g,
                                       float b)
        Converts an RGB color to linear space, the conversion depends on the specified type.
        Parameters:
        type - the color space of the RGB color values provided
        r - the red component
        g - the green component
        b - the blue component
        Returns:
        an RGB float array of size 3 with the result of the conversion
      • toLinear

        @NonNull
        @Size(min=3L)
        public static float[] toLinear​(@NonNull
                                       Colors.RgbType type,
                                       @NonNull @Size(min=3L)
                                       float[] rgb)
        Converts an RGB color to linear space, the conversion depends on the specified type.
        Parameters:
        type - the color space of the RGB color values provided
        rgb - an RGB float array of size 3, will be modified
        Returns:
        the passed-in rgb array, after applying the conversion
      • toLinear

        @NonNull
        @Size(4L)
        public static float[] toLinear​(@NonNull
                                       Colors.RgbaType type,
                                       float r,
                                       float g,
                                       float b,
                                       float a)
        Converts an RGBA color to linear space, with pre-multiplied alpha.
        Parameters:
        type - the color space and type of RGBA color values provided
        r - the red component
        g - the green component
        b - the blue component
        a - the alpha component
        Returns:
        an RGBA float array of size 4 with the result of the conversion
      • toLinear

        @NonNull
        @Size(min=4L)
        public static float[] toLinear​(@NonNull
                                       Colors.RgbaType type,
                                       @NonNull @Size(min=4L)
                                       float[] rgba)
        Converts an RGBA color to linear space, with pre-multiplied alpha.
        Parameters:
        type - the color space of the RGBA color values provided
        rgba - an RGBA float array of size 4, will be modified
        Returns:
        the passed-in rgba array, after applying the conversion
      • toLinear

        @NonNull
        public static float[] toLinear​(@NonNull
                                       Colors.Conversion conversion,
                                       @NonNull @Size(min=3L)
                                       float[] rgb)
        Converts an RGB color in sRGB space to an RGB color in linear space.
        Parameters:
        conversion - the conversion algorithm to use
        rgb - an RGB float array of at least size 3, will be modified
        Returns:
        the passed-in rgb array, after applying the conversion. The alpha channel, if present, is left unmodified.
      • cct

        @NonNull
        @Size(3L)
        public static float[] cct​(float temperature)
        Converts a correlated color temperature to a linear RGB color in sRGB space. The temperature must be expressed in Kelvin and must be in the range 1,000K to 15,000K.
        Parameters:
        temperature - the temperature, in Kelvin
        Returns:
        an RGB float array of size 3 with the result of the conversion
      • illuminantD

        @NonNull
        @Size(3L)
        public static float[] illuminantD​(float temperature)
        Converts a CIE standard illuminant series D to a linear RGB color in sRGB space. The temperature must be expressed in Kelvin and must be in the range 4,000K to 25,000K.
        Parameters:
        temperature - the temperature, in Kelvin
        Returns:
        an RGB float array of size 3 with the result of the conversion