Last active
November 8, 2019 09:17
-
-
Save black-black-cat/6d0568a0a6e014014015799599893fc3 to your computer and use it in GitHub Desktop.
getCursors Cursors
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
<!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> |
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
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)) |
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
/* todo: add styles */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment