Class Color#

Class Documentation#

class Color#

RGB color representation.

Color class represents a color by RGB and alpha value.

Authors

beyss, stratmann

Date

27.07.2017

Public Functions

inline Color(double r = 0, double g = 0, double b = 0, double a = 1)#

Creates a Color from RGB and Alpha values.

Parameters:
  • r – the red value

  • g – the green value

  • b – the blue value

  • a – the alpha value

inline Color(const Color &c, double a)#
inline const double &r() const#

Access function for the color’s red value.

Returns:

a reference to the colors red value

inline const double &g() const#

Access function for the color’s green value.

Returns:

a reference to the colors green value

inline const double &b() const#

Access function for the color’s blue value.

Returns:

a reference to the colors blue value

inline const double &a() const#

Access function for the color’s alpha value.

Returns:

a reference to the colors alpha value

inline bool operator==(const Color &color) const#

Checks whether or not two colors are equal. This is the case if RGBA values are the same.

Parameters:

color – the other color

Returns:

equal or not

inline bool operator!=(const Color &color) const#

Checks whether or not two colors are not equal. Two colors would be equal if their RGBA values were the same.

Parameters:

color – the other color

Returns:

not equal or equal

inline void set_red(double red)#

Sets the red value of this Color. Input values from 0 to 255 will be automatically corrected to values from [0,1].

Parameters:

red – the red value to set

inline void set_green(double green)#

Sets the green value of this Color. Input values from 0 to 255 will be automatically corrected to values from [0,1].

Parameters:

green – the green value to set

inline void set_blue(double blue)#

Sets the blue value of this Color. Input values from 0 to 255 will be automatically corrected to values from [0,1].

Parameters:

blue – the blue value to set

inline void set_alpha(double alpha)#

Sets the alpha value of this Color. Input values from 0 to 255 will be automatically corrected to values from [0,1].

Parameters:

alpha – the alpha value to set

Public Static Attributes

static const Color BLACK = {0, 0, 0, 255}#

A Color constant representing black (0,0,0,1)

Friends

inline friend std::ostream &operator<<(std::ostream &o, const Color &c)#

Puts string representation of Color c to the output stream o.

Parameters:
  • o – the ostream to put into

  • c – the color to put