2 Argument Arctangent

A simple implementation of atan2(y,x) function of ChelseaJS.
It looks like two eyes following the mouse.

Code

            
    elem=document.querySelector(".example-container");
    setCanvas(elem);
    
    t=0;
    fetch_mouse_pos(elem,'mousemove');
    function draw(){
        clearCanvas()
        new circle(WIDTH/3,HEIGHT/2,100,'#fff',1);
        theta=atan2(HEIGHT/2-mousepos.y,mousepos.x-WIDTH/3);
        x1=WIDTH/3+50*cos(theta);
        y1=HEIGHT/2-50*sin(theta);

        new circle(2*WIDTH/3,HEIGHT/3,60,'#fff',1);

        theta2=atan2(HEIGHT/3-mousepos.y,mousepos.x-2*WIDTH/3);
        x2=2*WIDTH/3+30*cos(theta2);
        y2=HEIGHT/3-30*sin(theta2);

        new circle(x2,y2,30,'#222',1);


        new circle(x1,y1,50,'#222',1);
        requestAnimationFrame(draw);
    }
    
    draw();