griddemo: inverse

pull/30/head
nick black 5 years ago
parent 3d5ba40352
commit 7173f628ee
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -1,6 +1,70 @@
#include <unistd.h>
#include "demo.h"
static int
gridinv_demo(struct notcurses* nc, struct ncplane *n,
cell* ul, cell* uc, cell* ur,
cell* cl, cell* cc, cell* cr,
cell* ll, cell* lc, cell* lr){
int maxx, maxy;
notcurses_term_dimyx(nc, &maxy, &maxx);
int rs = 256 / maxx;
int gs = 256 / (maxx + maxy);
int bs = 256 / maxy;
int x = 0;
int y = 0;
if(ncplane_cursor_move_yx(n, y, x)){
return -1;
}
// top line
cell_set_fg(ul, 0, 0, 0);
cell_set_bg(ul, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, ul);
for(x = 1 ; x < maxx - 1 ; ++x){
cell_set_fg(uc, 0, 0, 0);
cell_set_bg(uc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, uc);
}
cell_set_fg(ur, 0, 0, 0);
cell_set_bg(ur, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, ur);
// center
x = 0;
for(y = 1 ; y < maxy - 1 ; ++y){
cell_set_fg(cl, 0, 0, 0);
cell_set_bg(cl, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, cl);
for(x = 1 ; x < maxx - 1 ; ++x){
cell_set_fg(cc, 0, 0, 0);
cell_set_bg(cc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, cc);
}
cell_set_fg(cr, 0, 0, 0);
cell_set_bg(cr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, cr);
}
// bottom line
x = 0;
cell_set_fg(ll, 0, 0, 0);
cell_set_bg(ll, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, ll);
for(x = 1 ; x < maxx - 1 ; ++x){
cell_set_fg(lc, 0, 0, 0);
cell_set_bg(lc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, lc);
}
cell_set_fg(lr, 0, 0, 0);
cell_set_bg(lr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, lr);
// render!
notcurses_render(nc);
sleep(1);
return 0;
}
// red across, blue down, green from UL to LR
int grid_demo(struct notcurses* nc){
int maxx, maxy;
@ -33,39 +97,42 @@ int grid_demo(struct notcurses* nc){
y = 0;
// top line
cell_set_fg(&ul, 255, 255, 255);
x = 0;
cell_set_fg(&ul, 255 - rs * x, 255, 255);
ncplane_putc(n, &ul);
for(x = 1 ; x < maxx - 1 ; ++x){
cell_set_fg(&uc, 255 - rs * x, 255 - gs * (x + y), 255);
ncplane_putc(n, &uc);
}
cell_set_fg(&ur, 1, 255 - gs * (x + y), 255);
cell_set_fg(&ur, 255 - rs * x, 255 - gs * (x + y), 255);
ncplane_putc(n, &ur);
// center
x = 0;
for(y = 1 ; y < maxy - 1 ; ++y){
cell_set_fg(&cl, 255, 255 - gs * (x + y), 255 - bs * y);
cell_set_fg(&cl, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, &cl);
for(x = 1 ; x < maxx - 1 ; ++x){
cell_set_fg(&cc, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, &cc);
}
cell_set_fg(&cr, 1, 255 - gs * (x + y), 255 - bs * y);
cell_set_fg(&cr, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
ncplane_putc(n, &cr);
}
// bottom line
cell_set_fg(&ll, 255, 255 - gs * (x + y), 1);
x = 0;
cell_set_fg(&ll, 255 - rs * x, 255 - gs * (x + y), 1);
ncplane_putc(n, &ll);
for(x = 1 ; x < maxx - 1 ; ++x){
cell_set_fg(&lc, 255 - rs * x, 255 - gs * (x + y), 1);
ncplane_putc(n, &lc);
}
cell_set_fg(&lr, 1, 255 - gs * (x + y), 1);
cell_set_fg(&lr, 255 - rs * x, 255 - gs * (x + y), 1);
ncplane_putc(n, &lr);
// render!
notcurses_render(nc);
sleep(1);
return 0;
return gridinv_demo(nc, n, &ul, &uc, &ur, &cl, &cc, &cr, &ll, &lc, &lr);
}

Loading…
Cancel
Save