## YCbCr2rgb (`lygia`/`color`/`space`/`YCbCr2rgb`)

Converts YCbCr to RGB according to https://en.wikipedia.org/wiki/YCbCr

Use:

``````YCbCr2rgb(<vec3|vec4> color)
``````

Check it on Github

``````
#ifndef FNC_YCBCR2RGB
#define FNC_YCBCR2RGB
vec3 YCbCr2rgb(const in vec3 ycbcr) {
float cb = ycbcr.y - .5;
float cr = ycbcr.z - .5;
float y = ycbcr.x;
float r = 1.402 * cr;
float g = -.344 * cb - .714 * cr;
float b = 1.772 * cb;
return vec3(r, g, b) + y;
}

vec4 YCbCr2rgb(const in vec4 ycbcr) {
return vec4(YCbCr2rgb(ycbcr.rgb),ycbcr.a);
}
#endif

``````

Use:

``````YCbCr2rgb(<float3|float4> color)
``````

Check it on Github

``````
#ifndef FNC_YCBCR2RGB
#define FNC_YCBCR2RGB
float3 YCbCr2rgb(in float3 ycbcr) {
float cb = ycbcr.y - .5;
float cr = ycbcr.z - .5;
float y = ycbcr.x;
float r = 1.402 * cr;
float g = -.344 * cb - .714 * cr;
float b = 1.772 * cb;
return float3(r, g, b) + y;
}

float4 YCbCr2rgb(in float4 ycbcr) {
return float4(YCbCr2rgb(ycbcr.rgb),ycbcr.a);
}
#endif

``````

Check it on Github

``````
fn YCbCr2rgb(ycbcr: vec3f) -> vec3f {
let cb = ycbcr.y - 0.5;
let cr = ycbcr.z - 0.5;
let y = ycbcr.x;
let r = 1.402 * cr;
let g = -0.344 * cb - 0.714 * cr;
let b = 1.772 * cb;
return vec3f(r, g, b) + y;
}

``````