Fix in Colorband: the "B-Spline" interpolation didn't extend well, when a
marker wasn't on the first or last possible position. Caused by clipping. As bonus; added Cardinal interpolation option too, which is just that little bit different! (Cardinal goes through the controlpoints, bspline not)
This commit is contained in:
@@ -248,20 +248,32 @@ int do_colorband(ColorBand *coba, float in, float out[4])
|
||||
out[3]= cbd1->a;
|
||||
}
|
||||
else {
|
||||
if(in < cbd1->pos) {
|
||||
if(in < cbd1->pos && coba->ipotype<2) {
|
||||
out[0]= cbd1->r;
|
||||
out[1]= cbd1->g;
|
||||
out[2]= cbd1->b;
|
||||
out[3]= cbd1->a;
|
||||
}
|
||||
else {
|
||||
|
||||
CBData left, right;
|
||||
|
||||
/* we're looking for first pos > in */
|
||||
for(a=0; a<coba->tot; a++, cbd1++) if(cbd1->pos > in) break;
|
||||
|
||||
if(a==coba->tot) cbd1--;
|
||||
if(a==coba->tot) {
|
||||
cbd2= cbd1-1;
|
||||
right= *cbd2;
|
||||
right.pos= 1.0f;
|
||||
cbd1= &right;
|
||||
}
|
||||
else if(a==0) {
|
||||
left= *cbd1;
|
||||
left.pos= 0.0f;
|
||||
cbd2= &left;
|
||||
}
|
||||
else cbd2= cbd1-1;
|
||||
|
||||
if(in > cbd1->pos) {
|
||||
if(in > cbd1->pos && coba->ipotype<2) {
|
||||
out[0]= cbd1->r;
|
||||
out[1]= cbd1->g;
|
||||
out[2]= cbd1->b;
|
||||
@@ -269,10 +281,9 @@ int do_colorband(ColorBand *coba, float in, float out[4])
|
||||
}
|
||||
else {
|
||||
|
||||
cbd2= cbd1-1;
|
||||
fac= (in-cbd1->pos)/(cbd2->pos-cbd1->pos);
|
||||
|
||||
if(coba->ipotype==2) {
|
||||
if(coba->ipotype>=2) {
|
||||
/* ipo from right to left: 3 2 1 0 */
|
||||
|
||||
if(a>=coba->tot-1) cbd0= cbd1;
|
||||
@@ -280,7 +291,10 @@ int do_colorband(ColorBand *coba, float in, float out[4])
|
||||
if(a<2) cbd3= cbd2;
|
||||
else cbd3= cbd2-1;
|
||||
|
||||
set_four_ipo(fac, t, KEY_BSPLINE);
|
||||
if(coba->ipotype==3)
|
||||
set_four_ipo(fac, t, KEY_CARDINAL);
|
||||
else
|
||||
set_four_ipo(fac, t, KEY_BSPLINE);
|
||||
|
||||
out[0]= t[3]*cbd3->r +t[2]*cbd2->r +t[1]*cbd1->r +t[0]*cbd0->r;
|
||||
out[1]= t[3]*cbd3->g +t[2]*cbd2->g +t[1]*cbd1->g +t[0]*cbd0->g;
|
||||
|
||||
Reference in New Issue
Block a user