Package info.u_team.u_team_core.util
Class RGBA
java.lang.Object
info.u_team.u_team_core.util.RGBA
Basic rgba representation of a color with some conversion methods
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRGBA
(float red, float green, float blue, float alpha) Creates a new RGBA object from the color components in range from 0 to 1 floats.RGBA
(int color) Creates a new RGBA object from a color integerRGBA
(int red, int green, int blue, int alpha) Creates a new RGBA object from the color components in range from 0 to 255 integers. -
Method Summary
Modifier and TypeMethodDescriptionstatic RGBA
fromARGB
(int color) Returns anRGBA
object from an argb integer.int
getAlpha()
Get alpha component in range from 0 to 255float
Get alpha component in range from 0 to 1int
getBlue()
Get blue component in range from 0 to 255float
Get blue component in range from 0 to 1int
getColor()
Get the integer (hex) representation of this color in rgba formatint
Get the integer (hex) representation of this color in argb formatint
getGreen()
Get green component in range from 0 to 255float
Get green component in range from 0 to 1int
getRed()
Get red component in range from 0 to 255float
Get red component in range from 0 to 1setAlpha
(int alpha) Set the alpha component in range from 0 to 255setAlphaComponent
(float alpha) Set the alpha component in range from 0 to 1setBlue
(int blue) Set the blue component in range from 0 to 255setBlueComponent
(float blue) Set the blue component in range from 0 to 1setGreen
(int green) Set the green component in range from 0 to 255setGreenComponent
(float green) Set the green component in range from 0 to 1setRed
(int red) Set the red component in range from 0 to 255setRedComponent
(float red) Set the red component in range from 0 to 1toString()
-
Field Details
-
BLACK
-
WHITE
-
-
Constructor Details
-
RGBA
public RGBA(int color) Creates a new RGBA object from a color integer- Parameters:
color
- hex code of color e.g. 0xFFFFFFFF for white
-
RGBA
public RGBA(int red, int green, int blue, int alpha) Creates a new RGBA object from the color components in range from 0 to 255 integers.- Parameters:
red
- Red componentgreen
- Green componentblue
- Blue componentalpha
- Alpha component
-
RGBA
public RGBA(float red, float green, float blue, float alpha) Creates a new RGBA object from the color components in range from 0 to 1 floats.- Parameters:
red
- Red componentgreen
- Green componentblue
- Blue componentalpha
- Alpha component
-
-
Method Details
-
getRed
public int getRed()Get red component in range from 0 to 255- Returns:
- Red component
-
getGreen
public int getGreen()Get green component in range from 0 to 255- Returns:
- Green component
-
getBlue
public int getBlue()Get blue component in range from 0 to 255- Returns:
- Blue component
-
getAlpha
public int getAlpha()Get alpha component in range from 0 to 255- Returns:
- Alpha component
-
getRedComponent
public float getRedComponent()Get red component in range from 0 to 1- Returns:
- Red component
-
getGreenComponent
public float getGreenComponent()Get green component in range from 0 to 1- Returns:
- Green component
-
getBlueComponent
public float getBlueComponent()Get blue component in range from 0 to 1- Returns:
- Blue component
-
getAlphaComponent
public float getAlphaComponent()Get alpha component in range from 0 to 1- Returns:
- Alpha component
-
getColor
public int getColor()Get the integer (hex) representation of this color in rgba format- Returns:
- Color as an integer
-
getColorARGB
public int getColorARGB()Get the integer (hex) representation of this color in argb format- Returns:
- Color as an integer
-
setRed
Set the red component in range from 0 to 255- Parameters:
red
- Red component- Returns:
- A new RGBA instance with the red value set
-
setGreen
Set the green component in range from 0 to 255- Parameters:
green
- Green component- Returns:
- A new RGBA instance with the green value set
-
setBlue
Set the blue component in range from 0 to 255- Parameters:
blue
- Blue component- Returns:
- A new RGBA instance with the blue value set
-
setAlpha
Set the alpha component in range from 0 to 255- Parameters:
alpha
- Alpha component- Returns:
- A new RGBA instance with the alpha value set
-
setRedComponent
Set the red component in range from 0 to 1- Parameters:
red
- Red component- Returns:
- A new RGBA instance with the red value set
-
setGreenComponent
Set the green component in range from 0 to 1- Parameters:
green
- Green component- Returns:
- A new RGBA instance with the green value set
-
setBlueComponent
Set the blue component in range from 0 to 1- Parameters:
blue
- Blue component- Returns:
- A new RGBA instance with the blue value set
-
setAlphaComponent
Set the alpha component in range from 0 to 1- Parameters:
alpha
- Alpha component- Returns:
- A new RGBA instance with the alpha value set
-
toString
-
fromARGB
Returns anRGBA
object from an argb integer. This encoding is used in many minecraft stuff- Parameters:
color
- ARBA color- Returns:
- RGBA object
-