intro: always fit orca to available size #2015

This commit is contained in:
nick black 2021-08-03 12:47:13 -05:00
parent cdb884a787
commit c3531b22bf

View File

@ -80,14 +80,16 @@ orcashow(struct notcurses* nc, int dimy, int dimx){
}; };
int odimy, odimx, scaley, scalex; int odimy, odimx, scaley, scalex;
ncvisual_blitter_geom(nc, ncv, &vopts, &odimy, &odimx, &scaley, &scalex, NULL); ncvisual_blitter_geom(nc, ncv, &vopts, &odimy, &odimx, &scaley, &scalex, NULL);
int rows = (odimy / scaley) + !!(odimy % scaley); vopts.leny = (odimy / scaley) + !!(odimy % scaley);
int cols = (odimx / scalex) + !!(odimx % scalex); vopts.lenx = (odimx / scalex) + !!(odimx % scalex);
if(cols > dimx || rows > dimy - 1){ if(vopts.lenx > dimx - 1){
ncvisual_destroy(ncv); vopts.lenx = dimx - 1;
return NULL;
} }
vopts.y = dimy - rows - 1; if(vopts.leny > dimy - 1){
vopts.x = dimx - cols; vopts.leny = dimy - 1;
}
vopts.y = dimy - vopts.leny - 1;
vopts.x = dimx - vopts.lenx - 1;
struct ncplane* n = ncvisual_render(nc, ncv, &vopts); struct ncplane* n = ncvisual_render(nc, ncv, &vopts);
ncvisual_destroy(ncv); ncvisual_destroy(ncv);
return n; return n;