#define scale 120.

//#define calculus(x,y) (cos(x) * y * 5. + sin(y) * x * 5.)
//#define calculus(x,y) (pow(x, 2.) + pow(y, 2.))
//#define calculus(x,y) (pow(x, 2.) - pow(y, 2.))
//#define calculus(x,y) (x * y)
#define calculus(x,y) ((pow(x,2.) - pow(y,3.))/4.)


//vec3 val2col(int val) {
//    while(val<0) val += 360;
//    int v = val % 360;
//    float c = float(v % 60) / 59.;
//    if(v >= 300) return vec3(1.  , 0.  , 1.-c);
//    if(v >= 240) return vec3(   c, 0.  , 1.  );
//    if(v >= 180) return vec3(0.  , 1.-c, 1.  );
//    if(v >= 120) return vec3(0.  , 1.  ,    c);
//    if(v >=  60) return vec3(1.-c, 1.  , 0.  );
//                 return vec3(1.  ,    c, 0.  );
//}

// Thank you iq
vec3 val2col( float val )
{
     return clamp(abs(mod(val/60.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0,0.0,1.0);
}


void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    // Normalized pixel coordinates (from 0 to 1)
    vec2 uv = (fragCoord / iResolution.xy - vec2(.5)) * scale;
    uv.x *= iResolution.x/iResolution.y;

    // Time varying pixel color
    float col = calculus(uv.x, uv.y) + iTime * 180.;

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