~ubuntu-branches/ubuntu/maverick/blender/maverick

« back to all changes in this revision

Viewing changes to extern/qdune/core/Color.h

  • Committer: Bazaar Package Importer
  • Author(s): Khashayar Naderehvandi, Khashayar Naderehvandi, Alessio Treglia
  • Date: 2009-01-22 16:53:59 UTC
  • mfrom: (14.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090122165359-v0996tn7fbit64ni
Tags: 2.48a+dfsg-1ubuntu1
[ Khashayar Naderehvandi ]
* Merge from debian experimental (LP: #320045), Ubuntu remaining changes:
  - Add patch correcting header file locations.
  - Add libvorbis-dev and libgsm1-dev to Build-Depends.
  - Use avcodec_decode_audio2() in source/blender/src/hddaudio.c

[ Alessio Treglia ]
* Add missing previous changelog entries.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef COLOR_H
2
 
#define COLOR_H
3
 
 
4
 
#include "QDRender.h"
5
 
__BEGIN_QDRENDER
6
 
 
7
 
class Color
8
 
{
9
 
public:
10
 
        // ctors
11
 
        Color():r(0), g(0), b(0) {}
12
 
        explicit Color(float i):r(i), g(i), b(i) {}
13
 
        explicit Color(float i, float j, float k):r(i), g(j), b(k) {}
14
 
        Color(const Color &c):r(c.r), g(c.g), b(c.b) {}
15
 
        // dtor
16
 
        ~Color() {}
17
 
        // mtds
18
 
        void set(float i) { r=g=b=i; }
19
 
        void set(float i, float j, float k) { r=i;  g=j;  b=k; }
20
 
        // basic arith.
21
 
        Color operator+(const Color &c) const { return Color(r+c.r, g+c.g, b+c.b); }
22
 
        Color operator-(const Color &c) const { return Color(r-c.r, g-c.g, b-c.b); }
23
 
        Color operator*(float s) const { return Color(r*s, g*s, b*s); }
24
 
        friend Color operator*(float s, const Color &c) { return Color(c.r*s, c.g*s, c.b*s); }
25
 
        Color operator*(const Color &c) const { return Color(r*c.r, g*c.g, b*c.b); }
26
 
        Color operator/(float s) const { if (s!=0) s=1.f/s;  return Color(r*s, g*s, b*s);  }
27
 
        Color& operator+=(const Color &c) { r+=c.r;  g+=c.g;  b+=c.b;  return *this; }
28
 
        Color& operator-=(const Color &c) { r-=c.r;  g-=c.g;  b-=c.b;  return *this; }
29
 
        Color& operator*=(float s) { r*=s;  g*=s;  b*=s;  return *this; }
30
 
        Color& operator*=(const Color &c) { r*=c.r;  g*=c.g;  b*=c.b;  return *this; }
31
 
        Color& operator/=(float s) { if (s!=0) s=1.f/s;   r*=s;  g*=s;  b*=s;  return *this; }
32
 
        float& operator[](int i) { return rgb[i]; }     // no bounds check!
33
 
        float operator[](int i) const { return rgb[i]; }        // no bounds check!
34
 
        // data
35
 
        union {
36
 
                struct { float r, g, b; };
37
 
                float rgb[3];
38
 
        };
39
 
};
40
 
 
41
 
Color rgb2hsl(const Color& rgb);
42
 
Color hsl2rgb(const Color& hsl);
43
 
 
44
 
__END_QDRENDER
45
 
 
46
 
#endif // COLOR_H