[intro] don't require pixels for orca

This commit is contained in:
nick black 2021-09-26 07:18:52 -04:00
parent 8585c0a8a9
commit 2239e1c7fc
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -76,21 +76,36 @@ orcashow(struct notcurses* nc, int dimy, int dimx){
}
struct ncvisual_options vopts = {
.blitter = NCBLIT_PIXEL,
.flags = NCVISUAL_OPTION_NODEGRADE,
.scaling = NCSCALE_STRETCH,
};
int cellpxy, cellpxx;
ncplane_pixelgeom(notcurses_stdplane_const(nc), NULL, NULL,
&cellpxy, &cellpxx, NULL, NULL);
int odimy, odimx, scaley, scalex;
ncvisual_blitter_geom(nc, ncv, &vopts, &odimy, &odimx, &scaley, &scalex, NULL);
vopts.leny = (odimy / scaley) + !!(odimy % scaley);
vopts.lenx = (odimx / scalex) + !!(odimx % scalex);
if(vopts.lenx > dimx - 1){
vopts.lenx = dimx - 1;
struct ncplane_options nopts = {
.rows = (odimy / cellpxy) + !!(odimy % cellpxy),
.cols = (odimx / cellpxx) + !!(odimx % cellpxx),
.name = "orca",
};
if(nopts.cols > dimx - 1){
nopts.cols = dimx - 1;
}
if(vopts.leny > dimy - 1){
vopts.leny = dimy - 1;
if(nopts.rows > dimy - 1){
nopts.rows = dimy - 1;
}
nopts.y = dimy - nopts.rows - 1;
nopts.x = dimx - nopts.cols - 1;
struct ncplane* n = ncplane_create(notcurses_stdplane(nc), &nopts);
if(n == NULL){
ncvisual_destroy(ncv);
return NULL;
}
vopts.n = n;
if(ncvisual_render(nc, ncv, &vopts) == NULL){
ncplane_destroy(n);
ncvisual_destroy(ncv);
}
vopts.y = dimy - vopts.leny - 1;
vopts.x = dimx - vopts.lenx - 1;
struct ncplane* n = ncvisual_render(nc, ncv, &vopts);
ncvisual_destroy(ncv);
return n;
}
@ -245,9 +260,8 @@ int intro(struct notcurses* nc){
clock_gettime(CLOCK_MONOTONIC, &now);
int err;
if(!on){
if(notcurses_check_pixel_support(nc) && notcurses_canopen_images(nc)){
on = orcashow(nc, rows, cols);
if(on == NULL){
if(notcurses_canopen_images(nc)){
if((on = orcashow(nc, rows, cols)) == NULL){
return -1;
}
}