#include <Magnum/Math/Color.h>
          template<class T = Float>
          Color4 class
        
        Color in linear RGBA color space.
See Color3 for more information.
Base classes
- 
              template<class T>class Vector4<Float>
- Four-component vector.
Public types
- using FloatingPointType = Color3<T>::FloatingPointType
- Corresponding floating-point type.
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 ColorHsv<FloatingPointType>& hsv, T a = Implementation::fullChannel<T>()) -> Color4<T>
- Create RGB color from HSV representation.
- static auto fromSrgbAlpha(const Vector4<FloatingPointType>& srgbAlpha) -> Color4<T>
- Create linear RGBA color from sRGB + alpha representation.
- 
              template<class Integral>static auto fromSrgbAlpha(const Vector4<Integral>& srgbAlpha) -> Color4<T>
- Create linear RGB color from integral 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 fromSrgb(const Vector3<Integral>& srgb, T a = Implementation::fullChannel<T>()) -> Color4<T>
- Create linear RGB color from integral sRGB representation.
- static auto fromSrgbAlphaInt(UnsignedInt srgbAlpha) -> Color4<T> new in Git master
- Create linear RGBA color from 32-bit sRGB + alpha representation.
- static auto fromSrgbAlpha(UnsignedInt srgb) -> Color4<T> deprecated in Git master
- Create linear RGBA color from 32-bit sRGB + alpha representation.
- static auto fromSrgbInt(UnsignedInt srgb, T a = Implementation::fullChannel<T>()) -> Color4<T>
- Create linear RGBA color from 24-bit sRGB + alpha representation.
- static auto fromSrgb(UnsignedInt srgb, T a = Implementation::fullChannel<T>()) -> Color4<T> deprecated in Git master
- Create linear RGBA color from 24-bit sRGB + alpha representation.
- static auto fromLinearRgbaInt(UnsignedInt linear) -> Color4<T> new in Git master
- Create linear RGBA color from 32-bit linear representation.
- static auto fromLinearRgbInt(UnsignedInt linear, T a = Implementation::fullChannel<T>()) -> Color4<T> new in Git master
- Create linear RGBA color from 24-bit linear RGB + alpha 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
- Construct a zero color.
- 
              Color4(Magnum::NoInitT) explicit noexcept 
- Construct a 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<std::Color4(const T(&data)[size_]) explicit constexpr noexcept new in Git mastersize_t size_> 
- Construct a vector from a fixed-size array.
- 
              template<class U>Color4(const Vector<4, U>& other) explicit constexpr noexcept
- Construct a vector from another of different type.
- Color4(const BitVector4& other) explicit constexpr noexcept new in Git master
- Construct a vector from a BitVector.
- 
              template<class U, class = decltype(Implementation::VectorConverter<4, T, U>::from(std::Color4(const U& other) explicit constexprdeclval<U>()))> 
- Construct a color from external representation.
- Color4(const Vector<4, T>& other) constexpr noexcept
- Copy constructor.
Public functions
- auto toHsv() const -> ColorHsv<FloatingPointType>
- 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 toSrgbAlphaInt() const -> UnsignedInt
- Convert to 32-bit integral sRGB + linear alpha representation.
- auto toLinearRgbaInt() const -> UnsignedInt
- Convert to 32-bit integral linear RGBA representation.
- auto toXyz() const -> Vector3<FloatingPointType>
- Convert to CIE XYZ representation
- auto premultiplied() const -> Color4<T> constexpr new in Git master
- Color with premultiplied alpha.
- auto unpremultiplied() const -> Color4<T> constexpr new in Git master
- Color with unpremultiplied alpha.
Typedef documentation
              
                template<class T>
              
              typedef Color3<T>::FloatingPointType Magnum::
            Corresponding floating-point type.
For HSV and other color spaces.
Function documentation
              
                template<class T>
              
              static Color4<T> Magnum::
            Create RGB color from HSV representation.
| Parameters | |
|---|---|
| hsv | Color in HSV color space | 
| a | Alpha value, defaults to 1.0for floating-point types and maximum positive value for integral types | 
Hue can overflow the range .
              
                template<class T>
              
              static Color4<T> Magnum::
            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>
                template<class Integral>
              
              static Color4<T> Magnum::
            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:
Vector4ub srgbAlpha; auto rgba = Color4::fromSrgbAlpha(srgbAlpha);
For conversion from a linear 32-bit representation (i.e, without applying the sRGB curve), use unpack():
Color4ub a{0xff, 0x33, 0x66, 0x99}; Color4 bFromSrgb = Color4::fromSrgbAlpha(a); // {1.0f, 0.0331f, 0.1329f, 0.6f} Color4 bFromLinear = Math::unpack<Color4>(a); // {1.0f, 0.2f, 0.4f, 0.6f}
              
                template<class T>
              
              static Color4<T> Magnum::
            Create linear RGBA color from sRGB representation.
