pixelplots: paint only through egcidx #1382

pull/2091/head
nick black 3 years ago committed by nick black
parent 242ec7a7bf
commit 1571bfee72

@ -4,6 +4,8 @@ rearrangements of Notcurses.
* 2.3.17 (not yet released)
* Added `notcurses_enter_alternate_screen()` and
`notcurses_leave_alternate_screen()`.
* Added `ncplane_boundlist()`.
* Plots now support `NCBLIT_PIXEL`!
* 2.3.16 (2021-08-19)
* Fix `ncdirect_set_*_rgb()` for the case where an emulator has fewer than

@ -839,6 +839,9 @@ int ncplane_resize_realign(struct ncplane* n);
struct ncplane* ncplane_parent(struct ncplane* n);
const struct ncplane* ncplane_parent_const(const struct ncplane* n);
// Get the head of the list of planes bound to 'n'.
struct ncplane* ncplane_boundlist(struct ncplane* n);
// Duplicate an existing ncplane. The new plane will have the same geometry,
// will duplicate all content, and will start with the same rendering state.
struct ncplane* ncplane_dup(struct ncplane* n, void* opaque);

@ -1550,8 +1550,14 @@ API int ncplane_abs_y(const struct ncplane* n) __attribute__ ((pure));
API int ncplane_abs_x(const struct ncplane* n) __attribute__ ((pure));
// Get the plane to which the plane 'n' is bound, if any.
API struct ncplane* ncplane_parent(struct ncplane* n);
API const struct ncplane* ncplane_parent_const(const struct ncplane* n);
API struct ncplane* ncplane_parent(struct ncplane* n)
__attribute__ ((nonnull (1)));
API const struct ncplane* ncplane_parent_const(const struct ncplane* n)
__attribute__ ((nonnull (1)));
// Get the head of the list of planes bound to 'n'.
API struct ncplane* ncplane_boundlist(struct ncplane* n)
__attribute__ ((nonnull (1)));
// Return non-zero iff 'n' is a proper descendent of 'ancestor'.
static inline int

@ -582,6 +582,10 @@ int demo_render(struct notcurses* nc){
clock_gettime(CLOCK_MONOTONIC, &ts);
if(plot){
if(!plot_hidden){
struct ncplane* pixelp = ncplane_boundlist(ncuplot_plane(plot));
if(pixelp){
ncplane_move_top(pixelp);
}
ncplane_move_top(ncuplot_plane(plot));
}
uint64_t ns = (timespec_to_ns(&ts) - plottimestart) / (NANOSECS_IN_SEC / FPSHZ);
@ -660,7 +664,7 @@ int fpsgraph_init(struct notcurses* nc){
opts.flags = NCPLOT_OPTION_LABELTICKSD |
NCPLOT_OPTION_EXPONENTIALD |
NCPLOT_OPTION_PRINTSAMPLE;
opts.gridtype = NCBLIT_BRAILLE;
opts.gridtype = NCBLIT_PIXEL;
opts.legendstyle = NCSTYLE_ITALIC | NCSTYLE_BOLD;
opts.title = "frames per semisecond";
ncchannels_set_fg_rgb8(&opts.minchannels, 0x80, 0x80, 0xff);

@ -2416,6 +2416,10 @@ const ncplane* ncplane_parent_const(const ncplane* n){
return n->boundto;
}
ncplane* ncplane_boundlist(ncplane* n){
return n->blist;
}
void ncplane_set_resizecb(ncplane* n, int(*resizecb)(ncplane*)){
if(n == notcurses_stdplane(ncplane_notcurses(n))){
return;

@ -138,7 +138,6 @@ int redraw_pixelplot_##T(nc##X##plot* ncp){ \
bool done = !ncp->plot.bset->fill; \
for(int y = 0 ; y < dimy ; ++y){ \
uint64_t channels = 0; \
ncplane_set_channels(ncp->plot.ncp, channels); \
/* if we've got at least one interval's worth on the number of positions \
times the number of intervals per position plus the starting offset, \
we're going to print *something* */ \
@ -154,7 +153,7 @@ int redraw_pixelplot_##T(nc##X##plot* ncp){ \
egcidx = (gvals[i] - intervalbase) / interval; \
} \
if(egcidx >= states){ \
egcidx = states - 1; \
egcidx = states; \
done = false; \
} \
}else{ \
@ -162,16 +161,14 @@ int redraw_pixelplot_##T(nc##X##plot* ncp){ \
} \
/* FIXME take egcidx into account for height..scale is wide, states is high */ \
/*fprintf(stderr, "WRITING TO y/x %d/%d (%zu)\n", y, x, dimx * dimy * scale * states); */\
if(egcidx){ \
for(size_t yy = 0 ; yy < states ; ++yy){ \
int poff = x * scale + i + ((y * states + yy) * dimx * scale); \
calc_gradient_channels(&channels, ncp->plot.minchannels, ncp->plot.minchannels, \
ncp->plot.maxchannels, ncp->plot.maxchannels, \
y * states + yy, x, dimy * states, dimx); \
uint32_t color = ncchannels_fg_rgb(channels); \
ncpixel_set_a(&color, 0xff); \
pixels[poff] = color; \
} \
for(size_t yy = 0 ; yy < egcidx ; ++yy){ \
int poff = x * scale + i + ((y * states + yy) * dimx * scale); \
calc_gradient_channels(&channels, ncp->plot.minchannels, ncp->plot.minchannels, \
ncp->plot.maxchannels, ncp->plot.maxchannels, \
y * states + yy, x, dimy * states, dimx); \
uint32_t color = ncchannels_fg_rgb(channels); \
ncpixel_set_a(&color, 0xff); \
pixels[poff] = color; \
} \
} \
if(done){ \

Loading…
Cancel
Save