program rechteck;
uses crt, graph;

var gd, gm, i, d, c, k : integer;
    color, l, h : word;

procedure bild;
  begin
    for i:=1 to 80 do {Rechtecke}
      begin
        if i>40 then setcolor(red);
        rectangle(0+i*8, 0+i*6, 639-i*8, 479-i*6);
        delay(50);
        if keypressed then exit;
      end;
    cleardevice;
    setcolor(yellow);
    for i:=1 to 94 do  {Kreise}
      begin
        if i<=47 then d:=5*i else d:=d-5;
        if i>=47 then setcolor(red);
        circle(320, 240, d);
        if i=47 then circle(320, 240, d);
        delay(50);
        if keypressed then exit;
      end;
    cleardevice;
    setcolor(yellow);
    for i:=1 to 158 do
      begin
        if i<=79 then d:=3*i else d:=d-3;
        if i<=79 then c:=4*i else c:=c-4;
        if i>=79 then setcolor(red);
        ellipse(320, 240, 0, 360, c, d);
        if i=79 then ellipse(320, 240, 0, 360, c, d);
        delay(50);
        if keypressed then exit;
      end;
    cleardevice;
    setcolor(yellow);
    for i:=0 to 160 do
      begin
        if i>=80 then setcolor(red);
        if i<=80 then d:=3*i else d:=d-3;
        if i<=80 then c:=4*i else c:=c-4;
        line(320-c, 240+d, 320+c, 240+d);
        line(320-c, 240-d, 320+c, 240-d);
        delay(50);
        if keypressed then exit;
      end;
    cleardevice;
    setcolor(yellow);
    for i:=0 to 160 do
      begin
        if i>=80 then setcolor(red);
        if i<=80 then d:=3*i else d:=d-3;
        if i<=80 then c:=4*i else c:=c-4;
        line(320-c, 240-d, 320-c, 240+d);
        line(320+c, 240-d, 320+c, 240+d);
        delay(50);
        if keypressed then exit;
      end;
    cleardevice;
    setcolor(yellow);
    for i:=0 to 160 do
      begin
        if i>=80 then color:=red else color:=yellow;
        if i<=80 then d:=3*i else d:=d-3;
        if i<=80 then c:=4*i else c:=c-4;
        putpixel(320-c, 240+d, color);
        putpixel(320-c, 240-d, color);
        putpixel(320+c, 240+d, color);
        putpixel(320+c, 240-d, color);
        putpixel(320, 240-d, color);
        putpixel(320, 240+d, color);
        putpixel(320+c, 240, color);
        putpixel(320-c, 240, color);
        delay(50);
        if keypressed then exit;
      end;
    cleardevice;
    i:=1;
    for i:=1 to 40 do
      begin
        if i<=20 then setcolor(yellow) else setcolor(red);
        if i<=20 then inc(c);
        if i>20 then dec(c);
        settextstyle(defaultfont, 0, c);
        l:=round(textwidth('Text')/2);
        h:=round(textheight('Text')/2);
        outtextxy(320-l, 240-h, 'Text');
        delay(50);
        setcolor(0);
        outtextxy(320-l, 240-h, 'Text');
        if keypressed then exit;
      end;
  end;

begin
  detectgraph(gd, gm);
  initgraph(gd, gm, 'd:\tp\bgi');
  cleardevice;
  k:=0;
  repeat
    setcolor(brown);
    bild;
    {readln;}
    cleardevice;
    k:=k+1;
  until keypressed;{k=3;}
  cleardevice;
  closegraph;
end.