Skip to Content
⚠ Under Construction
ReferenceC++ APIColor

endstone::Color

Represents a color with red, green, blue, and alpha components.

Attributes:

Functions:

NameDescription
Color
asBGRGets the color as an BGR integer.
asRGBGets the color as an RGB integer.
asRGBAGets the color as an RGBA integer.
getAlphaGets the alpha component of the color.
getBlueGets the blue component of the color.
getGreenGets the green component of the color.
getRedGets the red component of the color.
setAlphaCreates a new Color object with specified component.
setBlueCreates a new Color object with specified component.
setGreenCreates a new Color object with specified component.
setRedCreates a new Color object with specified component.

Functions:

NameDescription
fromBGRCreates a new Color object from a blue, green, and red.
fromBGR
fromRGBCreates a new Color object from a red, green, and blue.
fromRGBCreates a new color object from an integer that contains the red, green, and blue bytes in the lowest order 24 bits.
fromRGBACreates a new Color object from a red, green, blue, and alpha.
fromRGBACreates 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-255
  • green integer from 0-255
  • red 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-255
  • green integer from 0-255
  • blue 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-255
  • green integer from 0-255
  • blue integer from 0-255
  • alpha 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

Last updated on