template<class T = Float>
Color4 class
Color in linear RGBA color space.
Contents
See Color3 for more information.
Base classes
-
template<class T>class Vector4
- Four-component vector.
Public types
- using FloatingPointType = Color3<T>::FloatingPointType
- Corresponding floating-point type.
- using Hsv = Color3<T>::Hsv
- Type for storing HSV color space values.
- using HSV = Hsv deprecated
- Type for storing HSV color space values.
Public static functions
- static auto red(T red = Implementation::fullChannel<T>(), T alpha = Implementation::fullChannel<T>()) -> Color4<T> constexpr
- Red color.
- static auto green(T green = Implementation::fullChannel<T>(), T alpha = Implementation::fullChannel<T>()) -> Color4<T> constexpr
- Green color.
- static auto blue(T blue = Implementation::fullChannel<T>(), T alpha = Implementation::fullChannel<T>()) -> Color4<T> constexpr
- Blue color.
- static auto cyan(T red = T(0), T alpha = Implementation::fullChannel<T>()) -> Color4<T> constexpr
- Cyan color.
- static auto magenta(T green = T(0), T alpha = Implementation::fullChannel<T>()) -> Color4<T> constexpr
- Magenta color.
- static auto yellow(T blue = T(0), T alpha = Implementation::fullChannel<T>()) -> Color4<T> constexpr
- Yellow color.
- static auto fromHsv(const Hsv& hsv, T a = Implementation::fullChannel<T>()) -> Color4<T>
- Create RGB color from HSV representation.
- static auto fromHsv(Deg<FloatingPointType> hue, FloatingPointType saturation, FloatingPointType value, T alpha = Implementation::fullChannel<T>()) -> Color4<T>
- static auto fromHSV(const Hsv& hsv, T a = Implementation::fullChannel<T>()) -> Color4<T> deprecated
- Create RGB color from HSV representation.
- static auto fromHSV(Deg<FloatingPointType> hue, FloatingPointType saturation, FloatingPointType value, T a = Implementation::fullChannel<T>()) -> Color4<T> deprecated
- static auto fromSrgbAlpha(const Vector4<FloatingPointType>& srgbAlpha) -> Color4<T>
- Create linear RGBA color from sRGB + alpha representation.
- static auto fromSrgb(const Vector3<FloatingPointType>& srgb, T a = Implementation::fullChannel<T>()) -> Color4<T>
- Create linear RGBA color from sRGB representation.
-
template<class Integral>static auto fromSrgbAlpha(const Vector4<Integral>& srgbAlpha) -> Color4<T>
- Create linear RGB color from integral sRGB + alpha representation.
-
template<class Integral>static auto fromSrgb(const Vector3<Integral>& srgb, T a = Implementation::fullChannel<T>()) -> Color4<T>
- Create linear RGB color from integral sRGB representation.
- static auto fromXyz(const Vector3<FloatingPointType> xyz, T a = Implementation::fullChannel<T>()) -> Color4<T>
- Create RGBA color from CIE XYZ representation.
Constructors, destructors, conversion operators
- Color4() constexpr noexcept
- Default constructor.
- Color4(ZeroInitT) explicit constexpr noexcept
- Default constructor.
- Color4(NoInitT) explicit noexcept
- Construct vector without initializing the contents.
- Color4(T rgb, T alpha = Implementation::fullChannel<T>()) explicit constexpr noexcept
- Gray constructor.
- Color4(T r, T g, T b, T a = Implementation::fullChannel<T>()) constexpr noexcept
- Constructor.
- Color4(const Vector3<T>& rgb, T a = Implementation::fullChannel<T>()) constexpr noexcept
- Constructor.
-
template<class U>Color4(const Vector<4, U>& other) explicit constexpr noexcept
- Construct vector from another of different type.
-
template<class U, class V = decltype(Implementation::VectorConverter<4, T, U>::from(std::Color4(const U& other) explicit constexpr
declval<U>()))> - Construct color from external representation.
- Color4(const Vector<4, T>& other) constexpr noexcept
- Copy constructor.
Public functions
- auto toHsv() const -> Hsv
- Convert to HSV representation.
- auto toHSV() const -> Hsv deprecated
- Convert to HSV representation.
- auto hue() const -> Deg<FloatingPointType>
- Hue.
- auto saturation() const -> FloatingPointType
- Saturation.
- auto value() const -> FloatingPointType
- Value.
- auto toSrgbAlpha() const -> Vector4<FloatingPointType>
- Convert to sRGB + alpha representation.
-
template<class Integral>auto toSrgbAlpha() const -> Vector4<Integral>
- Convert to integral sRGB + alpha representation.
- auto toXyz() const -> Vector3<FloatingPointType>
- Convert to CIE XYZ representation.
Typedef documentation
template<class T>
typedef Color3<T>::FloatingPointType Magnum:: Math:: Color4<T>:: FloatingPointType
Corresponding floating-point type.
For HSV and other color spaces.
Function documentation
template<class T>
static Color4<T> Magnum:: Math:: Color4<T>:: fromHsv(const Hsv& hsv,
T a = Implementation::fullChannel<T>())
Create RGB color from HSV representation.
Parameters | |
---|---|
hsv | Color in HSV color space |
a | Alpha value, defaults to 1.0 for floating-point types and maximum positive value for integral types |
Hue can overflow the range .
template<class T>
static Color4<T> Magnum:: Math:: Color4<T>:: fromHsv(Deg<FloatingPointType> hue,
FloatingPointType saturation,
FloatingPointType value,
T alpha = Implementation::fullChannel<T>())
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
template<class T>
static Color4<T> Magnum:: Math:: Color4<T>:: fromHSV(Deg<FloatingPointType> hue,
FloatingPointType saturation,
FloatingPointType value,
T a = Implementation::fullChannel<T>())
template<class T>
static Color4<T> Magnum:: Math:: Color4<T>:: fromSrgbAlpha(const Vector4<FloatingPointType>& srgbAlpha)
Create linear RGBA color from sRGB + alpha representation.
Parameters | |
---|---|
srgbAlpha | Color in sRGB color space with linear alpha |
Applies inverse sRGB curve onto RGB channels of the input, alpha channel is assumed to be linear. See Color3::
template<class T>
static Color4<T> Magnum:: Math:: Color4<T>:: fromSrgb(const Vector3<FloatingPointType>& srgb,
T a = Implementation::fullChannel<T>())
Create linear RGBA color from sRGB representation.
Parameters | |
---|---|
srgb | Color in sRGB color space |
a | Alpha value, defaults to 1.0 for floating-point types and maximum positive value for integral types |
Applies inverse sRGB curve onto RGB channels of the input. Alpha value is taken as-is. See Color3::
template<class T>
template<class Integral>
static Color4<T> Magnum:: Math:: Color4<T>:: fromSrgbAlpha(const Vector4<Integral>& srgbAlpha)
Create linear RGB color from integral sRGB + alpha representation.
Parameters | |
---|---|
srgbAlpha | Color in sRGB color space with linear alpha |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Useful in cases where you have for example an 8-bit sRGB + alpha representation and want to create a floating-point linear RGBA color out of it:
Math::Vector4<UnsignedByte> srgbAlpha; auto rgba = Color4::fromSrgbAlpha(srgbAlpha);
template<class T>
template<class Integral>
static Color4<T> Magnum:: Math:: Color4<T>:: fromSrgb(const Vector3<Integral>& srgb,
T a = Implementation::fullChannel<T>())
Create linear RGB color from integral sRGB representation.
Parameters | |
---|---|
srgb | Color in sRGB color space |
a | Alpha value, defaults to 1.0 for floating-point types and maximum positive value for integral types |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Useful in cases where you have for example an 8-bit sRGB representation and want to create a floating-point linear RGBA color out of it:
Math::Vector3<UnsignedByte> srgb; auto rgba = Color4::fromSrgb(srgb);
template<class T>
static Color4<T> Magnum:: Math:: Color4<T>:: fromXyz(const Vector3<FloatingPointType> xyz,
T a = Implementation::fullChannel<T>())
Create RGBA color from CIE XYZ representation.
Parameters | |
---|---|
xyz | Color in CIE XYZ color space |
a | Alpha value, defaults to 1.0 for floating-point types and maximum positive value for integral types |
Applies transformation matrix, returning the input in linear RGB color space. See Color3::
template<class T>
Magnum:: Math:: Color4<T>:: Color4() constexpr noexcept
Default constructor.
All components are set to zero.
template<class T>
Magnum:: Math:: Color4<T>:: Color4(T rgb,
T alpha = Implementation::fullChannel<T>()) explicit constexpr noexcept
Gray constructor.
Parameters | |
---|---|
rgb | RGB value |
alpha | Alpha value, defaults to 1.0 for floating-point types and maximum positive value for integral types |
template<class T>
Magnum:: Math:: Color4<T>:: Color4(T r,
T g,
T b,
T a = Implementation::fullChannel<T>()) constexpr noexcept
Constructor.
Parameters | |
---|---|
r | R value |
g | G value |
b | B value |
a | A value, defaults to 1.0 for floating-point types and maximum positive value for integral types. |
template<class T>
template<class U>
Magnum:: Math:: Color4<T>:: Color4(const Vector<4, U>& other) explicit constexpr noexcept
Construct vector from another of different type.
Performs only default casting on the values, no rounding or anything else. Example usage:
Vector<4, Float> floatingPoint(1.3f, 2.7f, -15.0f, 7.0f); Vector<4, Byte> integral(floatingPoint); // integral == {1, 2, -15, 7}
template<class T>
Deg<FloatingPointType> Magnum:: Math:: Color4<T>:: hue() const
Hue.
Returns | Hue in range . |
---|
template<class T>
FloatingPointType Magnum:: Math:: Color4<T>:: saturation() const
Saturation.
Returns | Saturation in range . |
---|
template<class T>
FloatingPointType Magnum:: Math:: Color4<T>:: value() const
Value.
Returns | Value in range . |
---|
template<class T>
Vector4<FloatingPointType> Magnum:: Math:: Color4<T>:: toSrgbAlpha() const
Convert to sRGB + alpha representation.
Assuming the color is in linear RGB, applies sRGB curve onto the RGB channels, returning the color represented in sRGB color space. Alpha channel is kept linear. See Color3::
template<class T>
template<class Integral>
Vector4<Integral> Magnum:: Math:: Color4<T>:: toSrgbAlpha() const
Convert to integral sRGB + alpha representation.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Useful in cases where you have a floating-point linear RGBA color and want to create for example an 8-bit sRGB + alpha representation out of it:
Color4 color; Math::Vector4<UnsignedByte> srgbAlpha = color.toSrgbAlpha<UnsignedByte>();
template<class T>
Vector3<FloatingPointType> Magnum:: Math:: Color4<T>:: toXyz() const
Convert to CIE XYZ representation.
Assuming the color is in linear RGB, applies transformation matrix, returning the color in CIE XYZ color space. The alpha channel is not subject to any conversion, so it is ignored. See Color3::
Please note that xyz(), x(), y() and z() do not correspond to primaries in CIE XYZ color space, but are rather aliases to rgb(), r(), g() and b().
template<class T>
Color4<UnsignedByte> operator"" _rgba(unsigned long long value) constexpr
8bit-per-channel linear RGBA literal
Unpacks the literal into four 8-bit values. Example usage:
Color4ub a = 0x33b27fcc_rgba; // {0x33, 0xb2, 0x7f, 0xcc}
template<class T>
Vector4<UnsignedByte> operator"" _srgba(unsigned long long value) constexpr
8bit-per-channel sRGB + alpha literal
Unpacks the literal into four 8-bit values without any colorspace conversion. Behaves identically to operator""_
Math::Vector4<UnsignedByte> a = 0x33b27fcc_srgba; // {0x33, 0xb2, 0x7f, 0xcc}
template<class T>
Color4<Float> operator"" _rgbaf(unsigned long long value)
Float linear RGBA literal.
Unpacks the 8-bit values into four floats. Example usage:
Color4 a = 0x33b27fcc_rgbaf; // {0.2f, 0.698039f, 0.498039f, 0.8f}
template<class T>
Color4<Float> operator"" _srgbaf(unsigned long long value)
Float sRGB + alpha literal.
Unpacks the 8-bit values into four floats and converts the color space from sRGB + alpha to linear RGBA. See Color4::
Color4 a = 0x33b27fcc_srgbaf; // {0.0331048f, 0.445201f, 0.212231f, 0.8f}
template<class T>
Corrade:: Utility:: Debug& operator<<(Corrade:: Utility:: Debug& debug,
const Color4<UnsignedByte>& value)
Debug output operator.
Prints the value as hex color (e.g. #9933aaff
). Other underlying types are handled by operator<<(Corrade::