Update coordinates_xy.js

pull/2/head
Andreas Gysin 2021-02-20 14:35:54 +01:00
rodzic 436a642cdb
commit 617c54e138
1 zmienionych plików z 13 dodań i 4 usunięć

Wyświetl plik

@ -5,11 +5,20 @@
@desc Use of coord.x and coord.y
*/
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ.:!?'
const density = 'Ñ@#W$9876543210?!abc;:+=-,._ '
export function main(coord, context, cursor, buffer) {
// To generate an output return a character
// To generate an output return a single character
// or an object with a “char” field, for example {char: 'x'}
const i = (coord.y + coord.x + context.frame) % chars.length
return chars[i]
// Shortcuts for frame and coord
const f = context.frame
const {x, y} = coord
// Invert direction for odd rows
if (coord.y % 2 == 0) {
return density[(y + x + f) % density.length]
} else {
return density[(y + context.cols - x + f) % density.length]
}
}