fix linear interpolation on large geometries #216

This commit is contained in:
nick black 2019-12-25 00:12:21 -05:00
parent 7424b3b78c
commit 8d26803ed8
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC

View File

@ -1289,12 +1289,12 @@ int ncplane_hline_interp(ncplane* n, const cell* c, int len,
br1 = ur; bg1 = ug; bb1 = ub; br1 = ur; bg1 = ug; bb1 = ub;
channels_get_bg_rgb(c2, &ur, &ug, &ub); channels_get_bg_rgb(c2, &ur, &ug, &ub);
br2 = ur; bg2 = ug; bb2 = ub; br2 = ur; bg2 = ug; bb2 = ub;
int deltr = (r2 - r1) / (len + 1); int deltr = r2 - r1;
int deltg = (g2 - g1) / (len + 1); int deltg = g2 - g1;
int deltb = (b2 - b1) / (len + 1); int deltb = b2 - b1;
int deltbr = (br2 - br1) / (len + 1); int deltbr = br2 - br1;
int deltbg = (bg2 - bg1) / (len + 1); int deltbg = bg2 - bg1;
int deltbb = (bb2 - bb1) / (len + 1); int deltbb = bb2 - bb1;
int ret; int ret;
cell dupc = CELL_TRIVIAL_INITIALIZER; cell dupc = CELL_TRIVIAL_INITIALIZER;
if(cell_duplicate(n, &dupc, c) < 0){ if(cell_duplicate(n, &dupc, c) < 0){
@ -1308,17 +1308,17 @@ int ncplane_hline_interp(ncplane* n, const cell* c, int len,
bgdef = true; bgdef = true;
} }
for(ret = 0 ; ret < len ; ++ret){ for(ret = 0 ; ret < len ; ++ret){
r1 += deltr; int r = (deltr * ret) / len + r1;
g1 += deltg; int g = (deltg * ret) / len + g1;
b1 += deltb; int b = (deltb * ret) / len + b1;
br1 += deltbr; int br = (deltbr * ret) / len + br1;
bg1 += deltbg; int bg = (deltbg * ret) / len + bg1;
bb1 += deltbb; int bb = (deltbb * ret) / len + bb1;
if(!fgdef){ if(!fgdef){
cell_set_fg_rgb(&dupc, r1, g1, b1); cell_set_fg_rgb(&dupc, r, g, b);
} }
if(!bgdef){ if(!bgdef){
cell_set_bg_rgb(&dupc, br1, bg1, bb1); cell_set_bg_rgb(&dupc, br, bg, bb);
} }
if(ncplane_putc(n, &dupc) <= 0){ if(ncplane_putc(n, &dupc) <= 0){
break; break;