Skip to content

Instantly share code, notes, and snippets.

@black-black-cat
Last active November 8, 2019 09:17
Show Gist options
  • Save black-black-cat/6d0568a0a6e014014015799599893fc3 to your computer and use it in GitHub Desktop.
Save black-black-cat/6d0568a0a6e014014015799599893fc3 to your computer and use it in GitHub Desktop.
getCursors Cursors
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<h1>Hello world!</h1>
<script src="script.js"></script>
</body>
</html>
let cursors = ['n', 'ne', 'e', 'se', 's', 'sw', 'w', 'nw']
let points = ['t', 'tr', 'r', 'br', 'b', 'bl', 'l', 'tl']
function getCursors (angle) {
angle = formatAngle(angle)
let startMark = Math.ceil(Math.floor(angle / 22.5) / 2) % 8
newCursors = cursors.slice(startMark).concat(cursors.slice(0, startMark))
// let dict = {}
// points.forEach((v, i) => {
// dict[v] = newCursors[i]
// })
// return dict
return newCursors
}
function formatAngle (num) {
num = num % 360
if (num < 0) {
num += 360
}
return num
}
console.log(getCursors(-88))
/* todo: add styles */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment