[intro] manually resize greatscott to always hit cell boundary

This commit is contained in:
nick black 2021-04-20 06:11:12 -04:00
parent 16c47430d6
commit 71c7432e46
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -29,7 +29,7 @@ animate(struct notcurses* nc, struct ncplane* ncp, void* curry){
} }
static struct ncplane* static struct ncplane*
greatscott(struct notcurses* nc){ greatscott(struct notcurses* nc, int dimx){
char* path = find_data("greatscott.jpg"); char* path = find_data("greatscott.jpg");
if(path == NULL){ if(path == NULL){
return NULL; return NULL;
@ -39,11 +39,17 @@ greatscott(struct notcurses* nc){
if(ncv == NULL){ if(ncv == NULL){
return NULL; return NULL;
} }
int celldimy, celldimx;
ncplane_pixelgeom(notcurses_stdplane(nc), NULL, NULL, &celldimy, &celldimx, NULL, NULL);
if(ncvisual_resize(ncv, 18 * celldimy, celldimx * (dimx - 2))){
ncvisual_destroy(ncv);
return NULL;
}
struct ncvisual_options vopts = { struct ncvisual_options vopts = {
.y = 2, .y = 2,
.x = NCALIGN_CENTER, .x = NCALIGN_CENTER,
.blitter = NCBLIT_PIXEL, .blitter = NCBLIT_PIXEL,
.scaling = NCSCALE_SCALE, .scaling = NCSCALE_NONE,
.flags = NCVISUAL_OPTION_NODEGRADE | NCVISUAL_OPTION_HORALIGNED, .flags = NCVISUAL_OPTION_NODEGRADE | NCVISUAL_OPTION_HORALIGNED,
}; };
struct ncplane* n = ncvisual_render(nc, ncv, &vopts); struct ncplane* n = ncvisual_render(nc, ncv, &vopts);
@ -242,7 +248,7 @@ int intro(struct notcurses* nc){
ncplane_destroy(on); ncplane_destroy(on);
struct ncplane* gscott = NULL; struct ncplane* gscott = NULL;
if(notcurses_check_pixel_support(nc) && notcurses_canopen_images(nc)){ if(notcurses_check_pixel_support(nc) && notcurses_canopen_images(nc)){
if((gscott = greatscott(nc)) == NULL){ if((gscott = greatscott(nc, cols)) == NULL){
return -1; return -1;
} }
DEMO_RENDER(nc); DEMO_RENDER(nc);