Skip to content

Class endstone::Color

ClassList > endstone > Color

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

  • #include <endstone/util/color.h>

Public Static Attributes

Type Name
constexpr int BIT_MASK = 0xff
constexpr int DEFAULT_ALPHA = 255

Public Functions

Type Name
constexpr Color (const std::uint8_t red, const std::uint8_t green, const std::uint8_t blue, const std::uint8_t alpha=DEFAULT_ALPHA)
int asBGR () const
Gets the color as an BGR integer.
int asRGB () const
Gets the color as an RGB integer.
int asRGBA () const
Gets the color as an RGBA integer.
int getAlpha () const
Gets the alpha component of the color.
int getBlue () const
Gets the blue component of the color.
int getGreen () const
Gets the green component of the color.
int getRed () const
Gets the red component of the color.
bool operator!= (const Color & other) const
bool operator== (const Color & other) const
Result< Color > setAlpha (const int alpha) const
Creates a new Color object with specified component.
Result< Color > setBlue (const int blue) const
Creates a new Color object with specified component.
Result< Color > setGreen (const int green) const
Creates a new Color object with specified component.
Result< Color > setRed (const int red) const
Creates a new Color object with specified component.

Public Static Functions

Type Name
Result< Color > fromBGR (const int blue, const int green, const int red)
Creates a new Color object from a blue, green, and red.
Result< Color > fromBGR (const int bgr)
Result< Color > fromRGB (const int red, const int green, const int blue)
Creates a new Color object from a red, green, and blue.
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.
Result< Color > fromRGBA (int red, int green, int blue, int alpha)
Creates a new Color object from a red, green, blue, and alpha.
Result< Color > fromRGBA (const int rgba)
Creates a new color object from an integer that contains the red, green, blue, and alpha bytes.

Public Static Attributes Documentation

variable BIT_MASK

constexpr int endstone::Color::BIT_MASK;

variable DEFAULT_ALPHA

constexpr int endstone::Color::DEFAULT_ALPHA;

Public Functions Documentation

function Color

inline constexpr endstone::Color::Color (
    const std::uint8_t red,
    const std::uint8_t green,
    const std::uint8_t blue,
    const std::uint8_t alpha=DEFAULT_ALPHA
) 

function asBGR

Gets the color as an BGR integer.

inline int endstone::Color::asBGR () const

Returns:

An integer representation of this color, as 0xBBGGRR


function asRGB

Gets the color as an RGB integer.

inline int endstone::Color::asRGB () const

Returns:

An integer representation of this color, as 0xRRGGBB


function asRGBA

Gets the color as an RGBA integer.

inline int endstone::Color::asRGBA () const

Returns:

An integer representation of this color, as 0xRRGGBBAA


function getAlpha

Gets the alpha component of the color.

inline int endstone::Color::getAlpha () const

Returns:

The alpha component (0–255) of the color.


function getBlue

Gets the blue component of the color.

inline int endstone::Color::getBlue () const

Returns:

The blue component (0–255) of the color.


function getGreen

Gets the green component of the color.

inline int endstone::Color::getGreen () const

Returns:

The green component (0–255) of the color.


function getRed

Gets the red component of the color.

inline int endstone::Color::getRed () const

Returns:

The red component (0–255) of the color.


function operator!=

inline bool endstone::Color::operator!= (
    const Color & other
) const

function operator==

inline bool endstone::Color::operator== (
    const Color & other
) const

function setAlpha

Creates a new Color object with specified component.

inline Result< Color > endstone::Color::setAlpha (
    const int alpha
) const

Parameters:

  • alpha the alpha component, from 0 to 255

Returns:

a new color object with the alpha component


function setBlue

Creates a new Color object with specified component.

inline Result< Color > endstone::Color::setBlue (
    const int blue
) const

Parameters:

  • blue the blue component, from 0 to 255

Returns:

a new color object with the blue component


function setGreen

Creates a new Color object with specified component.

inline Result< Color > endstone::Color::setGreen (
    const int green
) const

Parameters:

  • green the green component, from 0 to 255

Returns:

a new color object with the green component


function setRed

Creates a new Color object with specified component.

inline Result< Color > endstone::Color::setRed (
    const int red
) const

Parameters:

  • red the red component, from 0 to 255

Returns:

a new color object with the red component


Public Static Functions Documentation

function fromBGR [½]

Creates a new Color object from a blue, green, and red.

static inline Result< Color > endstone::Color::fromBGR (
    const int blue,
    const int green,
    const int 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


function fromBGR [2/2]

static inline Result< Color > endstone::Color::fromBGR (
    const int bgr
) 

function fromRGB [½]

Creates a new Color object from a red, green, and blue.

static inline Result< Color > endstone::Color::fromRGB (
    const int red,
    const int green,
    const int 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


function fromRGB [2/2]

Creates a new color object from an integer that contains the red, green, and blue bytes in the lowest order 24 bits.

static inline Result< Color > endstone::Color::fromRGB (
    const int rgb
) 

Parameters:

  • rgb the integer storing the red, green, and blue values

Returns:

a new color object for specified values


function fromRGBA [½]

Creates a new Color object from a red, green, blue, and alpha.

static inline Result< Color > endstone::Color::fromRGBA (
    int red,
    int green,
    int blue,
    int 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


function fromRGBA [2/2]

Creates a new color object from an integer that contains the red, green, blue, and alpha bytes.

static inline Result< Color > endstone::Color::fromRGBA (
    const int rgba
) 

Parameters:

  • rgba the integer storing the red, green, blue, and alpha values

Returns:

a new color object for specified values



The documentation for this class was generated from the following file include/endstone/util/color.h