|
|
|
@ -219,10 +219,7 @@ Note that constructor conversion between different types (like in @ref Vector |
|
|
|
classes) doesn't do any (de)normalization, you should use @ref pack) and |
|
|
|
classes) doesn't do any (de)normalization, you should use @ref pack) and |
|
|
|
@ref unpack() instead, for example: |
|
|
|
@ref unpack() instead, for example: |
|
|
|
|
|
|
|
|
|
|
|
@code{.cpp} |
|
|
|
@snippet MagnumMath.cpp Color3-pack |
|
|
|
Color3 a{1.0f, 0.5f, 0.75f}; |
|
|
|
|
|
|
|
auto b = pack<Color3ub>(a); // b == {255, 127, 191}
|
|
|
|
|
|
|
|
@endcode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Conversion from and to HSV is done always using floating-point types, so hue |
|
|
|
Conversion from and to HSV is done always using floating-point types, so hue |
|
|
|
is always in range in range @f$ [0.0, 360.0] @f$, saturation and value in |
|
|
|
is always in range in range @f$ [0.0, 360.0] @f$, saturation and value in |
|
|
|
@ -383,10 +380,7 @@ template<class T> class Color3: public Vector3<T> { |
|
|
|
* representation and want to create a floating-point linear RGB color |
|
|
|
* representation and want to create a floating-point linear RGB color |
|
|
|
* out of it: |
|
|
|
* out of it: |
|
|
|
* |
|
|
|
* |
|
|
|
* @code{.cpp} |
|
|
|
* @snippet MagnumMath.cpp Color3-fromSrgb |
|
|
|
* Math::Vector3<UnsignedByte> srgb; |
|
|
|
|
|
|
|
* auto rgb = Color3::fromSrgb(srgb); |
|
|
|
|
|
|
|
* @endcode |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
/* Input is a Vector3 to hint that it doesn't have any (additive,
|
|
|
|
/* Input is a Vector3 to hint that it doesn't have any (additive,
|
|
|
|
multiplicative) semantics of a linear RGB color */ |
|
|
|
multiplicative) semantics of a linear RGB color */ |
|
|
|
@ -475,11 +469,7 @@ template<class T> class Color3: public Vector3<T> { |
|
|
|
* |
|
|
|
* |
|
|
|
* Example usage: |
|
|
|
* Example usage: |
|
|
|
* |
|
|
|
* |
|
|
|
* @code{.cpp} |
|
|
|
* @snippet MagnumMath.cpp Color3-toHsv |
|
|
|
* Deg hue; |
|
|
|
|
|
|
|
* Float saturation, value; |
|
|
|
|
|
|
|
* std::tie(hue, saturation, value) = color.toHsv(); |
|
|
|
|
|
|
|
* @endcode |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @see @ref hue(), @ref saturation(), @ref value(), @ref fromHsv() |
|
|
|
* @see @ref hue(), @ref saturation(), @ref value(), @ref fromHsv() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -547,10 +537,7 @@ template<class T> class Color3: public Vector3<T> { |
|
|
|
* Useful in cases where you have a floating-point linear RGB color and |
|
|
|
* Useful in cases where you have a floating-point linear RGB color and |
|
|
|
* want to create for example an 8-bit sRGB representation out of it: |
|
|
|
* want to create for example an 8-bit sRGB representation out of it: |
|
|
|
* |
|
|
|
* |
|
|
|
* @code{.cpp} |
|
|
|
* @snippet MagnumMath.cpp Color3-toSrgb |
|
|
|
* Color3 color; |
|
|
|
|
|
|
|
* Math::Vector3<UnsignedByte> srgb = color.toSrgb<UnsignedByte>(); |
|
|
|
|
|
|
|
* @endcode |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
template<class Integral> Vector3<Integral> toSrgb() const { |
|
|
|
template<class Integral> Vector3<Integral> toSrgb() const { |
|
|
|
return Implementation::toSrgbIntegral<T, Integral>(*this); |
|
|
|
return Implementation::toSrgbIntegral<T, Integral>(*this); |
|
|
|
@ -752,10 +739,7 @@ class Color4: public Vector4<T> { |
|
|
|
* representation and want to create a floating-point linear RGBA color |
|
|
|
* representation and want to create a floating-point linear RGBA color |
|
|
|
* out of it: |
|
|
|
* out of it: |
|
|
|
* |
|
|
|
* |
|
|
|
* @code{.cpp} |
|
|
|
* @snippet MagnumMath.cpp Color4-fromSrgbAlpha |
|
|
|
* Math::Vector4<UnsignedByte> srgbAlpha; |
|
|
|
|
|
|
|
* auto rgba = Color4::fromSrgbAlpha(srgbAlpha); |
|
|
|
|
|
|
|
* @endcode |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
/* Input is a Vector4 to hint that it doesn't have any (additive,
|
|
|
|
/* Input is a Vector4 to hint that it doesn't have any (additive,
|
|
|
|
multiplicative) semantics of a linear RGB color */ |
|
|
|
multiplicative) semantics of a linear RGB color */ |
|
|
|
@ -774,10 +758,7 @@ class Color4: public Vector4<T> { |
|
|
|
* representation and want to create a floating-point linear RGBA color |
|
|
|
* representation and want to create a floating-point linear RGBA color |
|
|
|
* out of it: |
|
|
|
* out of it: |
|
|
|
* |
|
|
|
* |
|
|
|
* @code{.cpp} |
|
|
|
* @snippet MagnumMath.cpp Color4-fromSrgb |
|
|
|
* Math::Vector3<UnsignedByte> srgb; |
|
|
|
|
|
|
|
* auto rgba = Color4::fromSrgb(srgb); |
|
|
|
|
|
|
|
* @endcode |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
/* Input is a Vector3 to hint that it doesn't have any (additive,
|
|
|
|
/* Input is a Vector3 to hint that it doesn't have any (additive,
|
|
|
|
multiplicative) semantics of a linear RGB color */ |
|
|
|
multiplicative) semantics of a linear RGB color */ |
|
|
|
@ -878,11 +859,7 @@ class Color4: public Vector4<T> { |
|
|
|
* The alpha channel is not subject to any conversion, so it is |
|
|
|
* The alpha channel is not subject to any conversion, so it is |
|
|
|
* ignored. Example usage: |
|
|
|
* ignored. Example usage: |
|
|
|
* |
|
|
|
* |
|
|
|
* @code{.cpp} |
|
|
|
* @snippet MagnumMath.cpp Color4-toHsv |
|
|
|
* Deg hue; |
|
|
|
|
|
|
|
* Float saturation, value; |
|
|
|
|
|
|
|
* std::tie(hue, saturation, value) = color.toHsv(); |
|
|
|
|
|
|
|
* @endcode |
|
|
|
|
|
|
|
* |
|
|
|
* |
|
|
|
* @see @ref hue(), @ref saturation(), @ref value(), @ref fromHsv() |
|
|
|
* @see @ref hue(), @ref saturation(), @ref value(), @ref fromHsv() |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -933,10 +910,7 @@ class Color4: public Vector4<T> { |
|
|
|
* and want to create for example an 8-bit sRGB + alpha representation |
|
|
|
* and want to create for example an 8-bit sRGB + alpha representation |
|
|
|
* out of it: |
|
|
|
* out of it: |
|
|
|
* |
|
|
|
* |
|
|
|
* @code{.cpp} |
|
|
|
* @snippet MagnumMath.cpp Color4-toSrgbAlpha |
|
|
|
* Color4 color; |
|
|
|
|
|
|
|
* Math::Vector4<UnsignedByte> srgbAlpha = color.toSrgbAlpha<UnsignedByte>(); |
|
|
|
|
|
|
|
* @endcode |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
template<class Integral> Vector4<Integral> toSrgbAlpha() const { |
|
|
|
template<class Integral> Vector4<Integral> toSrgbAlpha() const { |
|
|
|
return Implementation::toSrgbAlphaIntegral<T, Integral>(*this); |
|
|
|
return Implementation::toSrgbAlphaIntegral<T, Integral>(*this); |
|
|
|
@ -1012,9 +986,7 @@ namespace Literals { |
|
|
|
|
|
|
|
|
|
|
|
Unpacks the literal into three 8-bit values. Example usage: |
|
|
|
Unpacks the literal into three 8-bit values. Example usage: |
|
|
|
|
|
|
|
|
|
|
|
@code{.cpp} |
|
|
|
@snippet MagnumMath.cpp _rgb |
|
|
|
Color3ub a = 0x33b27f_rgb; // {0x33, 0xb2, 0x7f}
|
|
|
|
|
|
|
|
@endcode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@attention 8bit-per-channel colors are commonly treated as being in sRGB color |
|
|
|
@attention 8bit-per-channel colors are commonly treated as being in sRGB color |
|
|
|
space, which is not directly usable in calculations and has to be converted |
|
|
|
space, which is not directly usable in calculations and has to be converted |
|
|
|
@ -1035,9 +1007,7 @@ Behaves identically to @link operator""_rgb() @endlink though it doesn't |
|
|
|
return a @ref Color3 type to indicate that the resulting value is not linear |
|
|
|
return a @ref Color3 type to indicate that the resulting value is not linear |
|
|
|
RGB. Use this literal to document that given value is in sRGB. Example usage: |
|
|
|
RGB. Use this literal to document that given value is in sRGB. Example usage: |
|
|
|
|
|
|
|
|
|
|
|
@code{.cpp} |
|
|
|
@snippet MagnumMath.cpp _srgb |
|
|
|
Math::Vector3<UnsignedByte> a = 0x33b27f_srgb; // {0x33, 0xb2, 0x7f}
|
|
|
|
|
|
|
|
@endcode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@attention Note that colors in sRGB representation should not be used directly |
|
|
|
@attention Note that colors in sRGB representation should not be used directly |
|
|
|
in calculations --- they should be converted to linear RGB, calculation |
|
|
|
in calculations --- they should be converted to linear RGB, calculation |
|
|
|
@ -1058,9 +1028,7 @@ constexpr Vector3<UnsignedByte> operator "" _srgb(unsigned long long value) { |
|
|
|
|
|
|
|
|
|
|
|
Unpacks the literal into four 8-bit values. Example usage: |
|
|
|
Unpacks the literal into four 8-bit values. Example usage: |
|
|
|
|
|
|
|
|
|
|
|
@code{.cpp} |
|
|
|
@snippet MagnumMath.cpp _rgba |
|
|
|
Color4ub a = 0x33b27fcc_rgba; // {0x33, 0xb2, 0x7f, 0xcc}
|
|
|
|
|
|
|
|
@endcode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@attention 8bit-per-channel colors are commonly treated as being in sRGB color |
|
|
|
@attention 8bit-per-channel colors are commonly treated as being in sRGB color |
|
|
|
space, which is not directly usable in calculations and has to be converted |
|
|
|
space, which is not directly usable in calculations and has to be converted |
|
|
|
@ -1082,9 +1050,7 @@ return a @ref Color4 type to indicate that the resulting value is not linear |
|
|
|
RGBA. Use this literal to document that given value is in sRGB + alpha. Example |
|
|
|
RGBA. Use this literal to document that given value is in sRGB + alpha. Example |
|
|
|
usage: |
|
|
|
usage: |
|
|
|
|
|
|
|
|
|
|
|
@code{.cpp} |
|
|
|
@snippet MagnumMath.cpp _srgba |
|
|
|
Math::Vector4<UnsignedByte> a = 0x33b27fcc_srgba; // {0x33, 0xb2, 0x7f, 0xcc}
|
|
|
|
|
|
|
|
@endcode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@attention Note that colors in sRGB representation should not be used directly |
|
|
|
@attention Note that colors in sRGB representation should not be used directly |
|
|
|
in calculations --- they should be converted to linear RGB, calculation |
|
|
|
in calculations --- they should be converted to linear RGB, calculation |
|
|
|
@ -1105,9 +1071,7 @@ constexpr Vector4<UnsignedByte> operator "" _srgba(unsigned long long value) { |
|
|
|
|
|
|
|
|
|
|
|
Unpacks the 8-bit values into three floats. Example usage: |
|
|
|
Unpacks the 8-bit values into three floats. Example usage: |
|
|
|
|
|
|
|
|
|
|
|
@code{.cpp} |
|
|
|
@snippet MagnumMath.cpp _rgbf |
|
|
|
Color3 a = 0x33b27f_rgbf; // {0.2f, 0.698039f, 0.498039f}
|
|
|
|
|
|
|
|
@endcode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@attention 8bit-per-channel colors are commonly treated as being in sRGB color |
|
|
|
@attention 8bit-per-channel colors are commonly treated as being in sRGB color |
|
|
|
space, which is not directly usable in calculations and has to be converted |
|
|
|
space, which is not directly usable in calculations and has to be converted |
|
|
|
@ -1127,9 +1091,7 @@ Unpacks the 8-bit values into three floats and converts the color space from |
|
|
|
sRGB to linear RGB. See @ref Color3::fromSrgb() for more information. Example |
|
|
|
sRGB to linear RGB. See @ref Color3::fromSrgb() for more information. Example |
|
|
|
usage: |
|
|
|
usage: |
|
|
|
|
|
|
|
|
|
|
|
@code{.cpp} |
|
|
|
@snippet MagnumMath.cpp _srgbf |
|
|
|
Color3 a = 0x33b27f_srgbf; // {0.0331048f, 0.445201f, 0.212231f}
|
|
|
|
|
|
|
|
@endcode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@see @link operator""_srgbaf() @endlink, @link operator""_srgb() @endlink, |
|
|
|
@see @link operator""_srgbaf() @endlink, @link operator""_srgb() @endlink, |
|
|
|
@link operator""_rgbf() @endlink |
|
|
|
@link operator""_rgbf() @endlink |
|
|
|
@ -1143,9 +1105,7 @@ inline Color3<Float> operator "" _srgbf(unsigned long long value) { |
|
|
|
|
|
|
|
|
|
|
|
Unpacks the 8-bit values into four floats. Example usage: |
|
|
|
Unpacks the 8-bit values into four floats. Example usage: |
|
|
|
|
|
|
|
|
|
|
|
@code{.cpp} |
|
|
|
@snippet MagnumMath.cpp _rgbaf |
|
|
|
Color4 a = 0x33b27fcc_rgbaf; // {0.2f, 0.698039f, 0.498039f, 0.8f}
|
|
|
|
|
|
|
|
@endcode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@attention 8bit-per-channel colors are commonly treated as being in sRGB color |
|
|
|
@attention 8bit-per-channel colors are commonly treated as being in sRGB color |
|
|
|
space, which is not directly usable in calculations and has to be converted |
|
|
|
space, which is not directly usable in calculations and has to be converted |
|
|
|
@ -1165,9 +1125,7 @@ Unpacks the 8-bit values into four floats and converts the color space from |
|
|
|
sRGB + alpha to linear RGBA. See @ref Color4::fromSrgbAlpha() for more |
|
|
|
sRGB + alpha to linear RGBA. See @ref Color4::fromSrgbAlpha() for more |
|
|
|
information. Example usage: |
|
|
|
information. Example usage: |
|
|
|
|
|
|
|
|
|
|
|
@code{.cpp} |
|
|
|
@snippet MagnumMath.cpp _srgbaf |
|
|
|
Color4 a = 0x33b27fcc_srgbaf; // {0.0331048f, 0.445201f, 0.212231f, 0.8f}
|
|
|
|
|
|
|
|
@endcode |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@see @link operator""_srgbf() @endlink, @link operator""_srgba() @endlink, |
|
|
|
@see @link operator""_srgbf() @endlink, @link operator""_srgba() @endlink, |
|
|
|
@link operator""_rgbaf() @endlink |
|
|
|
@link operator""_rgbaf() @endlink |
|
|
|
|