1 #include <cstdio>
2 #include <cstdlib>
3 #include <clocale>
4 #include <notcurses/notcurses.h>
5 
main()6 auto main() -> int {
7   if(!setlocale(LC_ALL, "")){
8     fprintf(stderr, "Couldn't set locale\n");
9     return EXIT_FAILURE;
10   }
11   notcurses_options opts{};
12   opts.flags = NCOPTION_INHIBIT_SETLOCALE | NCOPTION_NO_ALTERNATE_SCREEN;
13   struct notcurses* nc = notcurses_init(&opts, nullptr);
14   if(nc == nullptr){
15     return EXIT_FAILURE;
16   }
17   unsigned dimy, dimx;
18   struct ncplane* n = notcurses_stdplane(nc);
19   ncplane_dim_yx(n, &dimy, &dimx);
20   int r , g, b;
21   r = 0;
22   g = 0x80;
23   b = 0;
24   ncplane_set_fg_rgb8(n, 0x40, 0x20, 0x40);
25   for(unsigned y = 0 ; y < dimy ; ++y){
26     if(ncplane_cursor_move_yx(n, y, 0)){
27       goto err;
28     }
29     for(unsigned x = 0 ; x < dimx ; ++x){
30       if(ncplane_set_bg_rgb8(n, r, g, b)){
31         goto err;
32       }
33       if(ncplane_putchar(n, 'x') <= 0){
34         goto err;
35       }
36       if(g % 2){
37         if(--b <= 0){
38           ++g;
39           b = 0;
40         }
41       }else{
42         if(++b >= 256){
43           ++g;
44           b = 255;
45         }
46       }
47     }
48   }
49   if(notcurses_render(nc)){
50     notcurses_stop(nc);
51     return EXIT_FAILURE;
52   }
53   notcurses_stop(nc);
54   return EXIT_SUCCESS;
55 
56 err:
57   notcurses_stop(nc);
58   return EXIT_FAILURE;
59 }
60