home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / dtx9302 / svga / xgdemo.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-02-17  |  5.5 KB  |  167 lines

  1. (*========================================================*)
  2. (*                   XGDEMO.PAS v. 1.0                    *)
  3. (*              (C) 1993 Jörg Braun & DMV-Verlag          *)
  4. (*         Test-/Demoprogramm für die Unit XGRAPH         *)
  5. (*========================================================*)
  6. (*        Compiler: Turbo Pascal ab Version 5.0           *)
  7. (* Benötigt werden:                                       *)
  8. (*      SVGA.BGI, TRIP.CHR, LCOM.CHR, SANS.CHR, GOTH.CHR, *)
  9. (*      SCRI.CHR, SIMP.CHR, EURO.CHR, TSCR.CHR, LITT.CHR, *)
  10. (*      EURO.CHR, außerdem die Units XGRAPH, DRIVERS,     *)
  11. (*      FONTS, XFONTS, und die Standard-BGI-Treiber       *)
  12. (* »MAKE« mit: MAKE -fXGDEMO.MAK                          *)
  13. (* ====================================================== *)
  14. (* Das Programm zeigt einen Teil der Funktionen der Unit  *)
  15. (* XGraph in der Auflösung 800x600 Pixel                  *)
  16. (* ====================================================== *)
  17. (*    NICHT FÜR BORLAND PASCAL 7.0 DOS-PROTECTED-MODE !   *)
  18. (*========================================================*)
  19. {$I xgraph.h} {$M 16384,0,655360}
  20.  
  21. PROGRAM DemoProgramforXGraph;
  22.  
  23. USES
  24.   Dos, Crt, XGraph, Drivers, Fonts, XFonts;
  25.  
  26.  
  27.  
  28. VAR
  29.   BoldFont,
  30.   gd, gm, MaxX, MaxY, i, j     : INTEGER;
  31.   TestStr, MaxColorStr, ModeStr,
  32.   MaxXStr, MaxYStr, jStr       : STRING;
  33.   ch                           : CHAR;
  34.   Multiplyer                   : WORD;
  35.   xa, ya                       : WORD;
  36.  
  37. PROCEDURE WriteMsg;
  38. BEGIN
  39.   FontAttr := Bold;
  40.   OutTextXY(MaxX - 20, 10, 'Aktueller Paletteneintrag: '
  41.                           + ModeStr);
  42.   FontAttr := Normal;
  43. END;
  44.  
  45. BEGIN
  46.   Randomize;
  47.   ch := #0;
  48.   Detectgraph(gd, gm);
  49.   InitGraph(gd, gm, GetEnv('BGIPATH'));
  50.   gm := GetMaxMode;
  51.   SetGraphMode(gm);
  52.  
  53.   SetPalette(White, 63);
  54.   SetBkColor(Blue);
  55.   SetTextJustify(LeftText, CenterText);
  56.   SetTextStyle(0, HorizDir, 1);
  57.   MaxX := GetMaxX;
  58.   MaxY := GetMaxY;
  59.   Str(MaxX + 1, MaxXStr);
  60.   Str(MaxY + 1, MaxYStr);
  61.   Str(GetGraphMode, ModeStr);
  62.   Str(GetMaxColor + 1, MaxColorStr);
  63.   SetTextStyle(SmallFont, HorizDir, 5);
  64.   FontAttr := OutLine;
  65.   OutTextXY(10, 10, GetModeName(gm) +
  66.             ', Treiber: ' + GetDriverName + ', Modus: ' +
  67.             ModeStr + ', Auflösung: ' + MaxXStr + '*' +
  68.             MaxYStr + ' Punkte, ' + MaxColorStr+ ' Farben');
  69.   FontAttr := Normal;
  70.   REPEAT
  71.     SetWriteMode(Random(NotPut));
  72.     i := 1;
  73.     REPEAT
  74.       SetColor(Random(GetMaxColor + 1));
  75. {     Line(Random(MaxX),
  76.            Random(MaxY - MaxX DIV 30) + MaxX DIV 30,
  77.            Random(MaxX),
  78.            Random(MaxY - MaxX DIV 30) + MaxX DIV 30);}
  79.       IF i MOD 100 = 0 THEN BEGIN
  80.         SetColor(Random(GetMaxColor) + 1);
  81.         SetFillStyle(Random(11), Random(GetMaxColor) + 1);
  82.         j := Random(MaxY - MaxY DIV 3) * 2 + 100;
  83.         PieSlice(Random(MaxX), j + 30, 0, 360,
  84.                  Random((MaxY DIV 4)));
  85.       END;
  86.       IF i MOD 150 = 0 THEN BEGIN
  87.         SetColor(Random(GetMaxColor) + 1);
  88.         SetFillStyle(Random(11), Random(GetMaxColor) + 1);
  89.         Bar(Random(MaxX),
  90.             Random(MaxY - MaxX DIV 30) + MaxX DIV 30,
  91.             Random(MaxX),
  92.             Random(MaxY - MaxX DIV 30) + MaxX DIV 30);
  93.       END;
  94.       IF i MOD 180 = 0 THEN BEGIN
  95.         SetColor(Random(GetMaxColor) + 1);
  96.         SetFillStyle(Random(11), Random(GetMaxColor) + 1);
  97.         FillEllipse(
  98.                 Random(MaxX),
  99.                 Random(MaxY) + 100,
  100.                 Random(MaxX DIV 8),
  101.                 Random(MaxY DIV 8));
  102.       END;
  103.       Inc(i);
  104.     UNTIL i > 1000;
  105.     IF KeyPressed THEN ch := ReadKey;
  106.   UNTIL ch <> #0;
  107.  
  108.   BoldFont := InstallUserFont('BOLD');
  109.   ClearDevice;
  110.   SetWriteMode(NormalPut);
  111.   SetBkColor(Black);
  112.   Multiplyer := MaxY DIV 12;
  113.   SetColor(White);
  114.   SetTextJustify(LeftText, CenterText);
  115.   OutTextXY(10, 10, 'Schriften-Demonstration:');
  116.   SetTextJustify(CenterText, CenterText);
  117.   FOR i := DefaultFont TO BoldFont+1 DO BEGIN
  118.     IF i = 0 THEN
  119.       SetTextStyle(i, HorizDir, 2)
  120.     ELSE
  121.       SetTextStyle(i, HorizDir, 4);
  122.     CASE i OF
  123.       DefaultFont  :   TestStr := 'ROM-Zeichensatz';
  124.       TriplexFont  :   TestStr := 'Triplex-Font';
  125.       SmallFont    :   TestStr := 'SmallFont';
  126.       SansSerifFont:   TestStr := 'SansSerif-Font';
  127.       GothicFont   :   TestStr := 'Gothic-Font';
  128.       ScriptFont   :   TestStr := 'ScriptFont';
  129.       SimplexFont  :   TestStr := 'Simplex-Font';
  130.       TSCRFont     :   TestStr := 'Triplex-Font italic';
  131.       LightFont    :   TestStr := 'Triplex-Font light';
  132.       EuroFont     :   TestStr := 'Euro-Font';
  133.       10           :   TestStr := 'Bold-Font';
  134.       ELSE TestStr := 'Triplex-Font bold';
  135.            SetTextStyle(TriplexFont, HorizDir, 4);
  136.            FontAttr := Bold;
  137.     END;
  138.     OutTextXY(MaxX DIV 2, i * Multiplyer + Multiplyer - 20,
  139.               TestStr);
  140.   END;
  141.  
  142.   ch := #0;
  143.   i :=  63;
  144.   FontAttr    := Normal;
  145.   SetTextJustify(RightText, CenterText);
  146.   SetTextStyle(SmallFont, HorizDir, 5);
  147.   REPEAT
  148.     IF i > 127  THEN i := 0;
  149.     IF i < 0  THEN i := 127;
  150.     Str(i: 3, ModeStr);
  151.     SetPalette(White, i);
  152.     IF i IN [0, 64] THEN SetBkColor(LightBlue)
  153.                     ELSE SetBkColor(Black);
  154.     SetColor(White);
  155.     WriteMsg;
  156.     ch := ReadKey;
  157.     IF ch = '-' THEN Dec(i);
  158.     IF ch = '+' THEN Inc(i);
  159.     SetColor(GetBkColor);
  160.     WriteMsg;
  161.   UNTIL NOT (ch IN ['-', '+']);
  162.   CloseGraph;
  163. END.
  164.  
  165. (*========================================================*)
  166. (*                 Ende von XGDEMO.PAS                    *)
  167.