NoNameCracksInc icon

Triangle

NoNameCracksInc | PRO | 09/18/15 04:52:57 PM UTC | 0 ⭐ | 338 👁️ | Never ⏰ | []
text |

1.25 KB

|

None

|

0 👍

/

0 👎

<!DOCTYPE html>
<html>
  <body>
    <canvas id='paper'></canvas>
    <script>
     var paper = document.getElementById('paper');
    paper.width = window.innerWidth;
    paper.height = window.innerHeight;
    paper.style.position = 'absolute';paper.style.left = 0;paper.style.top = 0;
      document.body.onmousemove = function(e)
     {
       paper.width = paper.width;
      var x = e.pageX;
      var y = e.pageY;
         var ctx = paper.getContext('2d');
       ctx.lineWidth = 1;
      ctx.beginPath();
        ctx.moveTo(50,window.innerHeight/2);
       ctx.lineTo(x,y);
       ctx.moveTo(x,y);
       ctx.lineTo(e.pageX,window.innerHeight/2);
       ctx.moveTo(e.pageX,window.innerHeight/2);
       ctx.lineTo(50,window.innerHeight/2);
       ctx.moveTo(50,window.innerHeight/2);
           var x = e.pageX - 50;
          var y = window.innerHeight/2 - e.pageY;
          var angle = Math.abs(  Math.atan(y/x)*180/Math.PI );
          ctx.font = '15px Calibri';
         ctx.fillStyle='blue';
         ctx.fillText(Math.round(angle)+'°',20,window.innerHeight/2);
         ctx.fillText((180-90-Math.round(angle))+'°',e.pageX+15,e.pageY);
        ctx.stroke();
     }
    </script>
  </body>
 </html>

Comments