ACF $AcfVersion:0$
CHsv.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
181class CHsv: public TComposedColor<3>
182{
183public:
185
193
194 CHsv(double h = 0.0, double s = 0.0, double v = 0.0);
195 CHsv(const CHsv& color);
196 CHsv(const imath::CVarVector& vector);
197
198 // access to component values
199 double GetHue() const;
200 void SetHue(double value);
201 double GetSaturation() const;
202 void SetSaturation(double value);
203 double GetValue() const;
204 void SetValue(double value);
205
206 virtual bool Serialize(iser::IArchive& archive) override;
207
208 // operators
209 CHsv operator+(const CHsv& color) const;
210 CHsv operator-(const CHsv& color) const;
211 CHsv operator*(const CHsv& color) const;
212 CHsv operator/(const CHsv& color) const;
213
214 CHsv operator*(double value) const;
215 CHsv operator/(double value) const;
216
217 CHsv& operator=(const CHsv& color);
218
219 const CHsv& operator+=(const CHsv& color);
220 const CHsv& operator-=(const CHsv& color);
221 const CHsv& operator*=(const CHsv& color);
222 const CHsv& operator/=(const CHsv& color);
223
224 const CHsv& operator*=(double value);
225 const CHsv& operator/=(double value);
226};
227
228
229// inline methods
230
231inline CHsv::CHsv(double h, double s, double v)
232{
233 SetElement(CI_HUE, h);
236}
237
238
239inline CHsv::CHsv(const CHsv& color)
240: BaseClass(color)
241{
242}
243
244
245inline CHsv::CHsv(const imath::CVarVector& vector)
246: BaseClass(vector)
247{
248}
249
250
251// access to components
252
253inline double CHsv::GetHue() const
254{
255 return GetElement(CI_HUE);
256}
257
258
259inline void CHsv::SetHue(double value)
260{
261 SetElement(CI_HUE, value);
262}
263
264
265inline double CHsv::GetSaturation() const
266{
268}
269
270
271inline void CHsv::SetSaturation(double value)
272{
274}
275
276
277inline double CHsv::GetValue() const
278{
279 return GetElement(CI_VALUE);
280}
281
282
283inline void CHsv::SetValue(double value)
284{
285 SetElement(CI_VALUE, value);
286}
287
288
289// operators
290
291inline CHsv CHsv::operator+(const CHsv& color) const
292{
293 CHsv retVal = *this;
294
295 retVal += color;
296
297 return retVal;
298}
299
300
301inline CHsv CHsv::operator-(const CHsv& color) const
302{
303 CHsv retVal = *this;
304
305 retVal -= color;
306
307 return retVal;
308}
309
310
311inline CHsv CHsv::operator*(const CHsv& color) const
312{
313 CHsv retVal = *this;
314
315 retVal *= color;
316
317 return retVal;
318}
319
320
321inline CHsv CHsv::operator/(const CHsv& color) const
322{
323 CHsv retVal = *this;
324
325 retVal /= color;
326
327 return retVal;
328}
329
330
331inline CHsv CHsv::operator*(double value) const
332{
333 CHsv retVal = *this;
334
335 retVal *= value;
336
337 return retVal;
338}
339
340
341inline CHsv CHsv::operator/(double value) const
342{
343 CHsv retVal = *this;
344
345 retVal /= value;
346
347 return retVal;
348}
349
350
351inline CHsv& CHsv::operator=(const CHsv& color)
352{
354
355 return *this;
356}
357
358
359inline const CHsv& CHsv::operator+=(const CHsv& color)
360{
362
363 return *this;
364}
365
366
367inline const CHsv& CHsv::operator-=(const CHsv& color)
368{
370
371 return *this;
372}
373
374
375inline const CHsv& CHsv::operator*=(const CHsv& color)
376{
378
379 return *this;
380}
381
382
383inline const CHsv& CHsv::operator/=(const CHsv& color)
384{
386
387 return *this;
388}
389
390
391inline const CHsv& CHsv::operator*=(double value)
392{
394
395 return *this;
396}
397
398
399inline const CHsv& CHsv::operator/=(double value)
400{
402
403 return *this;
404}
405
406
407} // namespace icmm
408
409
Primitive for representation of HSV (Hue, Saturation, Value) color values.
Definition CHsv.h:182
const CHsv & operator*=(const CHsv &color)
Definition CHsv.h:375
ComponentIndex
Definition CHsv.h:187
@ CI_VALUE
Definition CHsv.h:190
@ CI_HUE
Definition CHsv.h:188
@ CI_LAST
Definition CHsv.h:191
@ CI_SATURATION
Definition CHsv.h:189
CHsv(double h=0.0, double s=0.0, double v=0.0)
Definition CHsv.h:231
double GetValue() const
Definition CHsv.h:277
CHsv operator+(const CHsv &color) const
Definition CHsv.h:291
const CHsv & operator-=(const CHsv &color)
Definition CHsv.h:367
const CHsv & operator/=(const CHsv &color)
Definition CHsv.h:383
const CHsv & operator+=(const CHsv &color)
Definition CHsv.h:359
double GetHue() const
Definition CHsv.h:253
CHsv operator*(const CHsv &color) const
Definition CHsv.h:311
void SetValue(double value)
Definition CHsv.h:283
double GetSaturation() const
Definition CHsv.h:265
virtual bool Serialize(iser::IArchive &archive) override
Load or store state of this object as a archive stream.
CHsv operator/(const CHsv &color) const
Definition CHsv.h:321
void SetHue(double value)
Definition CHsv.h:259
void SetSaturation(double value)
Definition CHsv.h:271
CHsv & operator=(const CHsv &color)
Definition CHsv.h:351
TComposedColor< 3 > BaseClass
Definition CHsv.h:184
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)
Implementation of variable-size mathematical vector with double precision elements.
Definition CVarVector.h:110
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.