program przesuwanie;
uses crt, graph;
var
GraphDriver, GraphMode: integer;
kolor:char;
figura:char;
x1,x2,y1,y2,x3,y3,r:integer;
znak:char;
procedure rysuj(figura:char);
begin
case figura of
'1': rectangle(x1, y1, x2, y2);
'2': circle(x1, y1, r);
'3': rectangle(x1, y1, x2, y2);
'4': begin
line(x1, y1, x2, y2);
line(x2, y2, x3, y3);
line(x3, y3, x1, y1);
end;
end;
end;
begin
writeln('Wybierz figure');
writeln('1 - kwadrat');
writeln('2 - k˘ˆko');
writeln('3 - prostokĄt');
writeln('4 - tr˘jkĄt');
figura :=readkey;
writeln('Wybierz color');
writeln('1 - czerwony');
writeln('2 - zielony');
writeln('3 - niebieski');
kolor :=readkey;
GraphDriver := Detect;
InitGraph(GraphDriver, GraphMode, 'c:\pascal\tp70\bgi\');
if GraphResult<> grOk then
Halt(1);
case kolor of
'1':setcolor(red);
'2':setcolor(green);
'3':setcolor(blue);
end;
x1:= (GetMaxX div 2) -50;
x2:= (GetmaxX div 2) +50;
x3:= x1;
y1:= (GetMaxY div 2) -50;
y2:= (GetmaxY div 2) +50;
y3:= y2;
r:= 50;
repeat
ClearDevice;
rysuj(figura);
znak :=readkey;
case znak of
'4':
begin
if x1>10 then
begin
dec(x1,10);
dec(x2,10);
dec(x3,10);
end;
end;
'8':
begin
if y1>10 then
begin
dec(y1,10);
dec(y2,10);
dec(y3,10);
end;
end;
'6':
begin
if x2<getmaxx-10 then
begin
inc(x1,10);
inc(x2,10);
inc(x3,10);
end;
end;
'2':
begin
if y2<getmaxy-10 then
begin
inc(y1,10);
inc(y2,10);
inc(y3,10);
end;
end;
'-':
begin
if (x1< x2-10) and (r > 10)then
if figura='2' then
dec(r,10)
else
begin
inc(x1,10);
dec(x2,10);
inc(x3,10);
inc(y1,10);
dec(y2,10);
dec(y3,10);
end;
end;
'+':
begin
if (x1>10) and (x2<(getmaxx-10)) and (y1>10) and (y2<(getmaxy-10))then
if figura='2' then
inc(r,10)
else
begin
dec(x1,10);
inc(x2,10);
dec(x3,10);
dec(y1,10);
inc(y2,10);
inc(y3,10);
end;
end;
end;
until znak = #27;
CloseGraph;
end.