nyancat

Unnamed repository; edit this file 'description' to name the repository.
git clone https://git.inz.fi/nyancat
Log | Files | Refs | README

commit c2c783fc3676b448f5555188501d5fa428c5b476
parent 37bc640e61bf2f5833dd5373bc5e8dbee99c5e43
Author: Santtu Lakkala <inz@inz.fi>
Date:   Mon, 20 Jul 2020 16:47:30 +0300

Add option for vertical rainbow

Diffstat:
Mnyancat.c | 10++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/nyancat.c b/nyancat.c @@ -40,6 +40,7 @@ struct lolcat { int h; int sx; int sy; + int transpose; uint32_t fg; uint32_t bg; bool bg_set; @@ -59,8 +60,10 @@ struct lolcat { void *write_data; }; -int nyan(int x, int y) +int nyan(int x, int y, bool transpose) { + if (transpose) + return sin(y * PI / 18) * 18 + x * 18; return sin(x * PI / 18) * 18 + y * 18; } @@ -388,7 +391,7 @@ static void _lc_colorize(struct lolcat *lc, const char *u8_char, size_t len) col = _bold(lc->fg); else col = lc->fg; - col = _add(rainbow(0.03, nyan(lc->x, lc->y)), col, 0.5); + col = _add(rainbow(0.03, nyan(lc->x, lc->y, lc->transpose)), col, 0.5); if (lc->mode == INDEXED16) col = _index16(col, &lc->bold); @@ -719,6 +722,9 @@ int main(int argc, char **argv) case '2': lc->mode = INDEXED256; break; + case 'v': + lc->transpose = true; + break; case 'h': default: usage();