#define PI 3.1416

float curve(float st, float leftP, float rightP)
{
    //leftP && rightP select position of curve
    return abs(sin(((st-leftP)/rightP) * PI));
}

float line(float st, float l)
{
    return smoothstep(l-0.01, l, st) - smoothstep(l, l+0.01, st);
}

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    // Normalized pixel coordinates (from 0 to 1)
    vec2 uv = fragCoord/iResolution.xy;
    
    vec3 col = vec3(0.);
    
    ////Rainbow static and decided
    //col.r = curve(uv.x, 0.284, 0.412);
    //col.g = curve(uv.x, 0.428, 0.444);
    //col.b = curve(uv.x, 0.004, 0.268);
    
    ////Rainbow changing
    col.r = curve(uv.x, 0.284, abs(cos(iTime/6.))+0.2);
    col.g = curve(uv.x, 0.428, abs(sin(iTime/10.))+0.2);
    col.b = curve(uv.x, 0.0, abs(tan(iTime/16.))+0.2);
    
    
    ////Painted lines to see how the values r, g, b of the vec3 col change
    //col = mix(col, vec3(1., 0., 0.), line(uv.y, col.r));
    //col = mix(col, vec3(0., 1., 0.), line(uv.y, col.g));
    //col = mix(col, vec3(0., 0., 1.), line(uv.y, col.b));

    // Output to screen
    fragColor = vec4(col,1.0);
}
