Class Avogadro::Core::Color3f#

class Color3f#

Representation of an RGB color using three floats.

This class represents a color as three floats ranging from 0.0 to 1.0 specifying the intensity of the red, green and blue components of the color. It is stored in memory as float[3], and so vectors containing this type may be passed directly to OpenGL and other functions as C arrays.

Author

Marcus D. Hanwell

Several convenience functions are provided, the class is written with an emphasis on efficiency and memory layout.

Public Functions

inline Color3f(float red = 0.0, float green = 0.0, float blue = 0.0)#

Constructor, results in a black Color3f object unless the RGB values are set.

Parameters:
  • red – Intensity (from 0.0 to 1.0) of the red component of the color.

  • green – Intensity (from 0.0 to 1.0) of the green component of the color.

  • blue – Intensity (from 0.0 to 1.0) of the blue component of the color.

inline Color3f(int red, int green, int blue)#

Constructor where the color is constructed from integer values.

Parameters:
  • red – Intensity (from 0 to 255) of the red component of the color.

  • green – Intensity (from 0 to 255) of the green component of the color.

  • blue – Intensity (from 0 to 255) of the blue component of the color.

inline void set(float red, float green, float blue)#

Sets the color objects components.

Parameters:
  • red – Intensity (from 0.0 to 1.0) of the red component of the color.

  • green – Intensity (from 0.0 to 1.0) of the green component of the color.

  • blue – Intensity (from 0.0 to 1.0) of the blue component of the color.

inline float red() const#
Returns:

The intensity of the red component of the color (0.0 to 1.0).

inline float green() const#
Returns:

The intensity of the green component of the color (0.0 to 1.0).

inline float blue() const#
Returns:

The intensity of the blue component of the color (0.0 to 1.0).

inline float *data()#
Returns:

Direct access to the underlying float array of size 3.

inline const float *data() const#

This function is useful when calling OpenGL functions which expect a float * array of size 3.

Returns:

Direct access to the underlying float array of size 3.

Protected Attributes

float m_data[3]#