Package com.jeff_media.jefflib.data
Class HexColor
java.lang.Object
com.jeff_media.jefflib.data.HexColor
Represents a hex color code
-
Constructor Summary
ConstructorsConstructorDescriptionHexColor
(int red, int green, int blue) Creates a HexColor with the given RGB valueCreates a HexColor from a String in the format "rrggbb" (e.g. 00ff00)Creates a HexColor from three separate hex color Strings -
Method Summary
Modifier and TypeMethodDescriptionstatic String
applyGradient
(String text, HexColor start, HexColor end) Applies a gradient to the given text.boolean
int
getBlue()
Returns the Blue color component valueint
getGreen()
Returns the Green color component valuestatic HexColor
getHexAtPositionInGradient
(HexColor start, HexColor end, int textLengh, int position) Returns the HexColor for a given gradient at the given positionint
getRed()
Returns the Red color component valueint
hashCode()
void
setBlue
(int blue) Sets the Blue color component valuevoid
setGreen
(int green) Sets the Green color component valuevoid
setRed
(int red) Sets the Red color component valueConverts the HexColor into color codes readable byChatColor.translateAlternateColorCodes(char, String)
, using the ampersand (&) as alternate color charactertoHex()
Returns the HexColor as a String in the format rrggbb (e.g. 00ff00)toString()
-
Constructor Details
-
HexColor
Creates a HexColor with the given RGB value- Parameters:
red
- Red (0-255)green
- Green (0-255)blue
- Blue (0-255)
-
HexColor
Creates a HexColor from a String in the format "rrggbb" (e.g. 00ff00)- Parameters:
hex
- Color in hex
-
HexColor
Creates a HexColor from three separate hex color Strings- Parameters:
red
- Red (00-ff)green
- Green (00-ff)blue
- Blue (00-ff)
-
-
Method Details
-
applyGradient
Applies a gradient to the given text. Also preserves already existing formatting codes inside the text.- Parameters:
text
- Text to apply gradient tostart
- Starting colorend
- End color- Returns:
- Text with color codes applied to match the given gradient
-
getHexAtPositionInGradient
public static HexColor getHexAtPositionInGradient(HexColor start, HexColor end, int textLengh, int position) Returns the HexColor for a given gradient at the given position- Parameters:
start
- Starting colorend
- End colortextLengh
- Text lenghposition
- Position inside the text- Returns:
- HexColor needed at this position
-
toColorCode
Converts the HexColor into color codes readable byChatColor.translateAlternateColorCodes(char, String)
, using the ampersand (&) as alternate color character- Returns:
- HexColor as color code, e.g. "&x&0&0&f&f&0&0"
-
toHex
Returns the HexColor as a String in the format rrggbb (e.g. 00ff00)- Returns:
- HexColor as String
-
getRed
Returns the Red color component value- Returns:
- Red color component value (0-255)
-
setRed
Sets the Red color component value- Parameters:
red
- Red color component value (0-255)
-
getGreen
Returns the Green color component value- Returns:
- Red green component value (0-255)
-
setGreen
Sets the Green color component value- Parameters:
green
- Green color component value (0-255)
-
getBlue
Returns the Blue color component value- Returns:
- Blue color component value (0-255)
-
setBlue
Sets the Blue color component value- Parameters:
blue
- Blue color component value (0-255)
-
hashCode
-
equals
-
toString
-