diff --git a/src/lib/stats.c b/src/lib/stats.c index e089b110b..751848df5 100644 --- a/src/lib/stats.c +++ b/src/lib/stats.c @@ -201,7 +201,7 @@ void summarize_stats(notcurses* nc){ stats->fgelisions, stats->bgemissions, stats->bgelisions); - fprintf(stderr, "Cell emits:elides: %ju/%ju (%.2f%%) %.2f%% %.2f%% %.2f%%\n", + fprintf(stderr, "Cell emits:elides: %ju:%ju (%.2f%%) %.2f%% %.2f%% %.2f%%\n", stats->cellemissions, stats->cellelisions, (stats->cellemissions + stats->cellelisions) == 0 ? 0 : (stats->cellelisions * 100.0) / (stats->cellemissions + stats->cellelisions), @@ -211,7 +211,7 @@ void summarize_stats(notcurses* nc){ (stats->fgelisions * 100.0) / (stats->fgemissions + stats->fgelisions), (stats->bgemissions + stats->bgelisions) == 0 ? 0 : (stats->bgelisions * 100.0) / (stats->bgemissions + stats->bgelisions)); - fprintf(stderr, "Sprixel emits:elides: %ju/%ju (%.2f%%)\n", + fprintf(stderr, "Sprixel emits:elides: %ju:%ju (%.2f%%)\n", stats->sprixelemissions, stats->sprixelelisions, (stats->sprixelemissions + stats->sprixelelisions) == 0 ? 0 : (stats->sprixelelisions * 100.0) / (stats->sprixelemissions + stats->sprixelelisions)); diff --git a/src/poc/interp.c b/src/poc/interp.c new file mode 100644 index 000000000..2f471e3a5 --- /dev/null +++ b/src/poc/interp.c @@ -0,0 +1,75 @@ +#include +#include + +static int +interp(struct notcurses* nc, int cellpixy, int cellpixx){ + struct ncplane* stdn = notcurses_stdplane(nc); + ncplane_printf_yx(stdn, 0, 0, "cellpix: %d/%d", cellpixy, cellpixx); + ncplane_printf_yx(stdn, 10, 0, "press any key to continue"); + size_t rands = cellpixy * cellpixx * 3; + unsigned char* randrgb = malloc(rands); + getrandom(randrgb, rands, GRND_NONBLOCK); + struct ncvisual* ncv = ncvisual_from_rgb_packed(randrgb, cellpixy, cellpixx * 3, cellpixx, 0xff); + if(ncv == NULL){ + return -1; + } + struct ncvisual_options vopts = { + .y = 1, + .blitter = NCBLIT_PIXEL, + }; + struct ncplane* ncvp = ncvisual_render(nc, ncv, &vopts); + if(ncvp == NULL){ + return -1; + } + struct ncplane_options popts = { + .y = 3, + .x = 1, + .rows = 6, + .cols = 12, + }; + struct ncplane* scalep = ncplane_create(stdn, &popts); + vopts.y = 0; + vopts.n = scalep; + vopts.scaling = NCSCALE_STRETCH; + popts.x += ncplane_dim_x(scalep) + 1; + if(ncvisual_render(nc, ncv, &vopts) == NULL){ + return -1; + } + struct ncplane* scalepni = ncplane_create(stdn, &popts); + vopts.n = scalepni; + vopts.flags = NCVISUAL_OPTION_NOINTERPOLATE; + if(ncvisual_render(nc, ncv, &vopts) == NULL){ + return -1; + } +notcurses_debug(nc, stderr); + ncvisual_destroy(ncv); + notcurses_render(nc); + ncplane_destroy(ncvp); + ncplane_destroy(scalep); + ncplane_destroy(scalepni); + return 0; +} + +int main(void){ + struct notcurses_options nopts = { + .loglevel = NCLOGLEVEL_TRACE, + }; + struct notcurses* nc = notcurses_init(&nopts, NULL); + if(nc == NULL){ + return EXIT_FAILURE; + } + struct ncplane* stdn = notcurses_stdplane(nc); + int cellpixy, cellpixx; + ncplane_pixelgeom(stdn, NULL, NULL, &cellpixy, &cellpixx, NULL, NULL); + if(interp(nc, cellpixy, cellpixx)){ + goto err; + } + ncinput ni; + notcurses_getc_blocking(nc, &ni); + notcurses_stop(nc); + return EXIT_SUCCESS; + +err: + notcurses_stop(nc); + return EXIT_FAILURE; +}