pull/1802/head
nick black 3 years ago
parent 6152f621ba
commit 091bc1e625
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

@ -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));

@ -0,0 +1,75 @@
#include <sys/random.h>
#include <notcurses/notcurses.h>
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;
}
Loading…
Cancel
Save