var
Form1: TForm1;
Type1:
Byte
;
r:
real
;
x_min,y_min,x_max,y_max:
Real
;
n,iter,kr,zel,sin :
Integer
;
imagemouse:
boolean
;
imageRect: TRect;
ia,ib:
real
;
a,b:
real
;
implementation
uses
Unit2, Unit3;
{$R *.dfm}
function
MandelBrot(a,b:
real
): TColor;
var
x,y,xy:
real
;
x2,y2:
real
;
r:
real
;
k:
integer
;
begin
r:=
1
;
x:=
0
; y:=
0
;
k:=iter;
while
(k>
0
)
and
(r<
4
)
do
begin
x2:=x*x;
y2:=y*y;
xy:=x*y;
x:=x2-y2+a;
y:=
2
*xy+b;
r:=x2+y2;
dec(k)
end
;
k:=round((k/
100
)*
255
);
MandelBrot:=RGB(k+kr,k+zel,k+sin);
end
;
function
Julia(x0,y0:
real
): TColor;
var
x,y,x2,y2,xy:
real
;
r1:
Real
;
speed,k:
integer
;
begin
r1:=
1
;
x:=x0;
y:=y0;
k:=iter;
while
(k>
0
)
and
(r1<
4
)
do
begin
r1:=x*x+y*x;
X2:=X;
x:=x*x-y*y-a;
y:=
2
*x2*y-a;
dec(k)
end
;
k:=round((k/
100
)*
255
);
Julia:=RGB(k+kr,k+zel,k+sin);
end
;
procedure
TForm1
.
TrackBar1Change(Sender: TObject);
begin
edit1
.
Text:=inttostr(TrackBar1
.
Position);
end
;
procedure
TForm1
.
TrackBar2Change(Sender: TObject);
begin
edit2
.
Text:=inttostr(TrackBar2
.
Position);
end
;
procedure
TForm1
.
TrackBar3Change(Sender: TObject);
begin
edit3
.
Text:=inttostr(TrackBar3
.
Position);
end
;
procedure
TForm1
.
Edit1Change(Sender: TObject);
begin
TrackBar1
.
Position:=strtoint(edit1
.
Text);
end
;
procedure
TForm1
.
Edit2Change(Sender: TObject);
begin
TrackBar2
.
Position:=strtoint(edit2
.
Text);
end
;
procedure
TForm1
.
Edit3Change(Sender: TObject);
begin
TrackBar3
.
Position:=strtoint(edit3
.
Text);
end
;
procedure
TForm1
.
Button3Click(Sender: TObject);
var
s:
string
;
begin
s:=edit5
.
text;
SavePictureDialog1
.
FileName:=s;
if
SavePictureDialog1
.
Execute
then
begin
s:=SavePictureDialog1
.
FileName;
Image1
.
Picture
.
SaveToFile(s+
'.bmp'
);
ShowMessage(SavePictureDialog1
.
FileName +
' сохранен рисунок под названием '
+ s);
end
;
end
;
procedure
TForm1
.
N2Click(Sender: TObject);
var
s:
string
;
begin
if
OpenPictureDialog1
.
Execute
then
begin
s:= OpenPictureDialog1
.
FileName;
Image1
.
Picture
.
LoadFromFile(s);
end
;
end
;
procedure
TForm1
.
N4Click(Sender: TObject);
begin
close;
end
;
procedure
TForm1
.
N7Click(Sender: TObject);
begin
Image1
.
picture:=
nil
;
Form1
.
Image1
.
Refresh
end
;
procedure
TForm1
.
N3Click(Sender: TObject);
var
s:
string
;
begin
s:=edit5
.
text;
SavePictureDialog1
.
FileName:=s;
if
SavePictureDialog1
.
Execute
then
begin
s:=SavePictureDialog1
.
FileName;
Image1
.
Picture
.
SaveToFile(s+
'.bmp'
);
ShowMessage(SavePictureDialog1
.
FileName +
' сохранен рисунок под названием '
+ s);
end
;
end
;
procedure
TForm1
.
N6Click(Sender: TObject);
begin
if
(
not
Assigned(Form2))
then
Form2:=TForm2
.
Create(Self);
Form2
.
Show;
end
;
procedure
TForm1
.
N8Click(Sender: TObject);
begin
if
(
not
Assigned(Form3))
then
Form3:=TForm3
.
Create(Self);
Form3
.
Show;
end
;
procedure
TForm1
.
Button1Click(Sender: TObject);
var
min,max:
integer
;
hx,hy,x,y:
real
;
i,j,n:
integer
;
fractal: TColor;
begin
Image1
.
picture:=
nil
;
Image1
.
Width:=strtoint(Edit10
.
Text);
Image1
.
Height:=strtoint(Edit10
.
Text);
Type1:=
1
;
kr:=strtoint(Edit1
.
Text);
zel:=strtoint(Edit2
.
Text);
sin:=strtoint(Edit3
.
Text);
x_max:=strtofloat(ComboBox2
.
Text);
x_min:=strtofloat(ComboBox3
.
Text);
y_max:=strtofloat(ComboBox4
.
Text);
y_min:=strtofloat(ComboBox5
.
Text);
iter:=strtoint(Edit11
.
Text);
n:=strtoint(edit10
.
Text) ;
y:=y_min;
a:=strtofloat(ComboBox1
.
Text);
hx:=(x_max - x_min)/n;
hy:=(y_max - y_min)/n;
min:=strtoint(Edit4
.
Text);
max:=strtoint(Edit6
.
Text);
for
j:=min
to
max
do
begin
x:=x_min;
for
i:=min
to
max
do
begin
if
RadioButton1
.
Checked
then
fractal:=MandelBrot(x,y);
if
RadioButton2
.
Checked
then
fractal:=Julia(x,y);
Form1
.
Image1
.
Canvas
.
Pixels[i,j]:=fractal;
x:=x+hx;
end
;
y:=y+hy;
Form1
.
Image1
.
Refresh;
end
;
end
;
procedure
TForm1
.
BitBtn1Click(Sender: TObject);
var
hx,hy,x,y:
real
;
i,j,n:
integer
;
fractal: TColor;
begin
Image1
.
picture:=
nil
;
if
CheckBox1
.
Checked =
True
then
begin
if
RadioButton1
.
Checked
then
begin
ComboBox2
.
Text:=inttostr(
1
);
ComboBox3
.
Text:=inttostr(-
2
);
ComboBox4
.
Text:=floattostr(
1.2
) ;
ComboBox5
.
Text:=floattostr(-
1.2
);
end
;
if
RadioButton2
.
Checked
then
begin
ComboBox2
.
Text:=floattostr(
1.5
) ;
ComboBox3
.
Text:=floattostr(-
1.5
);
ComboBox4
.
Text:=inttostr(
1
);
ComboBox5
.
Text:=inttostr(-
1
);
end
;
end
;
Image1
.
Width:=strtoint(Edit10
.
Text);
Image1
.
Height:=strtoint(Edit10
.
Text);
Type1:=
1
;
kr:=strtoint(Edit1
.
Text);
zel:=strtoint(Edit2
.
Text);
sin:=strtoint(Edit3
.
Text);
x_max:=strtofloat(ComboBox2
.
Text);
x_min:=strtofloat(ComboBox3
.
Text);
y_max:=strtofloat(ComboBox4
.
Text);
y_min:=strtofloat(ComboBox5
.
Text);
iter:=strtoint(Edit11
.
Text);
n:=strtoint(edit10
.
Text) ;
y:=y_min;
a:=strtofloat(ComboBox1
.
Text);
hx:=(x_max - x_min)/n;
hy:=(y_max - y_min)/n;
for
j:=
0
to
n
do
begin
x:=x_min;
for
i:=
0
to
n
do
begin
if
RadioButton1
.
Checked
then
fractal:=MandelBrot(x,y);
if
RadioButton2
.
Checked
then
fractal:=Julia(x,y);
Form1
.
Image1
.
Canvas
.
Pixels[i,j]:=fractal;
x:=x+hx;
end
;
y:=y+hy;
Form1
.
Image1
.
Refresh;
end
;
end
;
procedure
TForm1
.
Image1Click(Sender: TObject);
var
pt: TPoint;
begin
GetCursorPos(pt);
pt := ScreenToClient(pt);
ShowMessage(
'Coordinates: X='
+ IntToStr(pt
.
X - Image1
.
Left) +
' Y='
+ IntToStr(pt
.
Y - Image1
.
Top));
label15
.
Caption:=inttostr(pt
.
X - Image1
.
Left+
20
);
label16
.
Caption:=inttostr(pt
.
X - Image1
.
Left-
20
);
label17
.
Caption:=IntToStr(pt
.
Y - Image1
.
Top+
20
);
label18
.
Caption:=IntToStr(pt
.
Y - Image1
.
Top-
20
)
end
;
end
.