Created
February 21, 2018 15:41
-
-
Save remy/92031f44dd7c573e62601c12eb7da8df to your computer and use it in GitHub Desktop.
Get x/y from index.
This file contains hidden or 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
| console.clear(); | |
| const w = 4; | |
| const h = 6; | |
| const res = Array.from({ | |
| length: w * h | |
| }, (_, i) => i).map(i => { | |
| const x = i % w; | |
| const y = i / w | 0; | |
| console.log('x/y: %s,%s', x, y); | |
| return { x, y } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment