function Flip2(MInput:Matriks; pil:string):Matriks;
var
i,j,r: integer;
MOutput : matriks;
begin
SetLength (MOutput,Length(MInput),Length(MInput[0]));
r:=Length(Moutput) div 2;
if (pil='vertical') then
begin
for i:= 0 to Length(MOutput)-1 do
begin
for j:= 0 to Length(MOutput[0])-1 do
begin
if ((i-r)*(i-r)+(j-r)*(j-r))<=r*r then
begin
MOutput[i,j]:= MInput[(Length(MOutput)-1)-i,j];
end
else
MOutput[i,j]:= MInput[i,j];
end;
end;
end
else
if (pil='horisontal') then
begin
for i:= 0 to Length(MOutput)-1 do
begin
for j:= 0 to Length(MOutput[0])-1 do
begin
if ((i-r)*(i-r)+(j-r)*(j-r))<=r*r then
begin
MOutput[i,j]:=MInput[i, (Length(MOutput[0])-1)-j];
end
else
MOutput[i,j]:= MInput[i,j];
end;
end;
end;
Flip2:=MOutput;
end;
No comments:
Post a Comment