Recently, I've been honing my Javascript skills and decided to create a follow-mouse function. After successfully implementing it, I started brainstorming a new concept that I'm unsure is achievable.
Is there a way to develop an "orb of vision" that tracks the mouse's movement, illuminating everything within its radius? Imagine using a torch to illuminate a specific area where your cursor hovers.
https://i.stack.imgur.com/qpzXk.png
- NOTE: I'm not seeking someone to write the code for me. Instead, I'm looking for insights to guide my learning process. I'm eager to tackle this project on my own but could use some pointers!
function trackMouseMovement(e) {
var x = document.getElementById('x_show');
var y = document.getElementById('y_show');
x.innerHTML = e.clientX;
y.innerHTML = e.clientY;
document.getElementById("followDiv").style.left = event.clientX - 15 + "px";
document.getElementById("followDiv").style.top = event.clientY - 15 + "px";
}
document.onmousemove = trackMouseMovement;
#followDiv {
background-color: lightblue;
height: 30px;
width: 30px;
position: absolute;
}
<p id="x_show">0</p>
<p id="y_show">0</p>
<div id="followDiv"></div>