program pravougaonik3;
uses crt,graph;
var  x,y,driver,mode:integer;
procedure rast(x,y:integer);
  begin
    repeat
      setcolor(white);
      rectangle(0,0,x,y);
      delay(10);
      setcolor(getbkcolor);
      rectangle(0,0,x,y);
      x:=x+1;
      y:=y+1
    until (x=GetMaxX) or (y=GetMaxY);
    setcolor(white);
    rectangle(0,0,x,y);
  end;
begin
  ClrScr;
  writeln(' Program simulira rast pravougaonika po dijagonali');
  writeln;
  write(' Unesi koordinate temena u intervalima x u (0,1023) i y u (0,886): ');
  readln(x,y);
  if (x>0) and (y>0) and (x<1023) and (y<886)
    then
    begin
      driver:=detect;
      initgraph(driver,mode,'');
      setbkcolor(black);
      setcolor(white);
      rast(x,y);
      readln;
      closegraph
    end
    else
    begin
      write(' Koordinate nisu u preporucenom intervalu!');
      readln
    end
end.