Package net.runelite.client.util
Class ColorUtil
- java.lang.Object
-
- net.runelite.client.util.ColorUtil
-
public class ColorUtil extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
CLOSING_COLOR_TAG
static int
MAX_RGB_VALUE
static int
MIN_RGB_VALUE
-
Constructor Summary
Constructors Constructor Description ColorUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Color
colorLerp(Color a, Color b, double t)
Linearly interpolates between colors a and b by t.static String
colorTag(Color color)
Creates a color tag from the given color.static String
colorToAlphaHexCode(Color color)
Gets the ARGB hex color code of the passed color.static String
colorToHexCode(Color color)
Gets the RGB hex color code of the passed color.static Color
colorWithAlpha(Color color, int alpha)
Gets the same RGB color with the specified alpha value.static int
constrainValue(int value)
Limits an int to the rgba value range (0-255)static Color
fromHex(String hex)
Gets the Color from the passed hex string.static Color
fromObject(Object object)
Creates color from passed object hash codestatic Color
fromString(String string)
Gets the Color from the passed int string.static boolean
isAlphaHex(String hex)
Determines if the passed hex string is an alpha hex color.static boolean
isHex(String hex)
Determines if the passed hex string is a hex color.static String
prependColorTag(String str, Color color)
Prepends the given str with an opening color tag of the given color.static String
toHexColor(Color color)
Converts a given color to it's hexadecimal equivalent.static String
wrapWithColorTag(String str, Color color)
Wraps the given str with a color tag of the given color.
-
-
-
Field Detail
-
MAX_RGB_VALUE
public static final int MAX_RGB_VALUE
- See Also:
- Constant Field Values
-
MIN_RGB_VALUE
public static final int MIN_RGB_VALUE
- See Also:
- Constant Field Values
-
CLOSING_COLOR_TAG
public static final String CLOSING_COLOR_TAG
- See Also:
- Constant Field Values
-
-
Method Detail
-
colorTag
public static String colorTag(Color color)
Creates a color tag from the given color.- Parameters:
color
- The Color to create a tag from.- Returns:
- A string of the color tag for the given color.
-
prependColorTag
public static String prependColorTag(String str, Color color)
Prepends the given str with an opening color tag of the given color.- Parameters:
str
- The string to be colorized.color
- The color to be used in the color tag.- Returns:
- The passed str with a prepended color tag.
-
wrapWithColorTag
public static String wrapWithColorTag(String str, Color color)
Wraps the given str with a color tag of the given color.- Parameters:
str
- The string to be colorized.color
- The color to be used in the color tag.- Returns:
- The passed str wrapped with opening and closing color tags.
-
toHexColor
public static String toHexColor(Color color)
Converts a given color to it's hexadecimal equivalent.- Parameters:
color
- Color to get hexadecimal string from.- Returns:
- Hexadecimal string representing the given color, in the form "#abcdef".
-
colorLerp
public static Color colorLerp(Color a, Color b, double t)
Linearly interpolates between colors a and b by t.- Parameters:
a
- first colorb
- second colort
- factor- Returns:
- interpolated color
-
colorToHexCode
public static String colorToHexCode(Color color)
Gets the RGB hex color code of the passed color.- Parameters:
color
- The color to get a hex code from.- Returns:
- A lower-cased string of the RGB hex code of color.
-
colorToAlphaHexCode
public static String colorToAlphaHexCode(Color color)
Gets the ARGB hex color code of the passed color.- Parameters:
color
- The color to get a hex code from.- Returns:
- A lower-cased string of the ARGB hex code of color.
-
colorWithAlpha
public static Color colorWithAlpha(Color color, int alpha)
Gets the same RGB color with the specified alpha value.- Parameters:
color
- The RGB color to use.alpha
- The alpha value to use (0-255).- Returns:
- A Color with the given RGB and alpha.
-
isAlphaHex
public static boolean isAlphaHex(String hex)
Determines if the passed hex string is an alpha hex color.- Parameters:
hex
- The hex to test.- Returns:
- boolean
-
isHex
public static boolean isHex(String hex)
Determines if the passed hex string is a hex color.- Parameters:
hex
- The hex to test.- Returns:
- boolean
-
constrainValue
public static int constrainValue(int value)
Limits an int to the rgba value range (0-255)- Parameters:
value
- The value for the r, g, b, or a.- Returns:
- An int between 0 - 255.
-
fromString
public static Color fromString(String string)
Gets the Color from the passed int string.- Parameters:
string
- The int to get a Color object from.- Returns:
- A Color of the int of color.
-
fromHex
public static Color fromHex(String hex)
Gets the Color from the passed hex string.- Parameters:
hex
- The hex to get a Color object from.- Returns:
- A Color of the hex code of color.
-
-