end;
procedure TMainForm.OneMore;
var
dx, dy, Rand, Kx, Ky: word;
A, B, C, D, E, F: real;
x, y, K: real;
i: longint;
begin
Kx := 4; Ky := 4;
dx := (xEnd-xStart+1) div Kx; xEnd := xStart +Kx*dx - 1;
dy := (yEnd-yStart+1) div Ky; yEnd := yStart +Ky*dy - 1;
x := xStart; y := yStart;
for i := 1 to 100000 do begin
Rand := Random(Kx*Ky);
if (Rand = 0) or (Rand = 3) or (Rand = 12) or (Rand = 15) then
Continue;
K := (Rand - Kx*(Rand div Kx)) *dx;
x := K + xStart + 1 + (x-xStart+1) / Kx;
K := (Rand div Kx)*dy;
y := K + yStart + 1 + (y-yStart+1) / Ky;
Image.Canvas.Pixels[Round(x),Round(y)] := clBlue;
end; { for i }
end;
procedure TMainForm.Onemore1Click(Sender: TObject);
begin
OneMore;
end;
procedure TMainForm.Mandel;
var
Z, Z0, C: TComplex;
i, x, y: word;
begin
Z0 := TComplex.Create(0,0);
Z := TComplex.Create(0,0);
C := TComplex.Create(0,0);
for y := yStart to yEnd do begin
for x := xStart to xEnd do begin
C.Assign(x,y);
Z.Mul(Z0);
Z.Plus(C);
if (Z.Re < 2) and (Z.Im < 2) then
Image.Canvas.Pixels[Z.Re,Z.Im] := clBlue;
Z.Assign(0,0);
end; { for x }
end; { for y }
C.Free;
Z.Free;
Z0.Free;
end;
procedure TMainForm.N8Click(Sender: TObject);
begin
Mandel;
end;
procedure TMainForm.Paporotnik;
const
A: array[0..3, 0..2, 0..3] of integer =
(((0,0,0,0),(0,20,0,0),(0,0,0,0)),
((85,0,0,0),(0,85,11,70),(0,-10,85,0)),
((31,-41,0,0),(10,21,0,21),(0,0,30,0)),
((-29,40,0,0),(10,19,0,56),(0,0,30,0)));
var
b: array[1..15000] of word;
k, n, i: word;
newX, newY, z, x, y: real;
Color: longint;
begin
x := 0; y := 0; z := 0;
Randomize;
for k := 1 to 15000 do begin
b[k] := Random(10);
if b[k] > 3 then b[k] := 1;
end; { for k }
i := 1;
{ b[i] := 1;}
for i := 1 to 10000 do begin
newX := (a[b[i],0,0]*x + a[b[i],0,1]*y + a[b[i],0,2]*z) / 100+
a[b[i],0,3];
newY := (a[b[i],1,0]*x + a[b[i],1,1]*y + a[b[i],1,2]*z) / 100+
a[b[i],1,3];
z := (a[b[i],2,0]*x + a[b[i],2,1]*y + a[b[i],2,2]*z) / 100+
a[b[i],2,3];
x := newX; y := newY;
Color := Random(65535);
Color := Color*100;
Image.Canvas.Pixels[Round(300-x+z), Round(350-y)] := clGreen;
end; { for k }
end;
procedure TMainForm.N9Click(Sender: TObject);
begin
Paporotnik;
end;
function TMainForm.GetDensity: string;
var
i, j: byte;
LenX, LenY, x, y, xOld, yOld, dx, dy: word;
BlackCnt, TotCnt: word;
P: real; { Плотность пикселов в квадранте }
S, S1: string;
begin
{ Определяем плотность в 9 квадрантах }
{ выделенного диапазона }
S := '';
LenX := xEnd-xStart+1;
LenY := yEnd-yStart+1;
xOld := xStart; yOld := yStart;
for j := 1 to 3 do begin
if j = 2 then dy := LenY-2*Round(LenY/3)
else dy := Round(LenY/3);
for i := 1 to 3 do begin
if i = 2 then dx := LenX-2*Round(LenX/3)
else dx := Round(LenX/3);
{------------------------------------------------------------------}
BlackCnt := 0; { Кол-во черных пикселов в квадранте }
for y := yOld to yOld+dy-1 do begin
for x := xOld to xOld+dx-1 do begin
if Image.Canvas.Pixels[x,y] <> clWhite then Inc(BlackCnt);
end; { for x }
end; { for y }
{------------------------------------------------------------------}
TotCnt := dx*dy;
P := BlackCnt/TotCnt; { Плотность пикселов в квадранте }
Str(P:1:3, S1);
S := S+S1+' ';
xOld := xOld+dx;
end; { for i }
yOld := yOld+dy;
end; { for j }
Result := S;
end; { TMainForm.GetDensity }
procedure TMainForm.N5Click(Sender: TObject);
var
S: string;
ID: word;
begin
S := GetDensity;
ID := DataTable.RecordCount;
DataTable.AppendRecord([ID+1, S]);
end;
procedure TMainForm.N10Click(Sender: TObject);
var
SValue: string[5];
S, DStr1, DStr2, OldS: string;
Value, NewValue: real;
i: byte;
ID: word;
begin
S := GetDensity;
OldS := S;
DataTable.First;
Value := 100;
ID := 0;
while not DataTable.EOF do begin
NewValue := 0;
{-----------------------------------------------------------}
for i := 1 to 9 do begin
DStr1 := Copy(S, (i-1)*6+1, 5);
DStr2 := Copy(DataTableOpis.Value, (i-1)*6+1, 5);
NewValue := NewValue + Abs(StrToFloat(DStr2)-StrToFloat(DStr1));
end; { for i }
{-----------------------------------------------------------}
if NewValue < Value then begin
Value := NewValue;
ID := DataTableID.AsInteger;
end;
DataTable.Next;
end; { while }
ShowMessage(IntToStr(ID));
end;
end.
[1] Известно, что при создании обычными средствами (”руками”) интерфейса пользователя для программ, работающих в графических средах, на это уходит более 80% времени разработки приложения.