update demos for ncplane_aligned #237

This commit is contained in:
nick black 2019-12-30 02:43:33 -05:00
parent 2ea4f77875
commit 32ff214be2
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
3 changed files with 8 additions and 6 deletions

View File

@ -63,13 +63,15 @@ outro_message(struct notcurses* nc, int* rows, int* cols){
const char str0[] = " ATL, baby! ATL! ";
const char str1[] = " throw your hands in the air ";
const char str2[] = " hack on! —dank❤ ";
int xs = (*cols - (strlen(str1) + 4)) / 2;
int ystart = *rows - 6;
*cols = xs;
struct ncplane* non = ncplane_new(nc, 5, strlen(str1) + 4, ystart, *cols, NULL);
struct ncplane* non = ncplane_aligned(notcurses_stdplane(nc), 5,
strlen(str1) + 4, ystart,
NCALIGN_CENTER, NULL);
if(non == NULL){
return NULL;
}
int xs;
ncplane_yx(non, NULL, &xs);
cell bgcell = CELL_SIMPLE_INITIALIZER(' ');
channels_set_bg_rgb(&bgcell.channels, 0x58, 0x36, 0x58);
if(ncplane_set_base(non, &bgcell) < 0){

View File

@ -188,7 +188,7 @@ int sliding_puzzle_demo(struct notcurses* nc){
const int idx = cy * CHUNKS_HORZ + cx;
chunks[idx] =
ncplane_new(nc, chunky, chunkx, cy * chunky + wastey + 1,
cx * chunkx + wastex + 1, NULL);
cx * chunkx + wastex + 1, NULL);
if(chunks[idx] == NULL){
goto done;
}

View File

@ -176,9 +176,9 @@ int unicodeblocks_demo(struct notcurses* nc){
if(ncplane_printf_aligned(n, 1, NCALIGN_CENTER, "Unicode points %05x%05x", blockstart, blockstart + BLOCKSIZE) <= 0){
return -1;
}
int xstart = (maxx - ((CHUNKSIZE * 2) + 3)) / 2;
struct ncplane* nn;
if((nn = ncplane_new(nc, BLOCKSIZE / CHUNKSIZE + 2, (CHUNKSIZE * 2) + 2, 3, xstart, NULL)) == NULL){
if((nn = ncplane_aligned(notcurses_stdplane(nc), BLOCKSIZE / CHUNKSIZE + 2,
(CHUNKSIZE * 2) + 2, 3, NCALIGN_CENTER, NULL)) == NULL){
return -1;
}
if(hud){