Skip to content

Commit

Permalink
pixelplot: set primary plane transparent but on top #1382
Browse files Browse the repository at this point in the history
  • Loading branch information
dankamongmen committed Aug 22, 2021
1 parent 2b73c80 commit 138e3b3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/lib/plot.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,19 @@ update_sample_double(ncdplot* ncp, int64_t x, double y, bool reset){
}
}

static inline int
create_pixelp(ncplot *p, ncplane* n){
if(((p->pixelp = ncplane_dup(n, NULL)) == NULL)){
return -1;
}
ncplane_move_below(p->pixelp, n);
uint64_t basechan = 0;
ncchannels_set_bg_alpha(&basechan, NCALPHA_TRANSPARENT);
ncchannels_set_fg_alpha(&basechan, NCALPHA_TRANSPARENT);
ncplane_set_base(n, "", 0, basechan);
return 0;
}

// takes ownership of n on all paths
ncuplot* ncuplot_create(ncplane* n, const ncplot_options* opts, uint64_t miny, uint64_t maxy){
ncuplot* ret = malloc(sizeof(*ret));
Expand All @@ -633,7 +646,7 @@ ncuplot* ncuplot_create(ncplane* n, const ncplot_options* opts, uint64_t miny, u
return NULL;
}
if(bset->geom == NCBLIT_PIXEL){
if(((ret->plot.pixelp = ncplane_dup(n, NULL)) == NULL)){
if(create_pixelp(&ret->plot, n)){
ncuplot_destroy(ret);
return NULL;
}
Expand Down Expand Up @@ -682,7 +695,7 @@ ncdplot* ncdplot_create(ncplane* n, const ncplot_options* opts, double miny, dou
return NULL;
}
if(bset->geom == NCBLIT_PIXEL){
if(((ret->plot.pixelp = ncplane_dup(n, NULL)) == NULL)){
if(create_pixelp(&ret->plot, n)){
ncdplot_destroy(ret);
return NULL;
}
Expand Down

0 comments on commit 138e3b3

Please sign in to comment.