Class ColorTools
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final IntegerPacked int representing black.static final IntegerPacked int representing blue.static final IntegerPacked int representing cyan.static final IntegerPacked int representing green.static final IntegerPacked int representing magenta.static final IntegerMask for use when extracting the alpha component from a packed ARGB int value.static final IntegerMask for use when extracting the blue component from a packed (A)RGB int value.static final IntegerMask for use when extracting the green component from a packed (A)RGB int value.static final IntegerMask for use when extracting the red component from a packed (A)RGB int value.static final IntegerPacked int representing red.static final IntegerPacked int representing white.static final IntegerPacked int representing yellow.
- 
Method SummaryModifier and TypeMethodDescriptionstatic intalpha(int argb) Extract the 8-bit alpha value from a packed ARGB value.static intblue(int rgb) Extract the 8-bit blue value from a packed RGB value.static intclip255(double val) Convert a double value to an int, flooring and clipping to the range 0-255.static intdo8BitRangeCheck(double v) Clip an input value to be an integer in the range 0-255 (with rounding down).static intdo8BitRangeCheck(float v) Clip an input value to be an integer in the range 0-255 (with rounding down).static intdo8BitRangeCheck(int v) Clip an input value to be an integer in the range 0-255.static intgreen(int rgb) Extract the 8-bit green value from a packed RGB value.static intmakeRGB(int r, int g, int b) Deprecated.static intmakeRGBA(int r, int g, int b, int a) Deprecated.The naming and order of arguments is misleading.static intmakeScaledRGB(int rgb, double scale) Scale the RGB channels for a color by a fixed amount.static intpackARGB(int a, int r, int g, int b) Make a packed ARGB value from specified input values.static intpackClippedARGB(int a, int r, int g, int b) Make a packed ARGB value from specified input values, clipping to the range 0-255.static intpackClippedRGB(int r, int g, int b) Make a packed RGB value from specified input values, clipping to the range 0-255.static intpackRGB(int r, int g, int b) Make a packed RGB value from specified input values.static intred(int rgb) Extract the 8-bit red value from a packed RGB value.static int[]unpackARGB(int rgb) Unpack a packed ARGB int into red, green and blue values, returning the result as a 4-element int array.static int[]unpackARGB(int rgb, int[] array) Unpack a packed ARGB int into red, green and blue values, into a 4-element int array.static int[]unpackRGB(int rgb) Unpack a packed (A)RGB int into red, green and blue values, returning the result as a 3-element int array.static int[]unpackRGB(int rgb, int[] array) Unpack a packed (A)RGB int into red, green and blue values, into a 3-element int array.
- 
Field Details- 
WHITEPacked int representing white.
- 
BLACKPacked int representing black.
- 
REDPacked int representing red.
- 
GREENPacked int representing green.
- 
BLUEPacked int representing blue.
- 
MAGENTAPacked int representing magenta.
- 
CYANPacked int representing cyan.
- 
YELLOWPacked int representing yellow.
- 
MASK_ALPHAMask for use when extracting the alpha component from a packed ARGB int value.
- 
MASK_REDMask for use when extracting the red component from a packed (A)RGB int value.
- 
MASK_GREENMask for use when extracting the green component from a packed (A)RGB int value.
- 
MASK_BLUEMask for use when extracting the blue component from a packed (A)RGB int value.
 
- 
- 
Method Details- 
makeRGBDeprecated.UsepackRGB(int, int, int)orpackClippedRGB(int, int, int)instead.Make a packed RGB value from specified input values.Input r, g and b should be in the range 0-255 - but no checking is applied. Rather, the input values are simply shifted as they are. The alpha value is 255. - Parameters:
- r-
- g-
- b-
- Returns:
 
- 
packRGBpublic static int packRGB(int r, int g, int b) Make a packed RGB value from specified input values. This is equivalent to an ARGB value with alpha set to 255, following JavaColor.Input r, g, and b should be in the range 0-255; only the lower 8 bits are used. - Parameters:
- r-
- g-
- b-
- Returns:
- packed ARGB value
- See Also:
 
- 
unpackRGBpublic static int[] unpackRGB(int rgb) Unpack a packed (A)RGB int into red, green and blue values, returning the result as a 3-element int array.- Parameters:
- rgb-
- Returns:
- Since:
- v0.4.0
 
