JSFiddle - React, Tailwind, and code Playground
HTML
<canvas width="500" height="500" id="debug"></canvas>
<canvas width="502" height="502" id="content"></canvas>
CSS
#debug
{
cursor:none;
border: 1px solid #000000;
position:absolute;
z-index: 1;
}
JavaScript
var canvas = document.getElementById("debug");
var context = canvas.getContext("2d");
var c = document.getElementById("content");
var co = c.getContext("2d");
canvas.addEventListener("mousemove", function(event){
// var contDiv = $('#current_system_map');
// var offset = contDiv.offset();
/* x = e.clientX-offset.left;
y = e.clientY-offset.top; */
var x = event.pageX - canvas.offsetLeft;
var y = event.pageY - canvas.offsetTop;
context.clearRect(0, 0, canvas.width, canvas.height);
context.beginPath();
context.moveTo(0,y);
context.lineTo(595,y);
context.moveTo(x,0);
context.lineTo(x,595);
context.strokeStyle = "black";//"rgb(255,255,255)";
context.stroke();
context.closePath();
});
co.beginPath();
co.moveTo(0,0);
co.lineTo(500,500);
co.strokeStyle = "red";
co.stroke();
co.closePath();