مصطفی ساتکی
دوشنبه 02 خرداد 1390, 09:07 صبح
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const N =500;
N2 = 250;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure DrawWave(Bit : TBitmap;Ticks : Integer);
var x,y : Integer;
p : PByte;
Gray : byte;
d : Double;
dy ,dx : Integer;
begin
for y := 0 to Bit.Height-1 do
begin
dy := y - N2;
p := Bit.ScanLine[y];
for x := 0 to Bit.Width-1 do
begin
dx := x - N2;
d := sqrt( dx*dx + dy*dy);
Gray :=round( 128 + 127 *(cos(d/10-Ticks/7)/ (d/10 +1)));
p^ := Gray;
inc(p);
p^ := Gray;
inc(p);
p^ := Gray;
inc(p);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var bit : TBitmap;
i : Integer;
begin
bit := TBitmap.Create;
with bit do
begin
PixelFormat := pf24bit;
Width := N;
Height := N;
end;
for i := 0 to 200 do
begin
DrawWave(bit,50+i);
Canvas.Draw(0,0,bit);
Application.ProcessMessages;
end;
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const N =500;
N2 = 250;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure DrawWave(Bit : TBitmap;Ticks : Integer);
var x,y : Integer;
p : PByte;
Gray : byte;
d : Double;
dy ,dx : Integer;
begin
for y := 0 to Bit.Height-1 do
begin
dy := y - N2;
p := Bit.ScanLine[y];
for x := 0 to Bit.Width-1 do
begin
dx := x - N2;
d := sqrt( dx*dx + dy*dy);
Gray :=round( 128 + 127 *(cos(d/10-Ticks/7)/ (d/10 +1)));
p^ := Gray;
inc(p);
p^ := Gray;
inc(p);
p^ := Gray;
inc(p);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var bit : TBitmap;
i : Integer;
begin
bit := TBitmap.Create;
with bit do
begin
PixelFormat := pf24bit;
Width := N;
Height := N;
end;
for i := 0 to 200 do
begin
DrawWave(bit,50+i);
Canvas.Draw(0,0,bit);
Application.ProcessMessages;
end;
end;
end.