Back to index

nux  3.0.0
Public Member Functions | Public Attributes | Protected Attributes | Friends
nux::color::Color Class Reference

#include <Color.h>

List of all members.

Public Member Functions

 Color ()
 Color (unsigned int c)
 Color (int r, int g, int b)
 Color (float r, float g, float b, float a=1.0f)
 Color (RedGreenBlue const &rgb, float a=1.0f)
 Color (std::string const &hex)
 Constructor - Initializes the color using an hex string.
Color GetPremultiplied ()
 Returns the pre-multiplied version of this color.
void SetPremultiplied (float r, float g, float b, float a)
 Sets a pre-multiplied color.
bool IsPremultiplied ()
 Returns True if this color is pre-multiplied.

Public Attributes

float red
float green
float blue
float alpha

Protected Attributes

bool premultiplied_
 True if the rgb components have been pre-multiplied with the alpha component.

Friends

bool operator== (Color const &lhs, Color const &rhs)

Detailed Description

Definition at line 114 of file Color.h.


Constructor & Destructor Documentation

Definition at line 39 of file Color.cpp.

  : red(0.0f)
  , green(0.0f)
  , blue(0.0f)
  , alpha(1.0f)
  , premultiplied_(false)
  {}
nux::color::Color::Color ( unsigned int  c) [explicit]

Definition at line 55 of file Color.cpp.

  : red(NUX_RGBA_GET_RED(c) / 255.0f)
  , green(NUX_RGBA_GET_GREEN(c) / 255.0f)
  , blue(NUX_RGBA_GET_BLUE(c) / 255.0f)
  , alpha(NUX_RGBA_GET_ALPHA(c) / 255.0f)
  , premultiplied_(false)
  {}
nux::color::Color::Color ( int  r,
int  g,
int  b 
)

Definition at line 63 of file Color.cpp.

  : red(r / 255.0f)
  , green(g / 255.0f)
  , blue(b / 255.0f)
  , alpha(1.0f)
  , premultiplied_(false)
  {}
nux::color::Color::Color ( float  r,
float  g,
float  b,
float  a = 1.0f 
)

Definition at line 71 of file Color.cpp.

  : red(r)
  , green(g)
  , blue(b)
  , alpha(a)
  , premultiplied_(false)
  {}
nux::color::Color::Color ( RedGreenBlue const &  rgb,
float  a = 1.0f 
)

Definition at line 47 of file Color.cpp.

  : red(rgb.red)
  , green(rgb.green)
  , blue(rgb.blue)
  , alpha(a)
  , premultiplied_(false)
  {}
nux::color::Color::Color ( std::string const &  hex)

Constructor - Initializes the color using an hex string.

Initializes the color using an hex string, which may be in one of these formats:

RGB (each of R, G, B, A is a single hex digit)

RGBA

RRGGBB

RRGGBBAA

The color is #ffffffff if hex cannot be parsed.

Definition at line 79 of file Color.cpp.

  : red(0.0f)
  , green(0.0f)
  , blue(0.0f)
  , alpha(1.0f)
  , premultiplied_(false)
  {
    HexToRGBA(hex, red, green, blue, alpha);
  }

Here is the call graph for this function:


Member Function Documentation

Returns the pre-multiplied version of this color.

Returns the pre-multiplied version of this color. If this color is already pre-multiplied then *this is returned.
The premultiplied color is Color(red * alpha, green * alpha, blue * alpha, alpha).

Returns:
The pre-multiplied version of this color.

Definition at line 89 of file Color.cpp.

  {
    if (premultiplied_)
    {
      // Already pre-multiplied. Return *this;
      return *this;
    }

    Color c;
    c.SetPremultiplied(red, green, blue, alpha);
    return c;
  }

Here is the call graph for this function:

Returns True if this color is pre-multiplied.

Returns True if this color is pre-multiplied.

Returns:
True is this color is pre-multiplied.

Definition at line 111 of file Color.cpp.

  {
    return premultiplied_;
  }
void nux::color::Color::SetPremultiplied ( float  r,
float  g,
float  b,
float  a 
)

Sets a pre-multiplied color.

Sets a pre-multiplied color

Parameters:
rRed value.
gGreen value.
bBlue value.
aAlpha value.

Definition at line 102 of file Color.cpp.

  {
    red   = r * a;
    green = g * a;
    blue  = b * a;
    alpha = a;
    premultiplied_ = true;
  }

Here is the caller graph for this function:


Friends And Related Function Documentation

bool operator== ( Color const &  lhs,
Color const &  rhs 
) [friend]

Definition at line 116 of file Color.cpp.

  {
    return (lhs.red == rhs.red &&
            lhs.green == rhs.green &&
            lhs.blue == rhs.blue &&
            lhs.alpha == rhs.alpha &&
            lhs.premultiplied_ == rhs.premultiplied_);
  }

Member Data Documentation

Definition at line 168 of file Color.h.

Definition at line 167 of file Color.h.

Definition at line 166 of file Color.h.

True if the rgb components have been pre-multiplied with the alpha component.

Definition at line 171 of file Color.h.

Definition at line 165 of file Color.h.


The documentation for this class was generated from the following files: