Color4¶
The Color4 class template represents a 4-component color (red,
green, blue, and alpha), with pre-defined typedefs of unsigned
char, half, and float.
The Color4 class is not derived from Vec4. Its fields are
named r, g, b, and a. 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
color4_example()
{
Imath::C4f r (1.0f, 0.0f, 0.0f, 1.0f);
Imath::C4f g (0.0f, 1.0f, 0.0f, 1.0f);
Imath::C4f b (0.0f, 0.0f, 1.0f, 1.0f);
Imath::C4f w = r + g + b;
assert (w.r == 1.0f);
assert (w.g == 1.0f);
assert (w.b == 1.0f);
assert (w.a == 3.0f);
}
-
typedef Color4<unsigned char>
Imath::Color4c¶ 4 8-bit integer channels
-
typedef Color4<float>
Imath::Color4f¶ 4 float channels
-
typedef Color4<unsigned char>
Imath::C4c¶ 4 8-bit integer channels
-
typedef Color4<float>
Imath::C4f¶ 4 float channels
-
template<class
T>
classColor4¶ A 4-channel color class: 3 channels plus alpha.
For convenience, the fields are named
r,g, andb, although this class does not impose interpretation on the channels, which can represent either rgb or hsv color values.Constructors and Assignment
-
Color4()¶ No initialization by default.
-
constexpr
Color4(T a)¶ Initialize to
(a a a a)
-
constexpr
Color4(T a, T b, T c, T d)¶ Initialize to
(a b c d)
-
~Color4()¶ Destructor.
-
constexpr const Color4<T> &
operator=(const Color4 &v)¶ Assignment.
-
T &
operator[](int i)¶ Component-wise value.
-
const T &
operator[](int i) const¶ Component-wise value.
Arithmetic and Comparison
-
constexpr const Color4<T> &
operator+=(const Color4 &v)¶ Component-wise addition.
-
constexpr Color4<T>
operator+(const Color4 &v) const¶ Component-wise addition.
-
constexpr const Color4<T> &
operator-=(const Color4 &v)¶ Component-wise subtraction.
-
constexpr Color4<T>
operator-(const Color4 &v) const¶ Component-wise subtraction.
-
constexpr Color4<T>
operator-() const¶ Component-wise multiplication by -1.
-
constexpr const Color4<T> &
negate()¶ Component-wise multiplication by -1.
-
constexpr const Color4<T> &
operator*=(const Color4 &v)¶ Component-wise multiplication.
-
constexpr const Color4<T> &
operator*=(T a)¶ Component-wise multiplication.
-
constexpr Color4<T>
operator*(const Color4 &v) const¶ Component-wise multiplication.
-
constexpr Color4<T>
operator*(T a) const¶ Component-wise multiplication.
-
constexpr const Color4<T> &
operator/=(const Color4 &v)¶ Component-wise division.
-
constexpr const Color4<T> &
operator/=(T a)¶ Component-wise division.
-
constexpr Color4<T>
operator/(const Color4 &v) const¶ Component-wise division.
-
constexpr Color4<T>
operator/(T a) const¶ Component-wise division.
Compatibilty with Sb
-
T *
getValue()¶ Return raw pointer to the value.
-
const T *
getValue() const¶ Return raw pointer to the value.
Numeric Limits
-
static constexpr T
baseTypeLowest()¶ Largest possible negative value.
-
static constexpr T
baseTypeMax()¶ Largest possible positive value.
-
static constexpr T
baseTypeSmallest()¶ Smallest possible positive value.
-
static constexpr T
baseTypeEpsilon()¶ Smallest possible e for which 1+e != 1.
-
Warning
doxygenfunction: Unable to resolve multiple matches for function “operator<<” with arguments (std::ostream& s, const Color4<T>& v) in doxygen xml output for project “Imath” from directory: /build/ilmbase-2t9TFS/ilmbase-3.1.12/obj-x86_64-linux-gnu/website/doxygen/xml. Potential matches:
- std::ostream &operator<<(std::ostream&, Imath::half)
- template<class T>
std::ostream &Imath::operator<<(std::ostream&, const Color4<T>&)
- template<class T>
std::ostream &Imath::operator<<(std::ostream&, const Euler<T>&)
- template<class T>
std::ostream &Imath::operator<<(std::ostream&, const Interval<T>&)
- template<class T>
std::ostream &Imath::operator<<(std::ostream&, const Line3<T>&)
- template<class T>
std::ostream &Imath::operator<<(std::ostream&, const Matrix22<T>&)
- template<class T>
std::ostream &Imath::operator<<(std::ostream&, const Matrix33<T>&)
- template<class T>
std::ostream &Imath::operator<<(std::ostream&, const Matrix44<T>&)
- template<class T>
std::ostream &Imath::operator<<(std::ostream&, const Plane3<T>&)
- template<class T>
std::ostream &Imath::operator<<(std::ostream&, const Quat<T>&)
- template<class T>
std::ostream &Imath::operator<<(std::ostream&, const Shear6<T>&)
- template<class T>
std::ostream &Imath::operator<<(std::ostream&, const Vec2<T>&)
- template<class T>
std::ostream &Imath::operator<<(std::ostream&, const Vec3<T>&)
- template<class T>
std::ostream &Imath::operator<<(std::ostream&, const Vec4<T>&)