endstone::Color
Represents a color with red, green, blue, and alpha components.
Attributes:
| Name | Description |
|---|---|
BIT\_MASK | |
DEFAULT\_ALPHA |
Functions:
| Name | Description |
|---|---|
Color | |
asBGR | Gets the color as an BGR integer. |
asRGB | Gets the color as an RGB integer. |
asRGBA | Gets the color as an RGBA integer. |
getAlpha | Gets the alpha component of the color. |
getBlue | Gets the blue component of the color. |
getGreen | Gets the green component of the color. |
getRed | Gets the red component of the color. |
setAlpha | Creates a new Color object with specified component. |
setBlue | Creates a new Color object with specified component. |
setGreen | Creates a new Color object with specified component. |
setRed | Creates a new Color object with specified component. |
Functions:
| Name | Description |
|---|---|
fromBGR | Creates a new Color object from a blue, green, and red. |
fromBGR | |
fromRGB | Creates a new Color object from a red, green, and blue. |
fromRGB | Creates a new color object from an integer that contains the red, green, and blue bytes in the lowest order 24 bits. |
fromRGBA | Creates a new Color object from a red, green, blue, and alpha. |
fromRGBA | Creates a new color object from an integer that contains the red, green, blue, and alpha bytes. |
BIT_MASK
int endstone::Color::BIT_MASK; DEFAULT_ALPHA
int endstone::Color::DEFAULT_ALPHA; Color
constexpr Color(const std::uint8_t red, const std::uint8_t green,
const std::uint8_t blue,
const std::uint8_t alpha = DEFAULT_ALPHA) asBGR
int asBGR() constGets the color as an BGR integer.
Returns:
An integer representation of this color, as 0xBBGGRR
asRGB
int asRGB() constGets the color as an RGB integer.
Returns:
An integer representation of this color, as 0xRRGGBB
asRGBA
int asRGBA() constGets the color as an RGBA integer.
Returns:
An integer representation of this color, as 0xRRGGBBAA
getAlpha
int getAlpha() constGets the alpha component of the color.
Returns:
The alpha component (0–255) of the color.
getBlue
int getBlue() constGets the blue component of the color.
Returns:
The blue component (0–255) of the color.
getGreen
int getGreen() constGets the green component of the color.
Returns:
The green component (0–255) of the color.
getRed
int getRed() constGets the red component of the color.
Returns:
The red component (0–255) of the color.
setAlpha
Result<Color> setAlpha(const int alpha) constCreates a new Color object with specified component.
Parameters:
alphathe alpha component, from 0 to 255
Returns:
a new color object with the alpha component
setBlue
Result<Color> setBlue(const int blue) constCreates a new Color object with specified component.
Parameters:
bluethe blue component, from 0 to 255
Returns:
a new color object with the blue component
setGreen
Result<Color> setGreen(const int green) constCreates a new Color object with specified component.
Parameters:
greenthe green component, from 0 to 255
Returns:
a new color object with the green component
setRed
Result<Color> setRed(const int red) constCreates a new Color object with specified component.
Parameters:
redthe red component, from 0 to 255
Returns:
a new color object with the red component
fromBGR
static Result<Color> fromBGR(const int blue, const int green, const int red)Creates a new Color object from a blue, green, and red.
Parameters:
blueinteger from 0-255greeninteger from 0-255redinteger from 0-255
Returns:
a new Color object for the red, green, blue
static Result<Color> fromBGR(const int bgr) fromRGB
static Result<Color> fromRGB(const int red, const int green, const int blue)Creates a new Color object from a red, green, and blue.
Parameters:
redinteger from 0-255greeninteger from 0-255blueinteger from 0-255
Returns:
a new Color object for the red, green, blue
static Result<Color> fromRGB(const int rgb)Creates a new color object from an integer that contains the red, green, and blue bytes in the lowest order 24 bits.
Parameters:
rgbthe integer storing the red, green, and blue values
Returns:
a new color object for specified values
fromRGBA
static Result<Color> fromRGBA(int red, int green, int blue, int alpha)Creates a new Color object from a red, green, blue, and alpha.
Parameters:
redinteger from 0-255greeninteger from 0-255blueinteger from 0-255alphainteger from 0-255
Returns:
a new Color object for the red, green, blue, alpha
static Result<Color> fromRGBA(const int rgba)Creates a new color object from an integer that contains the red, green, blue, and alpha bytes.
Parameters:
rgbathe integer storing the red, green, blue, and alpha values
Returns:
a new color object for specified values