- 
unpackRGBpublic static int[] unpackRGB(int rgb, int[] array) Unpack a packed (A)RGB int into red, green and blue values, into a 3-element int array.- Parameters:
- rgb-
- array- optional preallocated input array
- Returns:
- the red, green and blue values in arrayif provided and long enough, otherwise a new int array storing the values
- Since:
- v0.4.0
 
- 
unpackARGBpublic static int[] unpackARGB(int rgb) Unpack a packed ARGB int into red, green and blue values, returning the result as a 4-element int array.- Parameters:
- rgb-
- Returns:
- Since:
- v0.4.0
 
- 
unpackARGBpublic static int[] unpackARGB(int rgb, int[] array) Unpack a packed ARGB int into red, green and blue values, into a 4-element int array.- Parameters:
- rgb-
- array- optional preallocated input array
- Returns:
- the alpha, red, green and blue values in arrayif provided and long enough, otherwise a new int array storing the values
- Since:
- v0.4.0
 
- 
packClippedRGBpublic static int packClippedRGB(int r, int g, int b) Make a packed RGB value from specified input values, clipping to the range 0-255. This is equivalent to an ARGB value with alpha set to 255, following JavaColor.Input r, g, and b should be in the range 0-255, but if they are not they are clipped to the closest valid value. - Parameters:
- r-
- g-
- b-
- Returns:
- packed ARGB value // * @see #packRGB(int, int, int)
 
- 
makeRGBADeprecated.The naming and order of arguments is misleading. The output is a packed ARGB value, but arguments are provided in the order red, green, blue, alpha.Make a packed ARGB value from specified input values.Input r, g, b and a should be in the range 0-255 - but no checking is applied. Rather, the input values are simply shifted as they are. - Parameters:
- r-
- g-
- b-
- a-
- Returns:
- See Also:
 
- 
packARGBpublic static int packARGB(int a, int r, int g, int b) Make a packed ARGB value from specified input values.Input a, r, g, and b should be in the range 0-255; only the lower 8 bits are used. Warning! Note the order of the input values. This differs from the (deprecated) method makeRGBA(int, int, int, int)- Parameters:
- a-
- r-
- g-
- b-
- Returns:
- packed ARGB value
- See Also:
 
- 
packClippedARGBpublic static int packClippedARGB(int a, int r, int g, int b) Make a packed ARGB value from specified input values, clipping to the range 0-255.Input a, r, g, and b should be in the range 0-255, but if they are not they are clipped to the closest valid value. Warning! Note the order of the input values. This differs from the (deprecated) method makeRGBA(int, int, int, int)- Parameters:
- a-
- r-
- g-
- b-
- Returns:
- packed ARGB value
- See Also:
 
- 
do8BitRangeCheckpublic static int do8BitRangeCheck(int v) Clip an input value to be an integer in the range 0-255.- Parameters:
- v-
- Returns:
 
- 
do8BitRangeCheckpublic static int do8BitRangeCheck(float v) Clip an input value to be an integer in the range 0-255 (with rounding down).- Parameters:
- v-
- Returns:
 
- 
do8BitRangeCheckpublic static int do8BitRangeCheck(double v) Clip an input value to be an integer in the range 0-255 (with rounding down).- Parameters:
- v-
- Returns:
 
- 
alphapublic static int alpha(int argb) Extract the 8-bit alpha value from a packed ARGB value.- Parameters:
- argb-
- Returns:
 
- 
redpublic static int red(int rgb) Extract the 8-bit red value from a packed RGB value.- Parameters:
- rgb-
- Returns:
 
- 
greenpublic static int green(int rgb) Extract the 8-bit green value from a packed RGB value.- Parameters:
- rgb-
- Returns:
 
- 
bluepublic static int blue(int rgb) Extract the 8-bit blue value from a packed RGB value.- Parameters:
- rgb-
- Returns:
 
- 
makeScaledRGBpublic static int makeScaledRGB(int rgb, double scale) Scale the RGB channels for a color by a fixed amount.This is useful for brightening/darkening an input color. - Parameters:
- rgb-
- scale-
- Returns:
 
- 
clip255public static int clip255(double val) Convert a double value to an int, flooring and clipping to the range 0-255.- Parameters:
- val-
- Returns:
 
 
- 
packRGB(int, int, int)orpackClippedRGB(int, int, int)instead.