Skip to content

Instantly share code, notes, and snippets.

@DarkMatterMatt
Last active March 30, 2020 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarkMatterMatt/f8657fe61f3bd790815940851776c249 to your computer and use it in GitHub Desktop.
Save DarkMatterMatt/f8657fe61f3bd790815940851776c249 to your computer and use it in GitHub Desktop.
Shows a crosshair at specific coordinates
function toPx(a) {
return a.toString() + "px";
}
function showLine(x, y, width, height, color) {
const $a = document.createElement("div");
document.body.append($a);
$a.style.width = toPx(width);
$a.style.height = toPx(height);
$a.style.backgroundColor = color;
$a.style.zIndex = 99999;
$a.style.position = "absolute";
$a.style.top = toPx(y - height/2);
$a.style.left = toPx(x - width/2);
}
function showCrossHair(x, y, size = 7, thickness = 1, color = "red") {
showLine(x, y, size, thickness, color);
showLine(x, y, thickness, size, color);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment