Package dev.robocode.tankroyale.botapi
Class Color
- java.lang.Object
-
- dev.robocode.tankroyale.botapi.Color
-
public class Color extends java.lang.Object
Color represented in RGB format.- See Also:
- Colors RGB.
-
-
Field Summary
Fields Modifier and Type Field Description static Color
BLACK
static Color
BLUE
static Color
CYAN
static Color
FUCHSIA
static Color
GRAY
static Color
GREEN
static Color
LIME
static Color
MAROON
static Color
NAVY
static Color
OLIVE
static Color
ORANGE
static Color
PURPLE
static Color
RED
static Color
SILVER
static Color
TEAL
static Color
WHITE
static Color
YELLOW
-
Constructor Summary
Constructors Constructor Description Color(int red, int green, int blue)
Creates a Color from RGB values.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
static Color
fromHex(java.lang.String hexTriplet)
Creates a color from a hex triplet.static Color
fromString(java.lang.String str)
Creates a color from a string.int
getBlue()
Returns the blue color component of the color.int
getGreen()
Returns the green color component of the color.int
getRed()
Returns the red color component of the color.int
hashCode()
java.lang.String
toHex()
Returns the color as a hex triplet of six hexadecimal digits representing an RGB color, e.g.java.lang.String
toString()
-
-
-
Field Detail
-
WHITE
public static final Color WHITE
-
SILVER
public static final Color SILVER
-
GRAY
public static final Color GRAY
-
BLACK
public static final Color BLACK
-
RED
public static final Color RED
-
MAROON
public static final Color MAROON
-
YELLOW
public static final Color YELLOW
-
OLIVE
public static final Color OLIVE
-
LIME
public static final Color LIME
-
GREEN
public static final Color GREEN
-
CYAN
public static final Color CYAN
-
TEAL
public static final Color TEAL
-
BLUE
public static final Color BLUE
-
NAVY
public static final Color NAVY
-
FUCHSIA
public static final Color FUCHSIA
-
PURPLE
public static final Color PURPLE
-
ORANGE
public static final Color ORANGE
-
-
Constructor Detail
-
Color
public Color(int red, int green, int blue)
Creates a Color from RGB values.- Parameters:
red
- is the red color component of the RGB color in the range [0 - 255]green
- is the green color component of the RGB color in the range [0 - 255]blue
- is the red blue component of the RGB color in the range [0 - 255]- See Also:
- Colors RGB.
-
-
Method Detail
-
getRed
public int getRed()
Returns the red color component of the color.- Returns:
- the red color component of the RGB color in the range [0 - 255]
-
getGreen
public int getGreen()
Returns the green color component of the color.- Returns:
- the green color component of the RGB color in the range [0 - 255]
-
getBlue
public int getBlue()
Returns the blue color component of the color.- Returns:
- the blue color component of the RGB color in the range [0 - 255]
-
toHex
public java.lang.String toHex()
Returns the color as a hex triplet of six hexadecimal digits representing an RGB color, e.g. "0099CC".- Returns:
- the color as a hex triplet of six hexadecimal digits representing an RGB color, e.g. "0099CC".
-
fromString
public static Color fromString(java.lang.String str)
Creates a color from a string. Currently, only numeric RGB values are supported. This method works the same was asfromHex(java.lang.String)
except that is required as hash sign before the hex value. An example of a numeric RGB value is "#09C" or "#0099CC", which both represents the same color.- Parameters:
str
- is a string containing either a three or six hexadecimal RGB values like "#09C" or "#0099CC".- Returns:
- the created Color;
null
if the input parameter isnull
. - See Also:
- Colors RGB, Web Colors
-
fromHex
public static Color fromHex(java.lang.String hexTriplet)
Creates a color from a hex triplet. A hex triplet is either three or six hexadecimal digits that represents an RGB Color.
An example of a hex triplet is "09C" or "0099CC", which both represents the same color.- Parameters:
hexTriplet
- is a string containing either a three or six hexadecimal numbers like "09C" or "0099CC".- Returns:
- the created Color.
- See Also:
- Colors RGB, Web Colors
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-