Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8448 in orxonox.OLD for trunk/src/lib/util


Ignore:
Timestamp:
Jun 15, 2006, 12:48:26 PM (19 years ago)
Author:
bensch
Message:

merged gui back to the trunk
merged with command
merge -r8377:HEAD https://svn.orxonox.net/orxonox/branches/gui .

Location:
trunk/src/lib/util
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/util/color.cc

    r8376 r8448  
    1818#include "color.h"
    1919#include <stdio.h>
     20
     21
     22void Color::debug() const
     23{
     24  printf("r:%0.2f g:%0.2f, b:%0.2f, a:%0.2f\n", r(), g(), b(), a());
     25}
    2026
    2127/**
  • trunk/src/lib/util/color.h

    r8376 r8448  
    1616{
    1717public:
    18   Color(float r = 0.0f, float g = 0.0f, float b = 0.0f, float a = 0.0f) { _rgba[0] = r; _rgba[1] = g; _rgba[2] = b; _rgba[3] = a; };
     18  Color(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; };
    1919  Color(const Color& c) { _rgba[0] = c.r(); _rgba[1] = c.g(); _rgba[2] = c.b(); _rgba[3] = c.a(); }
    2020
    21   float& operator[](unsigned int i) { return _rgba[i]; }
    22   const float& operator[](unsigned int i) const { return _rgba[i]; }
     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
    24   float r() const { return _rgba[0]; }
    25   float& r() { return _rgba[0]; }
    26   float g() const { return _rgba[1]; }
    27   float& g() { return _rgba[1]; }
    28   float b() const { return _rgba[2]; }
    29   float& b() { return _rgba[2]; }
    30   float a() const { return _rgba[3]; }
    31   float& a() { return _rgba[3]; }
     24  inline float& operator[](unsigned int i) { return _rgba[i]; }
     25  inline const float& operator[](unsigned int i) const { return _rgba[i]; }
    3226
     27  inline float r() const { return _rgba[0]; }
     28  inline float& r() { return _rgba[0]; }
     29  inline float g() const { return _rgba[1]; }
     30  inline float& g() { return _rgba[1]; }
     31  inline float b() const { return _rgba[2]; }
     32  inline float& b() { return _rgba[2]; }
     33  inline float a() const { return _rgba[3]; }
     34  inline float& a() { return _rgba[3]; }
     35
     36
     37
     38
     39  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  void setColor(const Color& c) { r() = c.r();  g()= c.g(); b() = c.b(); a() = c.a(); };
     41
     42  inline float dist(const Color& c) const { return (sqrt((r()-c.r())*(r()-c.r()) + (g()-c.g())*(g()-c.g()) + (b()-c.b())*(b()-c.b()) + (a()-c.a())*(a()-c.a()))); }
     43  /// Maths
     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 const Color& operator-=(const Color& c) { r()-=c.r(); g()-=c.g(); b()-=c.b(); a()-=c.a(); return *this; };
     47  inline Color operator-(const Color& c) const { return Color(r()-c.r(), g()-c.g(), b()-c.b(), a()-c.a()); };
     48  inline Color operator*(float v) const { return Color(r()*v, g()*v, b()*v, a()*v); };
     49
     50  void slerp(const Color& c, float v) { *this += (c - *this) * v; };
     51
     52  void debug() const;
    3353
    3454  /// STATIC TRANSFORMATIONS
Note: See TracChangeset for help on using the changeset viewer.