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() const
Gets the color as an BGR integer.
Returns:
An integer representation of this color, as 0xBBGGRR
asRGB
int asRGB() const
Gets the color as an RGB integer.
Returns:
An integer representation of this color, as 0xRRGGBB
asRGBA
int asRGBA() const
Gets the color as an RGBA integer.
Returns:
An integer representation of this color, as 0xRRGGBBAA
getAlpha
int getAlpha() const
Gets the alpha component of the color.
Returns:
The alpha component (0–255) of the color.
getBlue
int getBlue() const
Gets the blue component of the color.
Returns:
The blue component (0–255) of the color.
getGreen
int getGreen() const
Gets the green component of the color.
Returns:
The green component (0–255) of the color.
getRed
int getRed() const
Gets the red component of the color.
Returns:
The red component (0–255) of the color.
setAlpha
Result<Color> setAlpha(const int alpha) const
Creates a new Color object with specified component.
Parameters:
alpha
the alpha component, from 0 to 255
Returns:
a new color object with the alpha component
setBlue
Result<Color> setBlue(const int blue) const
Creates a new Color object with specified component.
Parameters:
blue
the blue component, from 0 to 255
Returns:
a new color object with the blue component
setGreen
Result<Color> setGreen(const int green) const
Creates a new Color object with specified component.
Parameters:
green
the green component, from 0 to 255
Returns:
a new color object with the green component
setRed
Result<Color> setRed(const int red) const
Creates a new Color object with specified component.
Parameters:
red
the 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:
blue
integer from 0-255green
integer from 0-255red
integer 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:
red
integer from 0-255green
integer from 0-255blue
integer 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:
rgb
the 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:
red
integer from 0-255green
integer from 0-255blue
integer from 0-255alpha
integer 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:
rgba
the integer storing the red, green, blue, and alpha values
Returns:
a new color object for specified values