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>
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<half>
Imath::Color3h
3 half channels
-
typedef Color3<float>
Imath::Color3f
3 float channels
-
typedef Color3<unsigned char>
Imath::C3c
3 8-bit integer channels
-
typedef Color3<half>
Imath::C3h
3 half channels
-
typedef Color3<float>
Imath::C3f
3 float channels
-
template <class T>
class Color3 : 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, and z.
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)
-
constexpr
Color3(const Color3 &c)
Construct from Color3.
-
template <class S>
constexpr Color3(const Vec3<S> &v)
Construct from Vec3.
-
~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.