Package com.google.android.filament
Class Colors
- java.lang.Object
-
- com.google.android.filament.Colors
-
public class Colors extends java.lang.ObjectUtilities to manipulate and convert colors.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classColors.ConversionType of color conversion to use when converting to/from sRGB and linear spaces.static interfaceColors.LinearColorstatic classColors.RgbaTypeTypes of RGBA colors.static classColors.RgbTypeTypes 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.
-
-
-
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 providedr- the red componentg- the green componentb- 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 providedrgb- an RGB float array of size 3, will be modified- Returns:
- the passed-in
rgbarray, 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 providedr- the red componentg- the green componentb- the blue componenta- 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 providedrgba- an RGBA float array of size 4, will be modified- Returns:
- the passed-in
rgbaarray, 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 usergb- an RGB float array of at least size 3, will be modified- Returns:
- the passed-in
rgbarray, 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
-
-