#ifndef __CCOLOR_H__
#define __CCOLOR_H__

class CColor
{
 public:
  CColor()
    : m_red(0), m_green(0), m_blue(0) {}
  CColor(float r, float g, float b)
    : m_red(r), m_green(g), m_blue(b) {}

  float red  ()        const { return m_red; }
  void  red  (float r)       { m_red = r;}
  float green()        const { return m_green; }
  void  green(float g)       { m_green = g;}
  float blue ()        const { return m_blue; }
  void  blue (float b)       { m_blue = b;}

  inline CColor operator +(const CColor &c) const
    {
      return CColor(m_red + c.m_red, m_green + c.m_green, m_blue + c.m_blue);
    }
  inline CColor operator -(const CColor &c) const
    {
      return CColor(m_red - c.m_red, m_green - c.m_green, m_blue - c.m_blue);
    }
  inline CColor operator *(const CColor &c) const
    {
      return CColor(m_red * c.m_red, m_green * c.m_green, m_blue * c.m_blue);
    }
  inline CColor operator *(float k) const
    {
      return CColor(k*m_red, k*m_green, k*m_blue);
    }
  friend inline CColor operator *(float k, const CColor &c);

  inline CColor operator += (const CColor &c)
    {
      m_red   += c.m_red;
      m_green += c.m_green;
      m_blue  += c.m_blue;
      return (*this);
    }
  inline CColor operator -= (const CColor &c)
    {
      m_red   -= c.m_red;
      m_green -= c.m_green;
      m_blue  -= c.m_blue;
      return (*this);
    }
  inline CColor operator *= (const CColor &c)
    {
      m_red   *= c.m_red;
      m_green *= c.m_green;
      m_blue  *= c.m_blue;
      return (*this);
    }
  inline CColor operator *= (float k)
    {
      m_red   *= k;
      m_green *= k;
      m_blue  *= k;
      return (*this);
    }

  friend inline std::ostream& operator <<(std::ostream& o,
                                          const CColor &c);
  
 private:
  float m_red;
  float m_green;
  float m_blue;
};

inline CColor operator *(float k, const CColor &c)
{
  return CColor(k*c.m_red, k*c.m_green, k*c.m_blue);
}
inline std::ostream& operator << (std::ostream& o, const CColor &c)
{
  o << "( " << c.m_red << " , " << c.m_green << " , " << c.m_blue << " )";
  return o;
}

#endif  // __CCOLOR_H__