| Parameters | |
|---|---|
| srgb | Color in sRGB color space | 
| a | Alpha value, defaults to 1.0for 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::
            Create linear RGB color from integral sRGB representation.
| Parameters | |
|---|---|
| srgb | Color in sRGB color space | 
| a | Linear alpha value, defaults to 1.0for 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. Same as above, but with alpha as a separate parameter.
              
                template<class T>
              
              static Color4<T> Magnum::
            Create linear RGBA color from 32-bit sRGB + alpha representation.
| Parameters | |
|---|---|
| srgbAlpha | 32-bit sRGB color with linear alpha | 
See Color3::
Color4 a = Color4::fromSrgbAlphaInt(0xff336680); Color4 b = 0xff336680_srgbaf;
Note that the integral value is endian-dependent (the red channel being in the last byte on little-endian platforms), for conversion from an endian-independent sRGB / linear representation use fromSrgbAlpha(const Vector4<Integral>&) / unpack().
              
                template<class T>
              
              static Color4<T> Magnum::
            Create linear RGBA color from 32-bit sRGB + alpha representation.
              
                template<class T>
              
              static Color4<T> Magnum::
            Create linear RGBA color from 24-bit sRGB + alpha representation.
| Parameters | |
|---|---|
| srgb | 24-bit sRGB color | 
| a | Linear alpha value, defaults to 1.0for floating-point types and maximum positive value for integral types | 
Same as above, but with alpha as a separate parameter.
              
                template<class T>
              
              static Color4<T> Magnum::
            Create linear RGBA color from 24-bit sRGB + alpha representation.
              
                template<class T>
              
              static Color4<T> Magnum::
            Create linear RGBA color from 32-bit linear representation.
| Parameters | |
|---|---|
| linear | 32-bit linear RGBA color | 
Compared to fromSrgbAlphaInt() does not peform a sRGB conversion on the input. See toLinearRgbaInt() for an inverse operation, there's also a operator""_
Color4 a = Color4::fromLinearRgbaInt(0xff336680); Color4 b = 0xff336680_rgbaf;
Note that the integral value is endian-dependent (the red channel being in the last byte on little-endian platforms), for conversion from endian-independent linear RGBA representation use unpack<Color4>() on a Color4ub input.
              
                template<class T>
              
              static Color4<T> Magnum::
            Create linear RGBA color from 24-bit linear RGB + alpha representation.
| Parameters | |
|---|---|
| linear | 24-bit linear RGB color | 
| a | Linear alpha value, defaults to 1.0for floating-point types and maximum positive value for integral types | 
Same as above, but with alpha as a separate parameter.
              
                template<class T>
              
              static Color4<T> Magnum::
            Create RGBA color from CIE XYZ representation
| Parameters | |
|---|---|
| xyz | Color in CIE XYZ color space | 
| a | Alpha value, defaults to 1.0for 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::
            Default constructor.
Equivalent to Color4(ZeroInitT).
              
                template<class T>
              
               Magnum::
            Gray constructor.
| Parameters | |
|---|---|
| rgb | RGB value | 
| alpha | Alpha value, defaults to 1.0for floating-point types and maximum positive value for integral types | 
              
                template<class T>
              
               Magnum::
            Constructor.
| Parameters | |
|---|---|
| r | R value | 
| g | G value | 
| b | B value | 
| a | A value, defaults to 1.0for floating-point types and maximum positive value for integral types. | 
              
                template<class T>
                template<std::
            Construct a vector from a fixed-size array.
Use from(const T*) to reinterpret an arbitrary pointer to a vector.
              
                template<class T>
                template<class U>
              
               Magnum::
            Construct a vector from another of different type.
Performs only default casting on the values, no rounding or anything else. Example usage:
Vector4 floatingPoint{1.3f, 2.7f, -15.0f, 7.0f}; Vector4i integral{floatingPoint}; // {1, 2, -15, 7}
              
                template<class T>
              
               Magnum::
            Construct a vector from a BitVector.
Bits that are unset are converted to 0, set bits to 1. If you need a different behavior, for example converting a bit mask to 0 or 255 for a color representation, use lerp(const Vector<size, T>&, const Vector<size, T>&, const BitVector<size>&) instead, for example:
BitVector3 mask = …; Vector3ub a = Math::lerp(Vector3ub{0}, Vector3ub{255}, mask);
              
                template<class T>
              
              ColorHsv<FloatingPointType> Magnum::
            Convert to HSV representation.
The alpha channel is not subject to any conversion, so it is ignored.
              
                template<class T>
              
              Deg<FloatingPointType> Magnum::
            Hue.
| Returns | Hue in range . | 
|---|
              
                template<class T>
              
              FloatingPointType Magnum::
            Saturation.
