程序如下:
me选了一个不太好的函数作渐变函数(//shy),exp下降太快,不得不对局离开了
几重根号;计算距离只对1/16的正方形进行,可充分利用它的对称性.
image大小:200*200
procedure TForm1.FormCreate(Sender: TObject);
var
i,j:integer;
Saturation:array [0..3] of Integer;
begin
for i:=0 to 100do
for j:=0 to ido
begin
Saturation[0]:=round(255*exp(-Sqrt(Sqrt(Sqrt(Sqrt((i-50)*(i-50)+(j-50)*(j-50)))))));
Saturation[1]:=round(255*Exp(-Sqrt(Sqrt(Sqrt(Sqrt((i-150)*(i-150)+(j-50)*(j-50)))))));
Saturation[2]:=round(255*Exp(-Sqrt(Sqrt(Sqrt(Sqrt((i-50)*(i-50)+(j-150)*(j-150)))))));
Saturation[3]:=round(255*Exp(-SQrt(Sqrt(Sqrt(Sqrt((i-150)*(i-150)+(j-150)*(j-150)))))));
Image1.Canvas.Pixels[i,j]:=RGB(Saturation[0]+Saturation[3],
Saturation[1]+Saturation[3],saturation[2]+Saturation[3]);
Image1.Canvas.Pixels[j,i]:=RGB(Saturation[0]+Saturation[3],
Saturation[2]+Saturation[3],saturation[1]+Saturation[3]);
Image1.Canvas.Pixels[j,200-i]:=RGB(Saturation[1]+Saturation[2],Saturation[3]+Saturation[2],saturation[0]+Saturation[2]);
Image1.Canvas.Pixels[i,200-j]:=RGB(Saturation[2]+Saturation[1],Saturation[3]+Saturation[1],saturation[0]+Saturation[1]);
Image1.Canvas.Pixels[200-i,200-j]:=RGB(Saturation[3]+Saturation[0],Saturation[2]+Saturation[0],saturation[1]+Saturation[0]);
Image1.Canvas.Pixels[200-j,200-i]:=RGB(Saturation[3]+Saturation[0],Saturation[1]+Saturation[0],saturation[2]+Saturation[0]);
Image1.Canvas.Pixels[200-j,i]:=RGB(Saturation[2]+Saturation[1],Saturation[0]+Saturation[1],saturation[3]+Saturation[1]);
Image1.Canvas.Pixels[200-i,j]:=RGB(Saturation[1]+Saturation[2],Saturation[0]+Saturation[2],saturation[3]+Saturation[2]);
end
end;