procedure TForm1.DrawFractal;
var
i, j, k, n, d, hib, h: integer;
xx, yy, degreeangles: real;
str: array [0..3] of string;
sh: array [0..3] of real;
stream: array [1..500000] of byte;
s1, s2: string;
begin
Image1.Picture.Bitmap.Canvas.Pen.Color := cbForecolor.ButtonColor;
if (MemoValues.Lines.Count < 15) then
begin
ShowMessage('MemoValues does not have enough lines for processing.');
Exit;
end;
n := StrToIntDef(MemoValues.Lines[0], 0);
d := StrToIntDef(MemoValues.Lines[1], 0);
xx := StrToFloatDef(MemoValues.Lines[2], 0);
yy := StrToFloatDef(MemoValues.Lines[3], 0);
degreeangles := StrToFloatDef(MemoValues.Lines[4], 0) * pi / 180;
for i := 0 to 3 do
str[i] := MemoValues.Lines[6 + i];
hib := Length(str[0]);
for i := 1 to hib do
stream[i] := Ord(str[0][i]) - Ord('0');
h := 2;
while hib < n do
begin
j := stream[h];
for i := 1 to Length(str[j]) do
stream[hib + i] := Ord(str[j][i]) - Ord('0');
hib := hib + Length(str[j]);
h := h + 1;
end;
for i := 0 to 3 do
begin
j := 1;
s1 := '';
while (j <= Length(MemoValues.Lines[11 + i])) and (MemoValues.Lines[11 + i][j] <> '/') do
begin
s1 := s1 + MemoValues.Lines[11 + i][j];
j := j + 1;
end;
if (j <= Length(MemoValues.Lines[11 + i])) and (MemoValues.Lines[11 + i][j] <> '/') then
sh[i] := StrToFloatDef(s1, 0) * pi / 180
else
begin
s2 := '';
for k := j + 1 to Length(MemoValues.Lines[11 + i]) do
s2 := s2 + MemoValues.Lines[11 + i][k];
sh[i] := StrToFloatDef(s1, 0) * pi / (180 * StrToFloatDef(s2, 1));
end;
end;
Image1.Picture.Bitmap.Canvas.MoveTo(Round(xx), Round(yy));
for i := 1 to n do
begin
degreeangles := degreeangles + sh[stream[i]];
xx := xx + d * Sin(degreeangles);
yy := yy + d * Cos(degreeangles);
Image1.Picture.Bitmap.Canvas.LineTo(Round(xx), Round(yy));
end;
end;