Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8431 in orxonox.OLD for branches/gui/src/lib


Ignore:
Timestamp:
Jun 15, 2006, 12:51:52 AM (18 years ago)
Author:
bensch
Message:

gui: more Color functionality (maths)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gui/src/lib/util/color.h

    r8419 r8431  
    1919  Color(const Color& c) { _rgba[0] = c.r(); _rgba[1] = c.g(); _rgba[2] = c.b(); _rgba[3] = c.a(); }
    2020
    21   const Color& operator=(const Color& c) { _rgba[0] = c.r(); _rgba[1] = c.g(); _rgba[2] = c.b(); _rgba[3] = c.a(); return *this; };
    22   bool operator==(const Color& c) const { return (r() == c.r() && g() == c.g() && b() == c.b() && a() == c.a()); };
     21  inline const Color& operator=(const Color& c) { _rgba[0] = c.r(); _rgba[1] = c.g(); _rgba[2] = c.b(); _rgba[3] = c.a(); return *this; };
     22  inline bool operator==(const Color& c) const { return (r() == c.r() && g() == c.g() && b() == c.b() && a() == c.a()); };
    2323
    2424  inline float& operator[](unsigned int i) { return _rgba[i]; }
     
    3636
    3737
     38
    3839  void setColor(float r = 0.0f, float g = 0.0f, float b = 0.0f, float a = 1.0f) { _rgba[0] = r; _rgba[1] = g; _rgba[2] = b; _rgba[3] = a; };
     40
     41  /// Maths
     42  inline const Color& operator+=(const Color& c) { r()+=c.r(); g()+=c.g(); b()+=c.b(); a()+=c.a(); return *this; };
     43  inline Color operator+(const Color& c) const { return Color(r()+c.r(), g()+c.g(), b()+c.b(), a()+c.a()); };
     44  inline const Color& operator-=(const Color& c) { r()-=c.r(); g()-=c.g(); b()-=c.b(); a()-=c.a(); return *this; };
     45  inline Color operator-(const Color& c) const { return Color(r()-c.r(), g()-c.g(), b()-c.b(), a()-c.a()); };
     46  inline Color operator*(float v) const { return Color(r()*v, g()*v, b()*v, a()*v); };
     47
     48  void slerp(const Color& c, float v) { *this += (c - *this) * v; };
    3949
    4050  void debug() const;
Note: See TracChangeset for help on using the changeset viewer.