Как реализовать градиент?
Автор: kenai
Исходная ссылка: - - -
Graphics::TBitmap *Gradient = new Graphics::TBitmap();
Gradient->Height = 50;
Gradient->Width = 50;
int h=Gradient->Height;
int w=Gradient->Height;
struct tRGB{int R,G,B;};
tRGB Color1,Color2;
Color1.R=214;
Color1.G=50;
Color1.B=50;
Color2.R=92;
Color2.G=44;
Color2.B=220;
double Rg=(Color2.R-Color1.R);
double Gg=(Color2.G-Color1.G);
double Bg=(Color2.B-Color1.B);
Rg/=w;
Gg/=w;
Bg/=w;
for(int i=0;i<w+1;i++)
for(int i2=0;i2<h+1;i2++)
{
Gradient->Canvas->Pixels[i][i2]=TColor(RGB(Color1.R+Rg*i,Color1.G+Gg*i,Color1.B+Bg*i));
}
Form1->Canvas->Draw(0,0,Gradient);
delete Gradient;
|