lygia
/color
/space
/rgb2yiq
)Convert from linear RGB to YIQ which was the followin range. Using conversion matrices from FCC NTSC Standard (SMPTE C) https://en.wikipedia.org/wiki/YIQ
Use:
rgb2yiq(<vec3|vec4> color)
#ifndef MAT_RGB2YIQ
#define MAT_RGB2YIQ
const mat3 RGB2YIQ = mat3(
0.300, 0.5900, 0.1100,
0.599, -0.2773, -0.3217,
0.213, -0.5251, 0.3121);
#endif
#ifndef FNC_RGB2YIQ
#define FNC_RGB2YIQ
vec3 rgb2yiq(const in vec3 rgb) { return RGB2YIQ * rgb; }
vec4 rgb2yiq(const in vec4 rgb) { return vec4(rgb2yiq(rgb.rgb), rgb.a); }
#endif
Use:
<float3|float4> rgb2yiq(<float3|float4> color)
#ifndef MAT_RGB2YIQ
#define MAT_RGB2YIQ
static const float3x3 RGB2YIQ = float3x3(
0.300, 0.5900, 0.1100,
0.599, -0.2773, -0.3217,
0.213, -0.5251, 0.3121);
#endif
#ifndef FNC_RGB2YIQ
#define FNC_RGB2YIQ
float3 rgb2yiq(in float3 rgb) { return mul(RGB2YIQ, rgb); }
float4 rgb2yiq(in float4 rgb) { return float4(rgb2yiq(rgb.rgb), rgb.a); }
#endif
Use:
rgb2yiq(<float3|float4> color)
#ifndef MAT_RGB2YIQ
#define MAT_RGB2YIQ
constant matrix<float, 3, 3> RGB2YIQ = matrix<float, 3, 3>(
0.300, 0.5900, 0.1100,
0.599, -0.2773, -0.3217,
0.213, -0.5251, 0.3121);
#endif
#ifndef FNC_RGB2YIQ
#define FNC_RGB2YIQ
float3 rgb2yiq( float3 rgb) { return RGB2YIQ * rgb; }
float4 rgb2yiq( float4 rgb) { return float4(rgb2yiq(rgb.rgb), rgb.a); }
#endif
const RGB2YIQ : mat3x3<f32> = mat3x3<f32>(
vec3f(0.300, 0.5900, 0.1100),
vec3f(0.599, -0.2773, -0.3217),
vec3f(0.213, -0.5251, 0.3121) );
fn rgb2yiq(rgb : vec3f) -> vec3f { return RGB2YIQ * rgb; }
LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).
It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository