Color3¶
The Color3
class template represents a 3-component color, with
pre-defined typedefs of unsigned char
, half
, and float
.
The Color3
class inherits from Vec3
and thus has
fields named x
, y
, and z
. The class itself implies no
specific interpretation of the values.
There are also various utility functions that operate on colors
defined in ImathColorAlgo.h
and described in Color Functions.
Example:
#include <Imath/ImathColor.h>
#include <cassert>
void
color3_example()
{
Imath::C3c r (255, 0, 0);
Imath::C3c g (0, 255, 0);
Imath::C3c b (0, 0, 255);
Imath::C3c c = r + g + b;
assert (c.x == 255);
assert (c.x == 255);
assert (c.x == 255);
}
-
typedef Color3<unsigned char>
Imath
::
Color3c
¶ 3 8-bit integer channels
-
typedef Color3<float>
Imath
::
Color3f
¶ 3 float channels
-
typedef Color3<unsigned char>
Imath
::
C3c
¶ 3 8-bit integer channels
-
typedef Color3<float>
Imath
::
C3f
¶ 3 float channels
-
template<class
T
>
classColor3
: public Imath::Vec3<T>¶ 3-channel color class that inherits from Vec3.
This class does not impose interpretation on the channels, which can represent either rgb or hsv color values.
Note: because Color3 inherits from Vec3, its member fields are called
x
,y
, andz
.Constructors and Assignemt
-
Color3
()¶ No initialization by default.
-
constexpr
Color3
(T a)¶ Initialize to (a a a)
-
constexpr
Color3
(T a, T b, T c)¶ Initialize to (a b c)
-
~Color3
()¶ Destructor.
-
constexpr const Color3<T> &
operator=
(const Color3 &c)¶ Component-wise assignment.
Arithmetic
-
constexpr const Color3<T> &
operator+=
(const Color3 &c)¶ Component-wise addition.
-
constexpr Color3<T>
operator+
(const Color3 &c) const¶ Component-wise addition.
-
constexpr const Color3<T> &
operator-=
(const Color3 &c)¶ Component-wise subtraction.
-
constexpr Color3<T>
operator-
(const Color3 &c) const¶ Component-wise subtraction.
-
constexpr Color3<T>
operator-
() const¶ Component-wise multiplication by -1.
-
constexpr const Color3<T> &
negate
()¶ Component-wise multiplication by -1.
-
constexpr const Color3<T> &
operator*=
(const Color3 &c)¶ Component-wise multiplication.
-
constexpr const Color3<T> &
operator*=
(T a)¶ Component-wise multiplication.
-
constexpr Color3<T>
operator*
(const Color3 &c) const¶ Component-wise multiplication.
-
constexpr Color3<T>
operator*
(T a) const¶ Component-wise multiplication.
-
constexpr const Color3<T> &
operator/=
(const Color3 &c)¶ Component-wise division.
-
constexpr const Color3<T> &
operator/=
(T a)¶ Component-wise division.
-
constexpr Color3<T>
operator/
(const Color3 &c) const¶ Component-wise division.
-
constexpr Color3<T>
operator/
(T a) const¶ Component-wise division.
-