Bresenham改進算法結合wu反走樣算法畫顏色漸變直線
Bresenham改進算法結合wu反走樣算法畫顏色漸變直線在上一篇文章 Bresenham改進算法結合wu反走樣算法畫直線基礎上進行了修改,利用插值漸變原理實現
具體代碼如下:
CRGB CLine::InterPolation(double i, double dx, CRGB c1, CRGB c2)
{
CRGB c;
c=(dx-i)/dx*c1+i/dx*c2;
return c;
}
p.clr=InterPolation(double(i),double(dx),P0.clr,P1.clr);
pDC->SetPixelV(Round(p.x),Round(p.y),RGB(p.clr.r,p.clr.g,p.clr.b));
p.clr=InterPolation(double(i),double(dx),P0.clr,P1.clr);
pDC->SetPixelV(Round(p.x),Round(p.y),RGB((br-p.clr.r)*e+p.clr.r,(bg-p.clr.g)*e+p.clr.g,(bb-p.clr.b)*e+p.clr.b));
if(!interchange)
b=p.y+s2;
else
a=p.x+s1;
pDC->SetPixelV(Round(a),Round(b),RGB((br-p.clr.r)*(1.0-e)+p.clr.r,(bg-p.clr.g)*(1.0-e)+p.clr.g,(bb-p.clr.b)*(1.0-e)+p.clr.b));