kitty: write transcolor pixel alpha as 0

when we're building out the kitty graphic, we check whether
alpha is low, or whether the color matches the transparent
color. in the latter case, we're writing the original alpha
to the auxvec. in rebuild, however, we don't know what the
transcolor was, and thus a pixel that matched it will become
visible. instead, rewrite alpha as 0 on transcolor match, so
that 0 is restored should we rebuild the cell.
This commit is contained in:
nick black 2021-07-21 01:14:10 -04:00 committed by nick black
parent fcd62a04ec
commit cc6bdf4b55
2 changed files with 4 additions and 1 deletions

View File

@ -551,6 +551,7 @@ write_kitty_data(FILE* fp, int linesize, int leny, int lenx, int cols,
tam[tyx].auxvector[vyx] = ncpixel_a(source[e]);
}
if(rgba_trans_p(source[e], transcolor)){
ncpixel_set_a(&source[e], 0); // in case it was transcolor
if(x % cdimx == 0 && y % cdimy == 0){
tam[tyx].state = SPRIXCELL_ANNIHILATED_TRANS;
}
@ -561,6 +562,7 @@ write_kitty_data(FILE* fp, int linesize, int leny, int lenx, int cols,
}else{
wipe[e] = 0;
if(rgba_trans_p(source[e], transcolor)){
ncpixel_set_a(&source[e], 0); // in case it was transcolor
if(x % cdimx == 0 && y % cdimy == 0){
tam[tyx].state = SPRIXCELL_TRANSPARENT;
}else if(tam[tyx].state == SPRIXCELL_OPAQUE_KITTY){

View File

@ -179,7 +179,8 @@ int sprite_wipe(const notcurses* nc, sprixel* s, int ycell, int xcell){
int idx = s->dimx * ycell + xcell;
if(s->n->tam[idx].state == SPRIXCELL_TRANSPARENT){
// need to make a transparent auxvec, because a reload will force us to
// update said auxvec.
// update said auxvec, but needn't actually change the glyph. auxvec will
// be entirely 0s coming from pixel_trans_auxvec().
if(s->n->tam[idx].auxvector == NULL){
s->n->tam[idx].auxvector = nc->tcache.pixel_trans_auxvec(&nc->tcache);
if(s->n->tam[idx].auxvector == NULL){