VTK
vtkColor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkColor.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
24 #ifndef __vtkColor_h
25 #define __vtkColor_h
26 
27 #include "vtkVector.h"
28 
29 // .NAME vtkColor3 - templated base type for storage of 3 component colors.
30 //
31 template<typename T>
32 class vtkColor3 : public vtkVector<T, 3>
33 {
34 public:
35  vtkColor3(const T& red = 0, const T& green = 0, const T& blue = 0)
36  {
37  this->Data[0] = red;
38  this->Data[1] = green;
39  this->Data[2] = blue;
40  }
41  explicit vtkColor3(const T* init) : vtkVector<T, 3>(init)
42  {
43  }
44 
46 
47  void Set(const T& red, const T& green, const T& blue)
48  {
49  this->Data[0] = red;
50  this->Data[1] = green;
51  this->Data[2] = blue;
52  }
54 
56  void SetRed(const T& red) { this->Data[0] = red; }
57 
59 
60  const T& GetRed() const { return this->Data[0]; }
61  const T& Red() const { return this->Data[0]; }
63 
65  void SetGreen(const T& green) { this->Data[1] = green; }
66 
68 
69  const T& GetGreen() const { return this->Data[1]; }
70  const T& Green() const { return this->Data[1]; }
72 
74  void SetBlue(const T& blue) { this->Data[2] = blue; }
75 
77 
78  const T& GetBlue() const { return this->Data[2]; }
79  const T& Blue() const { return this->Data[2]; }
80 };
82 
83 // .NAME vtkColor4 - templated base type for storage of 4 component colors.
84 //
85 template<typename T>
86 class vtkColor4 : public vtkVector<T, 4>
87 {
88 public:
89  vtkColor4(const T& red = 0, const T& green = 0, const T& blue = 0,
90  const T& alpha = 0)
91  {
92  this->Data[0] = red;
93  this->Data[1] = green;
94  this->Data[2] = blue;
95  this->Data[3] = alpha;
96  }
97  explicit vtkColor4(const T* init) : vtkVector<T, 4>(init)
98  {
99  }
100 
102 
103  void Set(const T& red, const T& green, const T& blue)
104  {
105  this->Data[0] = red;
106  this->Data[1] = green;
107  this->Data[2] = blue;
108  }
110 
112 
113  void Set(const T& red, const T& green, const T& blue, const T& alpha)
114  {
115  this->Data[0] = red;
116  this->Data[1] = green;
117  this->Data[2] = blue;
118  this->Data[3] = alpha;
119  }
121 
123  void SetRed(const T& red) { this->Data[0] = red; }
124 
126 
127  const T& GetRed() const { return this->Data[0]; }
128  const T& Red() const { return this->Data[0]; }
130 
132  void SetGreen(const T& green) { this->Data[1] = green; }
133 
135 
136  const T& GetGreen() const { return this->Data[1]; }
137  const T& Green() const { return this->Data[1]; }
139 
141  void SetBlue(const T& blue) { this->Data[2] = blue; }
142 
144 
145  const T& GetBlue() const { return this->Data[2]; }
146  const T& Blue() const { return this->Data[2]; }
148 
150  void SetAlpha(const T& alpha) { this->Data[3] = alpha; }
151 
153 
154  const T& GetAlpha() const { return this->Data[3]; }
155  const T& Alpha() const { return this->Data[3]; }
156 };
158 
160 
162 class vtkColor3ub : public vtkColor3<unsigned char>
163 {
164 public:
165  vtkColor3ub(unsigned char r = 0, unsigned char g = 0,
166  unsigned char b = 0) : vtkColor3<unsigned char>(r, g, b) {}
167  explicit vtkColor3ub(const unsigned char* init)
168  : vtkColor3<unsigned char>(init) {}
169 };
171 
172 class vtkColor3f : public vtkColor3<float>
173 {
174 public:
175  vtkColor3f(float r = 0.0, float g = 0.0, float b = 0.0)
176  : vtkColor3<float>(r, g, b) {}
177  explicit vtkColor3f(const float* init) : vtkColor3<float>(init) {}
178 };
179 
180 class vtkColor3d : public vtkColor3<double>
181 {
182 public:
183  vtkColor3d(double r = 0.0, double g = 0.0, double b = 0.0)
184  : vtkColor3<double>(r, g, b) {}
185  explicit vtkColor3d(const double* init) : vtkColor3<double>(init) {}
186 };
187 
188 class vtkColor4ub : public vtkColor4<unsigned char>
189 {
190 public:
191  vtkColor4ub(unsigned char r = 0, unsigned char g = 0,
192  unsigned char b = 0, unsigned char a = 255)
193  : vtkColor4<unsigned char>(r, g, b, a) {}
194  explicit vtkColor4ub(const unsigned char* init)
195  : vtkColor4<unsigned char>(init) {}
197  vtkColor4<unsigned char>(c[0], c[1], c[2], 255) {}
198 };
199 
200 class vtkColor4f : public vtkColor4<float>
201 {
202 public:
203  vtkColor4f(float r = 0.0, float g = 0.0, float b = 0.0, float a = 1.0)
204  : vtkColor4<float>(r, g, b, a) {}
205  explicit vtkColor4f(const float* init) : vtkColor4<float>(init) {}
206 };
207 
208 class vtkColor4d : public vtkColor4<double>
209 {
210 public:
211  vtkColor4d(double r = 0.0, double g = 0.0, double b = 0.0, float a = 1.0)
212  : vtkColor4<double>(r, g, b, a) {}
213  explicit vtkColor4d(const double* init) : vtkColor4<double>(init) {}
214 };
215 
216 #endif // __vtkColor_h
const T & GetGreen() const
Definition: vtkColor.h:136
vtkColor3f(const float *init)
Definition: vtkColor.h:177
const T & Blue() const
Definition: vtkColor.h:79
void SetAlpha(const T &alpha)
Definition: vtkColor.h:150
const T & Alpha() const
Definition: vtkColor.h:155
const T & GetAlpha() const
Definition: vtkColor.h:154
vtkColor4ub(const vtkColor3ub &c)
Definition: vtkColor.h:196
void Set(const T &red, const T &green, const T &blue, const T &alpha)
Definition: vtkColor.h:113
vtkColor3(const T &red=0, const T &green=0, const T &blue=0)
Definition: vtkColor.h:35
const T & Blue() const
Definition: vtkColor.h:146
templated base type for storage of vectors.
Definition: vtkVector.h:34
void SetGreen(const T &green)
Definition: vtkColor.h:65
vtkColor3d(const double *init)
Definition: vtkColor.h:185
const T & Green() const
Definition: vtkColor.h:70
const T & GetBlue() const
Definition: vtkColor.h:78
vtkColor3d(double r=0.0, double g=0.0, double b=0.0)
Definition: vtkColor.h:183
void SetBlue(const T &blue)
Definition: vtkColor.h:141
vtkColor4f(float r=0.0, float g=0.0, float b=0.0, float a=1.0)
Definition: vtkColor.h:203
vtkColor4ub(const unsigned char *init)
Definition: vtkColor.h:194
const T & Red() const
Definition: vtkColor.h:128
const T & GetRed() const
Definition: vtkColor.h:60
void SetGreen(const T &green)
Definition: vtkColor.h:132
void SetRed(const T &red)
Definition: vtkColor.h:123
void SetRed(const T &red)
Definition: vtkColor.h:56
void Set(const T &red, const T &green, const T &blue)
Definition: vtkColor.h:47
vtkColor4(const T *init)
Definition: vtkColor.h:97
vtkColor3ub(const unsigned char *init)
Definition: vtkColor.h:167
vtkColor4d(double r=0.0, double g=0.0, double b=0.0, float a=1.0)
Definition: vtkColor.h:211
void Set(const T &red, const T &green, const T &blue)
Definition: vtkColor.h:103
vtkColor4f(const float *init)
Definition: vtkColor.h:205
vtkColor4ub(unsigned char r=0, unsigned char g=0, unsigned char b=0, unsigned char a=255)
Definition: vtkColor.h:191
vtkColor3f(float r=0.0, float g=0.0, float b=0.0)
Definition: vtkColor.h:175
const T & Green() const
Definition: vtkColor.h:137
void SetBlue(const T &blue)
Definition: vtkColor.h:74
vtkColor3ub(unsigned char r=0, unsigned char g=0, unsigned char b=0)
Definition: vtkColor.h:165
const T & GetBlue() const
Definition: vtkColor.h:145
vtkColor4(const T &red=0, const T &green=0, const T &blue=0, const T &alpha=0)
Definition: vtkColor.h:89
vtkColor3(const T *init)
Definition: vtkColor.h:41
vtkColor4d(const double *init)
Definition: vtkColor.h:213
const T & GetGreen() const
Definition: vtkColor.h:69
const T & Red() const
Definition: vtkColor.h:61
const T & GetRed() const
Definition: vtkColor.h:127