ACF $AcfVersion:0$
CLab.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
214class CLab: public TComposedColor<3>
215{
216public:
218
225
226 CLab(double l = 0.0, double a = 0.0, double b = 0.0);
227 CLab(const CLab& color);
228
229 // access to component values
230 double GetL() const;
231 void SetL(double value);
232 double GetA() const;
233 void SetA(double value);
234 double GetB() const;
235 void SetB(double value);
236
237 virtual bool Serialize(iser::IArchive& archive) override;
238
239 double GetDeltaE(const CLab& lab) const;
240
241 // operators
242 CLab operator+(const CLab& color) const;
243 CLab operator-(const CLab& color) const;
244 CLab operator*(const CLab& color) const;
245 CLab operator/(const CLab& color) const;
246
247 CLab operator*(double value) const;
248 CLab operator/(double value) const;
249
250 CLab& operator=(const CLab& color);
251
252 const CLab& operator+=(const CLab& color);
253 const CLab& operator-=(const CLab& color);
254 const CLab& operator*=(const CLab& color);
255 const CLab& operator/=(const CLab& color);
256
257 const CLab& operator*=(double value);
258 const CLab& operator/=(double value);
259};
260
261
262// inline methods
263
264inline CLab::CLab(double l, double a, double b)
265{
266 SetElement(CI_L, l);
267 SetElement(CI_A, a);
268 SetElement(CI_B, b);
269}
270
271
272inline CLab::CLab(const CLab& color)
273: BaseClass(color)
274{
275}
276
277
278// access to components
279
280inline double CLab::GetL() const
281{
282 return GetElement(CI_L);
283}
284
285
286inline void CLab::SetL(double value)
287{
288 SetElement(CI_L, value);
289}
290
291
292inline double CLab::GetA() const
293{
294 return GetElement(CI_A);
295}
296
297
298inline void CLab::SetA(double value)
299{
300 SetElement(CI_A, value);
301}
302
303
304inline double CLab::GetB() const
305{
306 return GetElement(CI_B);
307}
308
309
310inline void CLab::SetB(double value)
311{
312 SetElement(CI_B, value);
313}
314
315
316// operators
317
318inline CLab CLab::operator+(const CLab& color) const
319{
320 CLab retVal = *this;
321
322 retVal += color;
323
324 return retVal;
325}
326
327
328inline CLab CLab::operator-(const CLab& color) const
329{
330 CLab retVal = *this;
331
332 retVal -= color;
333
334 return retVal;
335}
336
337
338inline CLab CLab::operator*(const CLab& color) const
339{
340 CLab retVal = *this;
341
342 retVal *= color;
343
344 return retVal;
345}
346
347
348inline CLab CLab::operator/(const CLab& color) const
349{
350 CLab retVal = *this;
351
352 retVal /= color;
353
354 return retVal;
355}
356
357
358inline CLab CLab::operator*(double value) const
359{
360 CLab retVal = *this;
361
362 retVal *= value;
363
364 return retVal;
365}
366
367
368inline CLab CLab::operator/(double value) const
369{
370 CLab retVal = *this;
371
372 retVal /= value;
373
374 return retVal;
375}
376
377
378inline CLab& CLab::operator=(const CLab& color)
379{
381
382 return *this;
383}
384
385
386inline const CLab& CLab::operator+=(const CLab& color)
387{
389
390 return *this;
391}
392
393
394inline const CLab& CLab::operator-=(const CLab& color)
395{
397
398 return *this;
399}
400
401
402inline const CLab& CLab::operator*=(const CLab& color)
403{
405
406 return *this;
407}
408
409
410inline const CLab& CLab::operator/=(const CLab& color)
411{
413
414 return *this;
415}
416
417
418inline const CLab& CLab::operator*=(double value)
419{
421
422 return *this;
423}
424
425
426inline const CLab& CLab::operator/=(double value)
427{
429
430 return *this;
431}
432
433
434} // namespace icmm
435
436
Primitive for representation of CIE Lab color values.
Definition CLab.h:215
double GetA() const
Definition CLab.h:292
const CLab & operator+=(const CLab &color)
Definition CLab.h:386
const CLab & operator-=(const CLab &color)
Definition CLab.h:394
double GetB() const
Definition CLab.h:304
virtual bool Serialize(iser::IArchive &archive) override
Load or store state of this object as a archive stream.
const CLab & operator/=(const CLab &color)
Definition CLab.h:410
CLab & operator=(const CLab &color)
Definition CLab.h:378
TComposedColor< 3 > BaseClass
Definition CLab.h:217
double GetL() const
Definition CLab.h:280
CLab operator/(const CLab &color) const
Definition CLab.h:348
void SetL(double value)
Definition CLab.h:286
ComponentIndex
Definition CLab.h:220
void SetB(double value)
Definition CLab.h:310
CLab operator+(const CLab &color) const
Definition CLab.h:318
CLab operator*(const CLab &color) const
Definition CLab.h:338
double GetDeltaE(const CLab &lab) const
void SetA(double value)
Definition CLab.h:298
CLab(double l=0.0, double a=0.0, double b=0.0)
Definition CLab.h:264
const CLab & operator*=(const CLab &color)
Definition CLab.h:402
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.