mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
keller demo #736
This commit is contained in:
parent
4203c2402f
commit
4effee947a
@ -1,6 +1,51 @@
|
||||
#include "demo.h"
|
||||
|
||||
int keller_demo(struct notcurses* nc){
|
||||
// FIXME
|
||||
// show it with each blitter, with a legend
|
||||
static int
|
||||
visualize(struct notcurses* nc, struct ncvisual* ncv){
|
||||
for(ncblitter_e b = NCBLIT_DEFAULT + 1 ; b < NCBLIT_SIXEL ; ++b){
|
||||
struct timespec ts = { .tv_sec = 1, .tv_nsec = 0, };
|
||||
struct ncvisual_options vopts = {
|
||||
.scaling = NCSCALE_STRETCH,
|
||||
.blitter = b,
|
||||
};
|
||||
struct ncplane* n = ncvisual_render(nc, ncv, &vopts);
|
||||
if(n == NULL){
|
||||
return -1;
|
||||
}
|
||||
const char* name = notcurses_str_blitter(b);
|
||||
ncplane_set_bg_rgb(n, 0);
|
||||
int scalex, scaley, truey, truex;
|
||||
ncvisual_geom(nc, ncv, &vopts, &truey, &truex, &scaley, &scalex);
|
||||
ncplane_printf_aligned(n, ncplane_dim_y(n) / 2 - 1, NCALIGN_CENTER,
|
||||
"%dx%d", truex, truey);
|
||||
ncplane_putstr_aligned(n, ncplane_dim_y(n) / 2, NCALIGN_CENTER, name);
|
||||
ncplane_printf_aligned(n, ncplane_dim_y(n) / 2 + 1, NCALIGN_CENTER,
|
||||
"%d:%d pixels -> cell", scalex, scaley);
|
||||
int ret = demo_render(nc);
|
||||
demo_nanosleep(nc, &ts);
|
||||
ncplane_destroy(n);
|
||||
if(ret){
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int keller_demo(struct notcurses* nc){
|
||||
if(!notcurses_canopen_images(nc)){
|
||||
return 0;
|
||||
}
|
||||
char* file = find_data("covid19.jpg");
|
||||
if(file == NULL){
|
||||
return -1;
|
||||
}
|
||||
struct ncvisual* ncv = ncvisual_from_file(file);
|
||||
free(file);
|
||||
if(ncv == NULL){
|
||||
return -1;
|
||||
}
|
||||
int r = visualize(nc, ncv);
|
||||
ncvisual_destroy(ncv);
|
||||
return r;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user