ACF $AcfVersion:0$
CRgb.h
Go to the documentation of this file.
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ACF-Commercial
2#pragma once
3
4
5// ACF includes
6#include <iser/IArchive.h>
8
9
10namespace icmm
11{
12
13
167class CRgb: public TComposedColor<3>
168{
169public:
171
179
180 CRgb(double r = 0.0, double g = 0.0, double b = 0.0);
181 CRgb(const CRgb& color);
182
183 // access to component values
184 double GetRed() const;
185 void SetRed(double value);
186 double GetGreen() const;
187 void SetGreen(double value);
188 double GetBlue() const;
189 void SetBlue(double value);
190
191 virtual bool Serialize(iser::IArchive& archive) override;
192
193 // operators
194 CRgb operator+(const CRgb& color) const;
195 CRgb operator-(const CRgb& color) const;
196 CRgb operator*(const CRgb& color) const;
197 CRgb operator/(const CRgb& color) const;
198
199 CRgb operator*(double value) const;
200 CRgb operator/(double value) const;
201
202 CRgb& operator=(const CRgb& color);
203
204 const CRgb& operator+=(const CRgb& color);
205 const CRgb& operator-=(const CRgb& color);
206 const CRgb& operator*=(const CRgb& color);
207 const CRgb& operator/=(const CRgb& color);
208
209 const CRgb& operator*=(double value);
210 const CRgb& operator/=(double value);
211};
212
213
214// inline methods
215
216inline CRgb::CRgb(double r, double g, double b)
217{
218 SetElement(CI_RED, r);
221}
222
223
224inline CRgb::CRgb(const CRgb& color)
225: BaseClass(color)
226{
227}
228
229
230// access to components
231
232inline double CRgb::GetRed() const
233{
234 return GetElement(CI_RED);
235}
236
237
238inline void CRgb::SetRed(double value)
239{
240 SetElement(CI_RED, value);
241}
242
243
244inline double CRgb::GetGreen() const
245{
246 return GetElement(CI_GREEN);
247}
248
249
250inline void CRgb::SetGreen(double value)
251{
252 SetElement(CI_GREEN, value);
253}
254
255
256inline double CRgb::GetBlue() const
257{
258 return GetElement(CI_BLUE);
259}
260
261
262inline void CRgb::SetBlue(double value)
263{
264 SetElement(CI_BLUE, value);
265}
266
267
268// operators
269
270inline CRgb CRgb::operator+(const CRgb& color) const
271{
272 CRgb retVal = *this;
273
274 retVal += color;
275
276 return retVal;
277}
278
279
280inline CRgb CRgb::operator-(const CRgb& color) const
281{
282 CRgb retVal = *this;
283
284 retVal -= color;
285
286 return retVal;
287}
288
289
290inline CRgb CRgb::operator*(const CRgb& color) const
291{
292 CRgb retVal = *this;
293
294 retVal *= color;
295
296 return retVal;
297}
298
299
300inline CRgb CRgb::operator/(const CRgb& color) const
301{
302 CRgb retVal = *this;
303
304 retVal /= color;
305
306 return retVal;
307}
308
309
310inline CRgb CRgb::operator*(double value) const
311{
312 CRgb retVal = *this;
313
314 retVal *= value;
315
316 return retVal;
317}
318
319
320inline CRgb CRgb::operator/(double value) const
321{
322 CRgb retVal = *this;
323
324 retVal /= value;
325
326 return retVal;
327}
328
329
330inline CRgb& CRgb::operator=(const CRgb& color)
331{
333
334 return *this;
335}
336
337
338inline const CRgb& CRgb::operator+=(const CRgb& color)
339{
341
342 return *this;
343}
344
345
346inline const CRgb& CRgb::operator-=(const CRgb& color)
347{
349
350 return *this;
351}
352
353
354inline const CRgb& CRgb::operator*=(const CRgb& color)
355{
357
358 return *this;
359}
360
361
362inline const CRgb& CRgb::operator/=(const CRgb& color)
363{
365
366 return *this;
367}
368
369
370inline const CRgb& CRgb::operator*=(double value)
371{
373
374 return *this;
375}
376
377
378inline const CRgb& CRgb::operator/=(double value)
379{
381
382 return *this;
383}
384
385
386} // namespace icmm
387
388
Primitive for representation of RGB color values.
Definition CRgb.h:168
const CRgb & operator*=(const CRgb &color)
Definition CRgb.h:354
CRgb operator*(const CRgb &color) const
Definition CRgb.h:290
double GetBlue() const
Definition CRgb.h:256
CRgb(double r=0.0, double g=0.0, double b=0.0)
Definition CRgb.h:216
void SetBlue(double value)
Definition CRgb.h:262
const CRgb & operator+=(const CRgb &color)
Definition CRgb.h:338
TComposedColor< 3 > BaseClass
Definition CRgb.h:170
const CRgb & operator/=(const CRgb &color)
Definition CRgb.h:362
CRgb & operator=(const CRgb &color)
Definition CRgb.h:330
ComponentIndex
Definition CRgb.h:173
@ CI_RED
Definition CRgb.h:174
@ CI_GREEN
Definition CRgb.h:175
@ CI_LAST
Definition CRgb.h:177
@ CI_BLUE
Definition CRgb.h:176
virtual bool Serialize(iser::IArchive &archive) override
Load or store state of this object as a archive stream.
void SetGreen(double value)
Definition CRgb.h:250
double GetGreen() const
Definition CRgb.h:244
const CRgb & operator-=(const CRgb &color)
Definition CRgb.h:346
double GetRed() const
Definition CRgb.h:232
CRgb operator+(const CRgb &color) const
Definition CRgb.h:270
void SetRed(double value)
Definition CRgb.h:238
CRgb operator/(const CRgb &color) const
Definition CRgb.h:300
Generic fixed-size color implementation template.
const TComposedColor< Size > & operator=(const TComposedColor< Size > &color)
const TComposedColor< Size > & operator+=(const TComposedColor< Size > &color)
const TComposedColor< Size > & operator-=(const TComposedColor< Size > &color)
const TComposedColor< Size > & operator*=(const TComposedColor< Size > &color)
const TComposedColor< Size > & operator/=(const TComposedColor< Size > &color)
TVector< Size, Element > operator-() const
Definition TVector.h:817
void SetElement(int i, const Element &value)
Sets the element at the specified index.
Definition TVector.h:560
const Element & GetElement(int i) const
Gets the element at the specified index (read-only).
Definition TVector.h:546
Represents an input/output persistence archive for object serialization.
Definition IArchive.h:164
Contains color management classes.