Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.body.innerHTML = '<div id="m" style="width:100px;height:5px;background:black;"></div>';
- px = 0;
- py = 0;
- angleDeg = (x1,y1,x2,y2) => Math.atan2(y2 - y1, x2 - x1) * 180 / Math.PI;
- document.onmousemove = function(e) {
- document.querySelector('#m').style.transform = 'rotate(' + angleDeg(px, py, e.x, e.y) + 'deg)';
- px = e.x; py = e.y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement