Coin  4.0.3
Coin3D core library
Loading...
Searching...
No Matches
SbColor4f.h
1#ifndef COIN_SBCOLOR4F_H
2#define COIN_SBCOLOR4F_H
3
4/**************************************************************************\
5 * Copyright (c) Kongsberg Oil & Gas Technologies AS
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
10 * met:
11 *
12 * Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * Neither the name of the copyright holder nor the names of its
20 * contributors may be used to endorse or promote products derived from
21 * this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34\**************************************************************************/
35
36#include <Inventor/system/inttypes.h>
37#include <Inventor/SbVec4f.h>
38#include <Inventor/SbColor.h>
39
40class SbVec4f;
41
43public:
44 SbColor4f(void);
45 SbColor4f(const SbColor &rgb, const float alpha = 1.0f);
46 SbColor4f(const SbVec4f& v);
47 SbColor4f(const float* const rgba);
48 SbColor4f(const float r, const float g, const float b, const float a = 1.0f);
49
50 void setValue(const float r, const float g, const float b,
51 const float a = 1.0f);
52 void setValue(const float col[4]);
53 const float *getValue() const;
54 void getValue(float &r, float &g, float &b, float &a);
55
56 SbColor4f& setRGB(const SbColor &col);
57 void getRGB(SbColor &color);
58 SbColor4f& setHSVValue(float h, float s, float v, float a = 1.0f);
59 SbColor4f& setHSVValue(const float hsv[3], float alpha = 1.0f);
60 void getHSVValue(float &h, float &s, float &v) const;
61 void getHSVValue(float hsv[3]) const;
62 SbColor4f& setPackedValue(const uint32_t rgba);
63 uint32_t getPackedValue() const;
64
65 float operator[](const int idx) const;
66 float &operator[](const int idx);
67
68 SbColor4f &operator*=(const float d);
69 SbColor4f &operator/=(const float d);
70 SbColor4f &operator+=(const SbColor4f &c);
71 SbColor4f &operator-=(const SbColor4f &c);
72
73 friend COIN_DLL_API SbColor4f operator *(const SbColor4f &c, const float d);
74 friend COIN_DLL_API SbColor4f operator *(const float d, const SbColor4f &c);
75 friend COIN_DLL_API SbColor4f operator /(const SbColor4f &c, const float d);
78 friend COIN_DLL_API int operator ==(const SbColor4f &v1, const SbColor4f &v2);
79 friend COIN_DLL_API int operator !=(const SbColor4f &v1, const SbColor4f &v2);
80
81private:
82 float red() const { return this->vec[0]; }
83 float green() const { return this->vec[1]; }
84 float blue() const { return this->vec[2]; }
85 float alpha() const { return this->vec[3]; }
86};
87
88COIN_DLL_API SbColor4f operator *(const SbColor4f &c, const float d);
89COIN_DLL_API SbColor4f operator *(const float d, const SbColor4f &c);
90COIN_DLL_API SbColor4f operator /(const SbColor4f &c, const float d);
95
96typedef class SbColor4f SbColorRGBA; // TGS compatibility
97
98#endif // !COIN_SBCOLOR4F_H
The SbColor4f class contains the red, green, blue and alpha components which make up a color value.
Definition SbColor4f.h:42
The SbColor class contains the red, green and blue components which make up a color value.
Definition SbColor.h:39
The SbList class is a template container class for lists.
Definition SbList.h:70
int operator!=(const SbList< Type > &l) const
Definition SbList.h:217
int operator==(const SbList< Type > &l) const
Definition SbList.h:209
Type operator[](const int index) const
Definition SbList.h:195
The SbVec4f class is a 4 dimensional vector with floating point coordinates.
Definition SbVec4f.h:49