Class Color
java.lang.Object
org.wpilib.util.Color
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents a color channel in an RGB color. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Color0xF0F8FF.static final Color0xFAEBD7.static final Color0x00FFFF.static final Color0x7FFFD4.static final Color0xF0FFFF.static final Color0xF5F5DC.static final Color0xFFE4C4.static final Color0x000000.static final Color0xFFEBCD.final doubleBlue component (0-1).static final Color0x0000FF.static final Color0x8A2BE2.static final Color0xA52A2A.static final Color0xDEB887.static final Color0x5F9EA0.static final Color0x7FFF00.static final Color0xD2691E.static final Color0xFF7F50.static final Color0x6495ED.static final Color0xFFF8DC.static final Color0xDC143C.static final Color0x00FFFF.static final Color0x00008B.static final Color0x008B8B.static final Color0xB8860B.static final Color0xA9A9A9.static final Color0x006400.static final Color0xBDB76B.static final Color0x8B008B.static final Color0x556B2F.static final Color0xFF8C00.static final Color0x9932CC.static final Color0x8B0000.static final Color0xE9967A.static final Color0x8FBC8F.static final Color0x483D8B.static final Color0x2F4F4F.static final Color0x00CED1.static final Color0x9400D3.static final Color0xFF1493.static final Color0x00BFFF.static final Color0x1560BD.static final Color0x696969.static final Color0x1E90FF.static final Color0xB22222.static final Color0x0066B3.static final Color0xED1C24.static final Color0xFFFAF0.static final Color0x228B22.static final Color0xFF00FF.static final Color0xDCDCDC.static final Color0xF8F8FF.static final Color0xFFD700.static final Color0xDAA520.static final Color0x808080.final doubleGreen component (0-1).static final Color0x008000.static final Color0xADFF2F.static final Color0xF0FFF0.static final Color0xFF69B4.static final Color0xCD5C5C.static final Color0x4B0082.static final Color0xFFFFF0.static final Color0xF0E68C.static final Color0xE6E6FA.static final Color0xFFF0F5.static final Color0x7CFC00.static final Color0xFFFACD.static final Color0xADD8E6.static final Color0xF08080.static final Color0xE0FFFF.static final Color0xFAFAD2.static final Color0xD3D3D3.static final Color0x90EE90.static final Color0xFFB6C1.static final Color0xFFA07A.static final Color0x20B2AA.static final Color0x87CEFA.static final Color0x778899.static final Color0xB0C4DE.static final Color0xFFFFE0.static final Color0x00FF00.static final Color0x32CD32.static final Color0xFAF0E6.static final Color0xFF00FF.static final Color0x800000.static final Color0x66CDAA.static final Color0x0000CD.static final Color0xBA55D3.static final Color0x9370DB.static final Color0x3CB371.static final Color0x7B68EE.static final Color0x00FA9A.static final Color0x48D1CC.static final Color0xC71585.static final Color0x191970.static final Color0xF5FFFA.static final Color0xFFE4E1.static final Color0xFFE4B5.static final Color0xFFDEAD.static final Color0x000080.static final Color0xFDF5E6.static final Color0x808000.static final Color0x6B8E23.static final Color0xFFA500.static final Color0xFF4500.static final Color0xDA70D6.static final Color0xEEE8AA.static final Color0x98FB98.static final Color0xAFEEEE.static final Color0xDB7093.static final Color0xFFEFD5.static final Color0xFFDAB9.static final Color0xCD853F.static final Color0xFFC0CB.static final Color0xDDA0DD.static final Color0xB0E0E6.static final Color0x800080.final doubleRed component (0-1).static final Color0xFF0000.static final Color0xBC8F8F.static final Color0x4169E1.static final Color0x8B4513.static final Color0xFA8072.static final Color0xF4A460.static final Color0x2E8B57.static final Color0xFFF5EE.static final Color0xA0522D.static final Color0xC0C0C0.static final Color0x87CEEB.static final Color0x6A5ACD.static final Color0x708090.static final Color0xFFFAFA.static final Color0x00FF7F.static final Color0x4682B4.static final Color0xD2B48C.static final Color0x008080.static final Color0xD8BFD8.static final Color0xFF6347.static final Color0x40E0D0.static final Color0xEE82EE.static final Color0xF5DEB3.static final Color0xFFFFFF.static final Color0xF5F5F5.static final Color0xFFFF00.static final Color0x9ACD32. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic ColorfromHSV(int h, int s, int v) Creates a Color from HSV values.static ColorfromString(String str) Makes a Color from a string.inthashCode()static inthsvToRgb(int h, int s, int v) Converts HSV values to RGB values.static intlerpRGB(double r1, double g1, double b1, double r2, double g2, double b2, double t) Linearly interpolates between two RGB colors represented by the (r1, g1, b1) and (r2, g2, b2) triplets.static intlerpRGB(int r1, int g1, int b1, int r2, int g2, int b2, double t) Linearly interpolates between two RGB colors represented by the (r1, g1, b1) and (r2, g2, b2) triplets.static ColorPerforms a linear interpolation between two colors in the RGB colorspace.static intpackRGB(int r, int g, int b) Packs 3 RGB values into a single 32-bit integer.Return this color represented as a hex string.toString()static intunpackRGB(int packedColor, Color.RGBChannel channel) Unpacks a single color channel from a packed 32-bit RGB integer.
-
Field Details
-
red
Red component (0-1). -
green
Green component (0-1). -
blue
Blue component (0-1). -
DENIM
-
FIRST_BLUE
0x0066B3. -
FIRST_RED
-
ALICE_BLUE
0xF0F8FF. -
ANTIQUE_WHITE
0xFAEBD7. -
AQUA
-
AQUAMARINE
0x7FFFD4. -
AZURE
-
BEIGE
-
BISQUE
-
BLACK
-
BLANCHED_ALMOND
0xFFEBCD. -
BLUE
-
BLUE_VIOLET
0x8A2BE2. -
BROWN
-
BURLYWOOD
-
CADET_BLUE
0x5F9EA0. -
CHARTREUSE
0x7FFF00. -
CHOCOLATE
-
CORAL
-
CORNFLOWER_BLUE
0x6495ED. -
CORNSILK
-
CRIMSON
-
CYAN
-
DARK_BLUE
-
DARK_CYAN
-
DARK_GOLDENROD
0xB8860B. -
DARK_GRAY
-
DARK_GREEN
0x006400. -
DARK_KHAKI
0xBDB76B. -
DARK_MAGENTA
0x8B008B. -
DARK_OLIVE_GREEN
0x556B2F. -
DARK_ORANGE
0xFF8C00. -
DARK_ORCHID
0x9932CC. -
DARK_RED
-
DARK_SALMON
0xE9967A. -
DARK_SEA_GREEN
0x8FBC8F. -
DARK_SLATE_BLUE
0x483D8B. -
DARK_SLATE_GRAY
0x2F4F4F. -
DARK_TURQUOISE
0x00CED1. -
DARK_VIOLET
0x9400D3. -
DEEP_PINK
-
DEEP_SKY_BLUE
0x00BFFF. -
DIM_GRAY
-
DODGER_BLUE
0x1E90FF. -
FIREBRICK
-
FLORAL_WHITE
0xFFFAF0. -
FOREST_GREEN
0x228B22. -
FUCHSIA
-
GAINSBORO
-
GHOST_WHITE
0xF8F8FF. -
GOLD
-
GOLDENROD
-
GRAY
-
GREEN
-
GREEN_YELLOW
0xADFF2F. -
HONEYDEW
-
HOT_PINK
-
INDIAN_RED
0xCD5C5C. -
INDIGO
-
IVORY
-
KHAKI
-
LAVENDER
-
LAVENDER_BLUSH
0xFFF0F5. -
LAWN_GREEN
0x7CFC00. -
LEMON_CHIFFON
0xFFFACD. -
LIGHT_BLUE
0xADD8E6. -
LIGHT_CORAL
0xF08080. -
LIGHT_CYAN
0xE0FFFF. -
LIGHT_GOLDENROD_YELLOW
0xFAFAD2. -
LIGHT_GRAY
0xD3D3D3. -
LIGHT_GREEN
0x90EE90. -
LIGHT_PINK
0xFFB6C1. -
LIGHT_SALMON
0xFFA07A. -
LIGHT_SEA_GREEN
0x20B2AA. -
LIGHT_SKY_BLUE
0x87CEFA. -
LIGHT_SLATE_GRAY
0x778899. -
LIGHT_STEEL_BLUE
0xB0C4DE. -
LIGHT_YELLOW
0xFFFFE0. -
LIME
-
LIME_GREEN
0x32CD32. -
LINEN
-
MAGENTA
-
MAROON
-
MEDIUM_AQUAMARINE
0x66CDAA. -
MEDIUM_BLUE
0x0000CD. -
MEDIUM_ORCHID
0xBA55D3. -
MEDIUM_PURPLE
0x9370DB. -
MEDIUM_SEA_GREEN
0x3CB371. -
MEDIUM_SLATE_BLUE
0x7B68EE. -
MEDIUM_SPRING_GREEN
0x00FA9A. -
MEDIUM_TURQUOISE
0x48D1CC. -
MEDIUM_VIOLET_RED
0xC71585. -
MIDNIGHT_BLUE
0x191970. -
MINTCREAM
-
MISTY_ROSE
0xFFE4E1. -
MOCCASIN
-
NAVAJO_WHITE
0xFFDEAD. -
NAVY
-
OLD_LACE
-
OLIVE
-
OLIVE_DRAB
0x6B8E23. -
ORANGE
-
ORANGE_RED
0xFF4500. -
ORCHID
-
PALE_GOLDENROD
0xEEE8AA. -
PALE_GREEN
0x98FB98. -
PALE_TURQUOISE
0xAFEEEE. -
PALE_VIOLET_RED
0xDB7093. -
PAPAYA_WHIP
0xFFEFD5. -
PEACH_PUFF
0xFFDAB9. -
PERU
-
PINK
-
PLUM
-
POWDER_BLUE
0xB0E0E6. -
PURPLE
-
RED
-
ROSY_BROWN
0xBC8F8F. -
ROYAL_BLUE
0x4169E1. -
SADDLE_BROWN
0x8B4513. -
SALMON
-
SANDY_BROWN
0xF4A460. -
SEA_GREEN
-
SEASHELL
-
SIENNA
-
SILVER
-
SKY_BLUE
-
SLATE_BLUE
0x6A5ACD. -
SLATE_GRAY
0x708090. -
SNOW
-
SPRING_GREEN
0x00FF7F. -
STEEL_BLUE
0x4682B4. -
TAN
-
TEAL
-
THISTLE
-
TOMATO
-
TURQUOISE
-
VIOLET
-
WHEAT
-
WHITE
-
WHITE_SMOKE
0xF5F5F5. -
YELLOW
-
YELLOW_GREEN
0x9ACD32.
-
-
Constructor Details
-
Color
public Color()Constructs a default color (black). -
Color
Constructs a Color from doubles.- Parameters:
red- Red value (0-1)green- Green value (0-1)blue- Blue value (0-1)
-
Color
Constructs a Color from ints.- Parameters:
red- Red value (0-255)green- Green value (0-255)blue- Blue value (0-255)
-
Color
-
-
Method Details
-
fromString
Makes a Color from a string.- Parameters:
str- a string of the format#RRGGBB,rgb(R, G, B), orConstantName- Returns:
- the Color
- Throws:
IllegalArgumentException- if the string is invalid.
-
fromHSV
-
equals
-
hashCode
-
toString
-
toHexString
Return this color represented as a hex string.- Returns:
- a string of the format
#RRGGBB
-
hsvToRgb
Converts HSV values to RGB values. The returned RGB color is packed into a 32-bit integer for memory performance reasons.- Parameters:
h- The h value [0-180)s- The s value [0-255]v- The v value [0-255]- Returns:
- the packed RGB color
-
packRGB
Packs 3 RGB values into a single 32-bit integer. These values can be unpacked withunpackRGB(int, RGBChannel)to retrieve the values. This is helpful for avoiding memory allocations of newColorobjects and its resulting garbage collector pressure.- Parameters:
r- the value of the first channel to packg- the value of the second channel to packb- the value of the third channel to pack- Returns:
- the packed integer
-
unpackRGB
Unpacks a single color channel from a packed 32-bit RGB integer.Note: Packed RGB colors are expected to be in byte order [empty][red][green][blue].
- Parameters:
packedColor- the packed color to extract fromchannel- the color channel to unpack- Returns:
- the value of the stored color channel
-
lerpRGB
-
lerpRGB
public static int lerpRGB(double r1, double g1, double b1, double r2, double g2, double b2, double t) Linearly interpolates between two RGB colors represented by the (r1, g1, b1) and (r2, g2, b2) triplets. For memory performance reasons, the output color is returned packed into a single 32-bit integer; useunpackRGB(int, RGBChannel)to extract the values for the individual red, green, and blue channels.- Parameters:
r1- the red value of the first color, in [0, 1]g1- the green value of the first color, in [0, 1]b1- the blue value of the first color, in [0, 1]r2- the red value of the second color, in [0, 1]g2- the green value of the second color, in [0, 1]b2- the blue value of the second color, in [0, 1]t- the interpolation value, in [0, 1]- Returns:
- the interpolated color, packed in a 32-bit integer
-
lerpRGB
Linearly interpolates between two RGB colors represented by the (r1, g1, b1) and (r2, g2, b2) triplets. For memory performance reasons, the output color is returned packed into a single 32-bit integer; useunpackRGB(int, RGBChannel)to extract the values for the individual red, green, and blue channels.- Parameters:
r1- the red value of the first color, in [0, 255]g1- the green value of the first color, in [0, 255]b1- the blue value of the first color, in [0, 255]r2- the red value of the second color, in [0, 255]g2- the green value of the second color, in [0, 255]b2- the blue value of the second color, in [0, 255]t- the interpolation value, in [0, 1]- Returns:
- the interpolated color, packed in a 32-bit integer
-