home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / spezial / 14 / grafik / exgrdemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-11-28  |  3.2 KB  |  106 lines

  1. (* ------------------------------------------------------ *)
  2. (*                  EXGRDEMO.PAS                          *)
  3. (*    Demonstriert den Einsatz der Unit EXGRAPH.TPU       *)
  4. (*        (c) 1989 Markus Kucborski & TOOLBOX             *)
  5. (* ------------------------------------------------------ *)
  6. PROGRAM ExGraphDemo;
  7.  
  8. USES Graph, ExGraph, Crt;
  9.  
  10. CONST
  11.   MaxSlices   = 12;    (* variable Werte möglich          *)
  12.   LoadImages  = FALSE; (* lädt von Disk Maxslices-Images  *)
  13.   SaveImages  = FALSE; (* speichert am Ende die Images ab *)
  14.   Headline    = 'Dies ist eine Demo fuer die Unit EXGRAPH.';
  15.   NoMsg       = '';
  16.  
  17. VAR
  18.   Image                   : ARRAY[1..MaxSlices] OF ImageRec;
  19.   Radius, x, y, Degree, i : INTEGER;
  20.  
  21.  
  22.   PROCEDURE Init(VAR x, y, Radius, Degree : INTEGER);
  23.   VAR Graphmode, Graphdriver : INTEGER;
  24.   BEGIN
  25.     GraphDriver := Detect;
  26.     InitGraph(Graphdriver, GraphMode, '');
  27.     Radius := GetMaxY DIV 15;
  28.     x      := GetMaxX DIV  2;
  29.     y      := GetMaxY DIV  2;
  30.     Degree := 60      DIV MaxSlices;
  31.     Rectangle(0, 0, GetMaxX, Textheight('H') + 4);
  32.     OutTextXY((GetMaxX - 1 -
  33.                Textwidth(Headline)) DIV 2, 2, Headline);
  34.   END;
  35.  
  36.  
  37.   PROCEDURE ShowMsg(msg : STRING);
  38.   BEGIN
  39.     Bar(0, Radius-2, GetMaxX, Radius + TextHeight('H')+2);
  40.     OutTextXY((GetMaxX - TextWidth(Msg)) DIV 2, Radius,Msg);
  41.   END;
  42.  
  43.  
  44.   PROCEDURE MovePac;
  45.   CONST up : BOOLEAN = TRUE;
  46.         i  : INTEGER = MaxSlices;
  47.   BEGIN
  48.     ShowMsg('Ende der Animation durch irgendeine Taste');
  49.     REPEAT
  50.       IF (i = MaxSlices) OR (i = 1) THEN up := NOT up;
  51.       IF up THEN Inc(i) ELSE Dec(i);
  52.         PutImage(GetMaxY - 2*Radius, GetMaxY - 2*Radius,
  53.                                      Image[i].Img^, XorPut);
  54.         PutImage(GetMaxY - 2*Radius, GetMaxY - 2*Radius,
  55.                                      Image[i].Img^, XorPut);
  56.     UNTIL KeyPressed;
  57.     ShowMsg(NoMsg)
  58.   END;
  59.  
  60.  
  61.   PROCEDURE DisplayAllImages;
  62.   VAR x, y : INTEGER;
  63.   BEGIN
  64.     y :=  3*Radius;
  65.     x := -2*Radius;
  66.     FOR i := 1 TO Maxslices DO BEGIN
  67.       IF (x + 2*Radius + 5) < GetMaxX THEN
  68.         Inc(x, 2*Radius + 5)
  69.       ELSE BEGIN
  70.         Inc(y, 2*Radius + 2);
  71.         x := 1;
  72.       END;
  73.       PutImage(x, y, Image[i].Img^, XorPut)
  74.     END;
  75.   END;
  76.  
  77.  
  78. BEGIN
  79.   Init(x, y, Radius, Degree);
  80.   SetFillStyle(WideDotFill, Black);
  81.   ShowMsg('Initialisiere BildSequenz ');
  82.   FOR i := 1 TO MaxSlices DO
  83.     IF LoadImages THEN BEGIN
  84.       ShowMsg(' Lade BildSequenz ');
  85.       LoadImg('Pac' + Chr(64+i) + '.img', Image[i]);
  86.     END ELSE BEGIN
  87.       PieSlice(x, y, i*Degree, 360 - Degree*i, Radius);
  88.       PieSlice(x, y - Radius DIV 3, 0, 360, Radius DIV 5);
  89.       CatchImg(x-Radius, y-Radius, x+Radius, y+Radius,
  90.                                                   Image[i]);
  91.       PutImage(x-Radius, y-Radius, Image[i].Img^, XorPut);
  92.     END;
  93.   DisplayAllImages;
  94.   MovePac;
  95.   FOR i := 1 TO MaxSlices DO BEGIN
  96.     IF SaveImages THEN BEGIN
  97.       ShowMsg('Speichere Bildsequenz');
  98.       SaveImg('pac' + Chr(64+i) + '.img', Image[i]);
  99.     END;
  100.     FreeImg(Image[i]);
  101.   END;
  102.   CloseGraph;
  103. END.
  104.  
  105. (* ------------------------------------------------------ *)
  106. (*                Ende von EXGRDEMO.PAS                   *)