mirror of
https://github.com/g-truc/glm.git
synced 2024-11-12 21:31:47 +00:00
Fixed GTX_color_space - saturation #195
This commit is contained in:
parent
c80f5bc740
commit
d77bfa1a70
@ -64,8 +64,8 @@ namespace glm
|
|||||||
|
|
||||||
/// Build a saturation matrix.
|
/// Build a saturation matrix.
|
||||||
/// @see gtx_color_space
|
/// @see gtx_color_space
|
||||||
template <typename T, precision P>
|
template <typename T>
|
||||||
GLM_FUNC_DECL detail::tmat4x4<T, P> saturation(
|
GLM_FUNC_DECL detail::tmat4x4<T, defaultp> saturation(
|
||||||
T const s);
|
T const s);
|
||||||
|
|
||||||
/// Modify the saturation of a color.
|
/// Modify the saturation of a color.
|
||||||
|
@ -106,16 +106,16 @@ namespace glm
|
|||||||
return hsv;
|
return hsv;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T, precision P>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T, P> saturation(const T s)
|
GLM_FUNC_QUALIFIER detail::tmat4x4<T, defaultp> saturation(T const s)
|
||||||
{
|
{
|
||||||
detail::tvec3<T, P> rgbw = detail::tvec3<T, P>(T(0.2126), T(0.7152), T(0.0722));
|
detail::tvec3<T, defaultp> rgbw = detail::tvec3<T, defaultp>(T(0.2126), T(0.7152), T(0.0722));
|
||||||
|
|
||||||
T col0 = (T(1) - s) * rgbw.r;
|
T col0 = (T(1) - s) * rgbw.r;
|
||||||
T col1 = (T(1) - s) * rgbw.g;
|
T col1 = (T(1) - s) * rgbw.g;
|
||||||
T col2 = (T(1) - s) * rgbw.b;
|
T col2 = (T(1) - s) * rgbw.b;
|
||||||
|
|
||||||
detail::tmat4x4<T, P> result(T(1));
|
detail::tmat4x4<T, defaultp> result(T(1));
|
||||||
result[0][0] = col0 + s;
|
result[0][0] = col0 + s;
|
||||||
result[0][1] = col0;
|
result[0][1] = col0;
|
||||||
result[0][2] = col0;
|
result[0][2] = col0;
|
||||||
|
@ -11,9 +11,20 @@
|
|||||||
#include <glm/gtc/type_precision.hpp>
|
#include <glm/gtc/type_precision.hpp>
|
||||||
#include <glm/gtx/color_space.hpp>
|
#include <glm/gtx/color_space.hpp>
|
||||||
|
|
||||||
|
int test_saturation()
|
||||||
|
{
|
||||||
|
int Error(0);
|
||||||
|
|
||||||
|
glm::vec4 Color = glm::saturation(1.0f, glm::vec4(1.0, 0.5, 0.0, 1.0));
|
||||||
|
|
||||||
|
return Error;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int Error(0);
|
int Error(0);
|
||||||
|
|
||||||
|
Error += test_saturation();
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user