Last active
March 30, 2020 04:51
-
-
Save DarkMatterMatt/f8657fe61f3bd790815940851776c249 to your computer and use it in GitHub Desktop.
Shows a crosshair at specific coordinates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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