2020-05-09 01:19:04 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <clocale>
|
2020-02-18 17:36:16 +00:00
|
|
|
#include <notcurses/notcurses.h>
|
2019-12-16 04:13:13 +00:00
|
|
|
|
2020-05-09 01:24:29 +00:00
|
|
|
auto main() -> int {
|
2019-12-16 04:13:13 +00:00
|
|
|
if(!setlocale(LC_ALL, "")){
|
|
|
|
fprintf(stderr, "Couldn't set locale\n");
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2020-05-19 12:44:39 +00:00
|
|
|
notcurses_options opts{};
|
2021-12-14 22:54:03 +00:00
|
|
|
opts.flags = NCOPTION_INHIBIT_SETLOCALE
|
|
|
|
| NCOPTION_NO_ALTERNATE_SCREEN
|
|
|
|
| NCOPTION_DRAIN_INPUT;
|
2020-05-19 12:44:39 +00:00
|
|
|
struct notcurses* nc = notcurses_init(&opts, nullptr);
|
2020-05-09 01:19:04 +00:00
|
|
|
if(nc == nullptr){
|
2019-12-16 04:13:13 +00:00
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2021-11-07 02:32:20 +00:00
|
|
|
unsigned dimy, dimx;
|
2019-12-16 04:13:13 +00:00
|
|
|
struct ncplane* n = notcurses_stdplane(nc);
|
|
|
|
ncplane_dim_yx(n, &dimy, &dimx);
|
|
|
|
int r , g, b;
|
|
|
|
r = 0;
|
|
|
|
g = 0x80;
|
|
|
|
b = 0;
|
2020-09-17 19:34:28 +00:00
|
|
|
ncplane_set_fg_rgb8(n, 0x40, 0x20, 0x40);
|
2021-11-07 02:32:20 +00:00
|
|
|
for(unsigned y = 0 ; y < dimy ; ++y){
|
2021-07-27 05:49:38 +00:00
|
|
|
if(ncplane_cursor_move_yx(n, y, 0)){
|
|
|
|
goto err;
|
|
|
|
}
|
2021-11-07 02:32:20 +00:00
|
|
|
for(unsigned x = 0 ; x < dimx ; ++x){
|
2020-09-17 19:34:28 +00:00
|
|
|
if(ncplane_set_bg_rgb8(n, r, g, b)){
|
2019-12-25 04:55:48 +00:00
|
|
|
goto err;
|
|
|
|
}
|
2020-08-31 23:39:07 +00:00
|
|
|
if(ncplane_putchar(n, 'x') <= 0){
|
2019-12-25 04:55:48 +00:00
|
|
|
goto err;
|
|
|
|
}
|
2019-12-16 04:13:13 +00:00
|
|
|
if(g % 2){
|
2019-12-25 04:55:48 +00:00
|
|
|
if(--b <= 0){
|
2019-12-16 04:13:13 +00:00
|
|
|
++g;
|
|
|
|
b = 0;
|
|
|
|
}
|
|
|
|
}else{
|
2019-12-25 04:55:48 +00:00
|
|
|
if(++b >= 256){
|
2019-12-16 04:13:13 +00:00
|
|
|
++g;
|
2019-12-25 04:55:48 +00:00
|
|
|
b = 255;
|
2019-12-16 04:13:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(notcurses_render(nc)){
|
|
|
|
notcurses_stop(nc);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
notcurses_stop(nc);
|
|
|
|
return EXIT_SUCCESS;
|
2019-12-25 04:55:48 +00:00
|
|
|
|
|
|
|
err:
|
|
|
|
notcurses_stop(nc);
|
|
|
|
return EXIT_FAILURE;
|
2019-12-16 04:13:13 +00:00
|
|
|
}
|