| Returns | Saturation in range . | 
|---|
              
                template<class T>
              
              FloatingPointType Magnum::
            Value.
| Returns | Value in range . | 
|---|
              
                template<class T>
              
              Vector4<FloatingPointType> Magnum::
            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::
            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; Vector4ub srgbAlpha = color.toSrgbAlpha<UnsignedByte>();
For conversion to a linear 32-bit representation (i.e, without applying the sRGB curve), use pack():
Color4 a{1.0f, 0.2f, 0.4f, 0.6f}; Vector4ub bSrgb = a.toSrgbAlpha<UnsignedByte>(); // {0xff, 0x7c, 0xaa, 0x99} Color4ub bLinear = Math::pack<Color4ub>(a); // {0xff, 0x33, 0x66, 0x99}
              
                template<class T>
              
              UnsignedInt Magnum::
            Convert to 32-bit integral sRGB + linear alpha representation.
See Color3::
              
                template<class T>
              
              UnsignedInt Magnum::
            Convert to 32-bit integral linear RGBA representation.
Compared to toSrgbAlphaInt() does not perform a sRGB conversion on the output. See fromLinearRgbaInt() for an inverse operation. Use rgb() together with Color3::
              
                template<class T>
              
              Vector3<FloatingPointType> Magnum::
            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<T> Magnum::
            Color with premultiplied alpha.
The resulting color has RGB channels always less than or equal to alpha. Note that premultiplication isn't a reversible operation — if alpha is zero, RGB channels become zero as well and unpremultiplied() won't be able to recover the original values back.
              
                template<class T>
              
              Color4<T> Magnum::
            Color with unpremultiplied alpha.
Assuming the input has premultiplied alpha, such as coming from premultiplied(), returns an unpremultiplied color. Note that premultiplication isn't a reversible operation — if alpha is zero, the RGB channels will be set to zero as well.
Additionally, with packed types such as Color4ub, RGB channels are clamped to avoid overflow:
              
                template<class T>
                template<char... chars>
              
              Color4<UnsignedByte> operator""_rgba() constexpr
            
            8bit-per-channel linear RGBA literal
Unpacks the literal into four 8-bit values. Example usage:
using namespace Math::Literals; Color4ub a = 0x33b27fcc_rgba; // {0x33, 0xb2, 0x7f, 0xcc}
              
                template<class T>
                template<char... chars>
              
              Vector4<UnsignedByte> operator""_srgba() constexpr
            
            8bit-per-channel sRGB + alpha literal
Unpacks the literal into four 8-bit values without any colorspace conversion. Behaves identically to operator""_
using namespace Math::Literals; Vector4ub a = 0x33b27fcc_srgba; // {0x33, 0xb2, 0x7f, 0xcc}
              
                template<class T>
                template<char... chars>
              
              Color4<Float> operator""_rgbaf() constexpr
            
            Float linear RGBA literal.
Equivalent to calling Color4::
using namespace Math::Literals; Color4 a = 0x33b27fcc_rgbaf; // {0.2f, 0.698039f, 0.498039f, 0.8f}
              
                template<class T>
                template<char... chars>
              
              Color4<Float> operator""_srgbaf()
            
            Float sRGB + alpha literal.
Equivalent to calling Color4::
using namespace Math::Literals; Color4 a = 0x33b27fcc_srgbaf; // {0.0331048f, 0.445201f, 0.212231f, 0.8f}
              
                template<class T>
                template<char... chars>
              
              Color4<Half> operator""_rgbah() new in Git master
            
            Half-float linear RGBA literal.
Equivalent to calling Color4::
using namespace Math::Literals; Color4h a = 0x33b27fcc_rgbah; // {0.2_h, 0.6982_h, 0.498_h, 0.7998_h}
              
                template<class T>
                template<char... chars>
              
              Color4<Half> operator""_srgbah() new in Git master
            
            Half-float sRGB + alpha literal.
Equivalent to calling Color4::
using namespace Math::Literals; Color4h a = 0x33b27fcc_srgbah; // {0.03311_h, 0.4453_h, 0.2123_h, 0.7998_h}
              
                template<class T>
              
              Debug& operator<<(Debug& debug,
              const Color4<UnsignedByte>& value)
            
            Debug output operator.
If Debug::░▒▓█ shades. The square shade is calculated as a product of Color4::
If Debug::
If Debug::#ff33aaff). Other underlying types are handled by operator<<(Debug&, const Vector<size, T>&).
For example, the following snippet:
Debug{Debug::Flag::Color} << 0x3bd26700_rgba << 0x3bd26733_rgba << 0x3bd26766_rgba << 0x3bd26799_rgba << 0x3bd267cc_rgba << 0x3bd267ff_rgba;
prints the following on terminals that support it:
░░ ▒▒ ▓▓ ██