home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / libs / mlib / source / graph / mgraph.cpp < prev    next >
Encoding:
Text File  |  1994-04-16  |  19.6 KB  |  615 lines

  1. { draw image }
  2.      Delay(PauseTime);
  3. {     PutImage(X, Y, Saucer^, XORput);                 { erase image }
  4.      MoveSaucer(X, Y, lrx - ulx + 1, lry - uly + 1);  { width/height }
  5.   until KeyPressed;
  6.   FreeMem(Saucer, size);
  7.   WaitToGo;
  8. end; { PutImagePlay }
  9.  
  10. procedure PolyPlay;
  11. { Draw random polygons with random fill styles on the screen }
  12. const
  13.   MaxPts = 5;
  14. type
  15.   PolygonType = array[1..MaxPts] of PointType;
  16. var
  17.   Poly : PolygonType;
  18.   I, Color : word;
  19. begin
  20.   MainWindow('FillPoly demonstration');
  21.   StatusLine('Esc aborts or press a key...');
  22.   repeat
  23.     Color := RandColor;
  24.     SetFillStyle(Random(11)+1, Color);
  25.     SetColor(Color);
  26.     for I := 1 to MaxPts do
  27.       with Poly[I] do
  28.       begin
  29.         X := Random(MaxX);
  30.         Y := Random(MaxY);
  31.       end;
  32.     FillPoly(MaxPts, Poly);
  33.   until KeyPressed;
  34.   WaitToGo;
  35. end; { PolyPlay }
  36.  
  37. procedure FillStylePlay;
  38. { Display all of the predefined fill styles available }
  39. var
  40.   Style    : word;
  41.   Width    : word;
  42.   Height   : word;
  43.   X, Y     : word;
  44.   I, J     : word;
  45.   ViewInfo : ViewPortType;
  46.  
  47. procedure DrawBox(X, Y : word);
  48. begin
  49.   SetFillStyle(Style, MaxColor);
  50.   with ViewInfo do
  51.     Bar(X, Y, X+Width, Y+Height);
  52.   Rectangle(X, Y, X+Width, Y+Height);
  53.   OutTextXY(X+(Width div 2), Y+Height+4, Int2Str(Style));
  54.   Inc(Style);
  55. end; { DrawBox }
  56.  
  57. begin
  58.   MainWindow('Pre-defined fill styles');
  59.   GetViewSettings(ViewInfo);
  60.   with ViewInfo do
  61.   begin
  62.     Width := 2 * ((x2+1) div 13);
  63.     Height := 2 * ((y2-10) div 10);
  64.   end;
  65.   X := Width div 2;
  66.   Y := Height div 2;
  67.   Style := 0;
  68.   for J := 1 to 3 do
  69.   begin
  70.     for I := 1 to 4 do
  71.     begin
  72.       DrawBox(X, Y);
  73.       Inc(X, (Width div 2) * 3);
  74.     end;
  75.     X := Width div 2;
  76.     Inc(Y, (Height div 2) * 3);
  77.   end;
  78.   SetTextJustify(LeftText, TopText);
  79.   WaitToGo;
  80. end; { FillStylePlay }
  81.  
  82. procedure FillPatternPlay;
  83. { Display some user defined fill patterns }
  84. const
  85.   Patterns : array[0..11] of FillPatternType = (
  86.   ($AA, $55, $AA, $55, $AA, $55, $AA, $55 üÖü üÖü  !BBäx!!!BBäx!BBäx"""DDêp""DDêp>"""BBääêp""!"BDäêêp>IÉÆ|      ° @≥î>00>><Dêx  !BBäx""DDêp&<"DDêê&22TTêêê$> $< @äêp>          ⁿBBBB<  @@Ç****DDDDDDDU¬U¬U¬U¬U¬U¬U¬▌w▌w▌w▌w▌w▌w▌w°°°≥■°°≥≥■≥≥■■°°°    ≤  ≤  ≤≤         °                     ≡≡≡≡≡≡≡≡≡≡≡≡≡≡       ;DDD;    $"Bdÿ>@@@>||>Ac]AAA1N"A""2,  `1NA"*III*<Bü üB<<BüüüB<A" \"QIE" < <BBBB  @@    ~ ?  @ÇB$$B ""A$$"AII6 üBr»$**IIII**ccregion.  The region is defined as any pixel of
  87.             OldColor which has a path of pixels of OldColor or NewColor
  88.             with sides touching back to the seed point, (XSeed, YSeed).
  89.             Therefore, only pixels of OldColor are modified and no other
  90.             information is changed.
  91.  
  92.             SEE ALSO
  93.  
  94.             DRWFILLBOX, DRWFILLCIRCLE, DRWFILLELLIPSE, FILLAREA,
  95.             FILLCONVEXPOLY, FILLPAGE, FILLPOLY, FILLSCREEN, FILLVIEW,
  96.             SETVIEW
  97.  
  98.             EXAMPL(HNxHHO$B<BBBB<$<BBBB<<BBBB<$BBBBBF:0BBBBF:$BBBF:B<""AAA""AAAAA"<B@@B<" <2\A">>xDDxDNDD <` <>BB= > <BBBB< BBBBF:2L\bBBBB&AaQIECA8$>""">0@@A>@@@ b$(. b$(*
  99.     $    $    $DDDDDDD¬U¬U¬U¬U¬U¬U¬Uw▌w▌w▌w▌w▌w▌w▌°°°⌠ⁿ°°⌠⌠ⁿ⌠⌠ⁿⁿ°°°    ≈  ≈  ≈≈         °                     ≡≡≡≡≡≡≡≡≡≡≡≡≡≡       7HH7"B\DBBRL~BB@@@@@@?R~!!~?DDDD8BBBB|@@Ç>P>III>"AA""AAA"Uw<DDDD86II6"EIQ"\ @@ "AAAAA> >     hH02L2L$$<H(,$<>>>>>>>         VMODE=VIDEOMODEGET
  100.             IF WHICHVGA = 0 THEN STOP
  101.             DUMMY=RES640
  102.             SETVIEW 100, 100, 539, 379
  103.             FILLVIEW 10
  104.             WHILE INKEY$ = ""
  105.             WEND
  106.             VIDEOMODESET VMODE
  107.             END
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.                                                                          63
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.           FONTGETINFO
  132.  
  133.             PROTOTYPE
  134.  
  135.             SUB FONTGETINFO (Width%, Height%)
  136.  
  137.             INPUT
  138.  
  139.             no input parameters
  140.     WEND
  141.             MOUSEEXIT
  142.             VIDEOMODESET VMODE
  143.             END
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.                                                                          86
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.           MOUSECURSORDEFAULT
  192.  
  193.             PROTOTYPE
  194.  
  195.             SUB MOUSECURSORDEFAULT ()
  196.  
  197.             INPUT
  198.  
  199.             no input parameters
  200.  
  201.             OUTPUT
  202.  
  203.             no value returned
  204.  
  205.             USAGE
  206.  
  207.             MOUSECURSORDEFAULT defines the mouse cursor to be a small
  208.        ,K$╖┼╘╤░XQ)σ┤ö≡÷┴─┤àñT┘,╘¬àñX9╘⌠àñ\9╘UÜ╢≤`9╘4a╘d9╘UTa╘h9╘ta╘l9╘Uöa╘p9╘┤a╘t┘PT±x┴îÇ╖0▓ïα│ÅαU┤ôα╡ùα╢¢α╖úΓ╘pǺΓ╕¡αë ╚┴πì°sKÉφb<$⌡▌ë     φë φë I1φë  Eφë $YφÆë (mφë ,üφë 0$òφë á⌐φë ñ╜φë I¿╤φë ¼σφë ░∙φÆë 4
  209. ²ë ┤!²ë ╕$5²ë ╝I²ë └]²ë ⌐8q²ë <àⁿΦiǬ∙PÖÇ ¥Ç
  210. ░╨â@%8@ΓΦá╝╤░≡cÑÅ*$
  211. ░╕≡ż≡τ╥m¿⌡ε    ╨@#µ≈$âh$âαra╨à`¥è∩Ç%Ç +─▀ TîcOî∩â°1<@  [$¿Ç¼ MMl·0ƒ Y¼─!%6a▐è ¥ì ßá+?±  P<îaTTV ╪iÇ¡≥░ `_ñ»%Çá᪠P█º»ε`éa∙É%H«┴íA%Gár∙É
  212. iw∙Éiφ`╧≥≡╤Çmⁿ▒
  213. ]ÆAáσw7░⌡∩    $·╟Ç√É&^`  ┐ $ⁿ  $■ $╒ nk$J-ÉQ1£PéBù »0αQ/Ñ4╜£░ºP≈Ñ4Ç⌡$(ª▀$@C]Æé≈└╕_SÇçÑ4=iÉ⌠ä╣<_np@Ñ45ò▒Y3ü¼Qí░.i>╠@5+┴╙É╛╙$@ #┴@«╦
  214. $╤
  215. #@Ñú4,p&e÷ü¼_ÇQºÑ4
  216. òQ  ü@;¡_áQ@e╠≥@mp!┤a╘O░√`Pñź ÇT°8ÿ!¼Åñ$½╙"q¿ PñCÇ¿α√└╥░eT"ß<p°%Pæ(╧%pδ¥/OêW0Ǽbφ φ B@[â¼8â≥µ≤(    ¿⌡%(Ç∩áTÿp+ óÜ▓0!Σ±(1±
  217. ░┤ÖÇD└D0Å╡`   $ «îO@╧1
  218. a╝╤j-0ñ│`@╖bΦaT1═⌠╝╤Σ²¼±,1öíî9lÿ28ÇÅ`Γî¿P²$,N0┴O0a╫δ≤0σú`°î╖#0δ≡└X▄1»Σî(▒¥Ç█Ñ"qá√1CÇú╟╨º Å
  219. FT Θ²î└1ÇY0    w ²à░$@AÅ`╦Φ¼╘`▄1A  }┐Ç*5 ΩSδδî`¼îaδæ¼î5 1¿⌡Ω╜⌠ ¼¥╬ü└Qî1S
  220. ╛≤î9╨iÇ,∙PU(}Ç$üÇ àÇ`σìÇ`QαÜBO$%ÿÇ╧"$Ç«Ç]É.┬\`%WÉ$  W0 ÄâO0]αG┬ur╩
  221. ░£▒
  222. Q¢ú╔Ç≡°s?`X0╘`@ µWâ@╣aá εdq`¥9?Ç&+o0µyÄΣAÅuV(7P╬±@IdQ╕@Å┤@;Ç▓?Çò│CÇ┤╟╨╡KÇÄ30ⁿφ° ó╬ì+]Ä╦≡     Mö╝σ ²y5<!└▀óâ╝É3~mp    $<╛≤9Æ-2ⁿ≡@T,╞Σa,)Pæ└¥#¼╪Q┤S(¼@Aîa
  223. ≡╤@Ö²±⌠KëD─┴▒▀0╨Ñ$╩-0 ╨ê*╙▓edm`î=3Kß-10è=≥≤²└£mîjy ÿe²ⁿ╨i╕e▓ΣmαÖ╢C%Ç*ê*0 EátQZ`mÄLP%    °üⁿªüNQ∙  T¿<qtWΩc z░ÅÇñΩçǪçÇ«;└<┐á¼¥. á?<Σscî)áí := 0;
  224.       end;
  225.     end;
  226.   end;
  227.   WaitToGo;
  228. end; { UserLineStylePlay }
  229.  
  230.  
  231. procedure SayGoodbye;
  232. { Say goodbye and then exit the program }
  233. var
  234.   ViewInfo : ViewPortType;
  235. begin
  236.   MainWindow('');
  237.   GetViewSettings(ViewInfo);
  238.   SetTextStyle(TriplexFont, HorizDir, 4);
  239.   SetTextJustify(CenterText, CenterText);
  240.   with ViewInfo do
  241.     OutTextXY((x2-x1) div 2, (y2-y1) div 2, 'That''s all folks!');
  242.   StatusLine('Press any key to quit...');
  243.   repeat until KeyPressed;
  244. end; { SayGoodbye }
  245.  
  246.  
  247. PROCEDURE SelectMode;
  248. VAR
  249.     choice1,choice2     : CHAR;
  250.    xsize,ysize            : WORD;
  251. BEGIN
  252.     (* Let's select a mode *)
  253.     ClrScr;
  254.     WriteLn('VESADEMO:');
  255.     WriteLn('1. 256 colors');
  256.     WriteLn('2. 32768 colors');
  257.     WriteLn('3. 65536 colors');
  258.     WriteLn('4. 16777216 colors');
  259.     WriteLn('Q uit');
  260.     WriteLn;
  261.     Write('Your choice: ');
  262.     REPEAT
  263.         ReadLn(choice1);
  264.       IF choice1 <> '1' THEN BEGIN
  265.           WriteLn('Sorry !');
  266.          WriteLn('This demo wasn''t written for more as 256 colors !');
  267.          WriteLn('You would only get a limited impression of the Hi-& TrueColor modes...');
  268.          WriteLn('Switching to 256 colors.');
  269.          choice1 := '1';
  270.       END;
  271.     UNTIL choice1 IN ['1'..'4','q'];
  272.     IF choice1 = 'q' THEN Halt;
  273.  
  274.     WriteLn;
  275.     WriteLn;
  276.     WriteLn('a. 320x200');
  277.     WriteLn('b. 640x480');
  278.     WriteLn('c. 800x600');
  279.     WriteLn('d. 1024x768');
  280.     WriteLn('e. 1280x1024');
  281.     WriteLn('Q uit');
  282.     WriteLn;
  283.     Write('Your choice: ');
  284.     REPEAT
  285.         ReadLn(choice2);
  286.     UNTIL choice2 IN ['a'..'e','q'];
  287.     IF choice2 = 'q' THEN Halt;
  288.  
  289.     CASE choice2 OF
  290.         'a' : BEGIN
  291.             xsize := 320;
  292.             ysize := 200;
  293.         END;
  294.         'b' : BEGIN
  295.             xsize := 640;
  296.             ysize := 480;
  297.         END;
  298.         'c' : BEGIN
  299.             xsize := 800;
  300.             ysize := 600;
  301.         END;
  302.         'd' : BEGIN
  303.             xsize := 1024;
  304.             ysize := 768;
  305.         END;
  306.         'e' : BEGIN
  307.             xsize := 1280;
  308.             ysize := 1024;
  309.         END;
  310.     END;
  311.     CASE choice1 OF
  312.         '1' : mode := FindVesaMode(xsize,ysize,8);
  313.         '2' : mode := FindVesaMode(xsize,ysize,15);
  314.         '3' : mode := FindVesaMode(xsize,ysize,16);
  315.         '4' : mode := FindVesaMode(xsize,ysize,24);
  316.     END;
  317.     IF mode = 0 THEN BEGIN
  318.         WriteLn('No such mode could be found !');
  319.         WriteLn('Switching to to 320x200.');
  320.         ReadKey;
  321.         mode := V320x200x256;
  322.     END;
  323. END;
  324.  
  325. begin { program body }
  326.   SelectMode;
  327.   Initialize;
  328.   ReportStatus;
  329.  
  330. {  AspectRatioPlay; }
  331.   FillEllipsePlay;
  332.   SectorPlay;
  333.   WriteModePlay;
  334.  
  335.   ColorPlay;
  336.   { PalettePlay only intended to work on these drivers: }
  337.   if (GraphDriver = EGA) or
  338.       (GraphDriver = EGA64) or
  339.       (GraphDriver = VGA) then
  340.      PalettePlay;
  341.   PutPixelPlay;
  342. {  PutImagePlay; }
  343.   RandBarPlay;
  344.   BarPlay;
  345.   Bar3DPlay;
  346.   ArcPlay;
  347.   CirclePlay;
  348.   PiePlay;
  349.   LineToPlay;
  350.   LineRelPlay;
  351. {  LineStylePlay; }
  352. {  UserLineStylePlay; }
  353.   TextDump;
  354.   TextPlay;
  355.   CrtModePlay;
  356.   FillStylePlay;
  357.   FillPatternPlay;
  358.   PolyPlay;
  359.   SayGoodbye;
  360. {  CloseGraph; }
  361.   CloseVesa;
  362. end.
  363. ***************************************************
  364.     '* SHOW D2ROTATE (ABOUT THE ORIGIN)
  365.     '****************************************************************∞╥≤c≤*φè#^│v/╒:j═φ0t+l▓ô"¬"g└≡?%ªêΣ│H╫½╫╜├¿U'╒⌐⌡ ßV?╩
  366. ¬ujOΦçEZ1∞▐! ▄B╛Σ8║æ]1GlNÜ┐q▌▓;ô$ΦzE<cª*bEô#ä╧ñÅ"∩─LrdaÖ ╠º╫a^¥£å╬1~)@ëÖMδ╫0═6DäFê¬Çv┼ß╨kæpτ╪É)}ª 1w3╤╧ü⌡¥╓h▓╣≈ïÅaÑ[TⁿHqªÉ╝DKÄ─Y-∞tT╤Θ╨º╟╪.*ÇI9lΦ≈{πτcσ$τπßoFr╪╨∩┼╞╟;O2■e²LÜ4^N|╪½ÅO?╔°FOz`╟╟╟'<>>π$πΘù6·
  367. Xgî╖│°oîδπGƒd╝▀░?■╪╔_9L ⌡ôⁿq'æO▀ƒn4╔▀╚▄┼3pτ.òO°·}÷╕ⁿ±'æO?ít│!√8ßÑ≤/┐╣p┼≥┘E╦Vox╕cΦé5╟╚º╙$?√$≥ΘZεsî≡åìΓpKù¢ïß X╥ 9╞≈\µk┤O¥_ 5Üö\≤éÄ┌╤A[╤ÿáï┼éNⁿÅu16    g,%hc╙╨cD╨Vï┘R¢öKñR;8εáΣ╢╪ós╤π╡á└èxgzPÄMú╫yαºÉ+σJ¢i+▓â3╥    ═Ñ╙î^ºG▓█πérφçs %#(╗⌠?┼%u8≡6+QÉ))ò)Afw≈╣╪)B&4░åLXV:δät@Å.;5Φf╢Ät┐ΣJ╫─U8úÇ╟éö£╕p╔┴⌠vg╨╬╥é÷╪╣┬ΓI.ç≡^v╤ZΦÇ& ╒┌6ñô6XßNè╡╬E₧Ñ
  368. kIº╠▄A+╣╥éb²tæ-Y¡½αÑa═uuîÇ╢αêvhuª╡SÅ┤vèùú¥F;p<d⌐/F─d█éT%▓KΦû=q■öI┐ ┐╠6S$▒÷╚ENΩ¥Fû9╔┌R'╝ ╧φ└?g┬j▓0═/b╖₧─mûé╢┌»ÿÄë/·<éò■░╤╟╢├Xσ:╥P3Θ"╬Læsφ░┌öSö!╗¿*mN£WΣÇ£┤~#╗ææ≥RΩóh:à▌.æ≈╕▌v£äàd▒à╒├=░╖π║$howeg*╬    6ù▄ƒô╕φ░Ö╢qΘD>(w@úKεHÆ╛öúΣU
  369. éÜR╔╤W▄èê 2M%ó.▓SNÖA1ùJE╢║l]▓¿>\%└Å4ßO▄£â⌐& ê/)8vSP▀▓ôⁿææ√ü√ÑÄa⌠â╚4S╓╟P- ?Σá╕▓Næ*q╡UΘ▓≈^ñ·I.rúR&$Y^╚%è≡B┌≈Ceat
  370.     Color := RandColor;
  371.     SetColor(Color);
  372.     SetFillStyle(Random(CloseDotFill)+1, Color);
  373.     Bar3D(Random(MaxWidth), Random(MaxHeight),
  374.           Random(MaxWidth), Random(MaxHeight), 0, TopOff);
  375.   until KeyPressed;
  376.   WaitToGo;
  377. end; { RandBarPlay }
  378.  
  379. procedure ArcPlay;
  380. { Draw random arcs on the screen }
  381. var
  382.   MaxRadius : word;
  383.   EndAngle : word;
  384.   ArcInfo : ArcCoordsType;
  385. begin
  386.   MainWindow('Arc / GetArcCoords demonstration');
  387.   StatusLine('Esc aborts or press a key');
  388.   MaxRadius := MaxY div 10;
  389.   repeat
  390.     SetColor(RandColor);
  391.     EndAngle := Random(360);
  392.     SetLineStyle(SolidLn, 0, NormWidth);
  393.     Arc(Random(MaxX), Random(MaxY), Random(EndAngle), EndAngle, Random(MaxRadius));
  394.     GetArcCoords(ArcInfo);
  395.     with ArcInfo do
  396.     begin
  397.       Line(X, Y, XStart, YStart);
  398.       Line(X, Y, Xend, Yend);
  399.     end;
  400.   until KeyPressed;
  401.   WaitToGo;
  402. end; { ArcPlay }
  403.  
  404. procedure PutPixelPlay;
  405. { Demonstrate the PutPixel and GetPixel commands }
  406. const
  407.   Seed   = 1962; { A seed for the random number generator }
  408.   NumPts = 2000; { The number of pixels plotted }
  409.   Esc    = #27;
  410. var
  411.   I : word;
  412.   X, Y, Color : word;
  413.   XMax, YMax  : integer;
  414.   ViewInfo    : ViewPortType;
  415. begin
  416.   MainWindow('PutPixel / GetPixel demonstration');
  417.   StatusLine('Esc aborts or press a key...');
  418.  
  419.   GetViewSettings(ViewInfo);
  420.   with ViewInfo do
  421.   begin
  422.     XMax := (x2-x1-1);
  423.     YMax := (y2-y1-1);
  424.   end;
  425.  
  426.   while not KeyPressed do
  427.   begin
  428.     { Plot random pixels }
  429.     RandSeed := Seed;
  430.     I := 0;
  431.     while (not KeyPressed) and (I < NumPts) do
  432.     begin
  433.       Inc(I);
  434.         PutPixel(Random(XMax)+1, Random(YMax)+1, RandColor);
  435.     end;
  436.  
  437.     { Erase pixels }
  438.     RandSeed := Seed;
  439.     I := 0;
  440.     while (not KeyPressed) and (I < NumPts) do
  441.     begin
  442.       Inc(I);
  443.       X := Random(XMax)+1;
  444.       Y := Random(YMax)+1;
  445.       Color := GetPixel(X, Y);
  446.         if Color = RandColor then
  447.           PutPixel(X, Y, 0);
  448.      end;
  449.   end;
  450.   WaitToGo;
  451. end; { PutPixelPlay }
  452.  
  453. procedure PutImagePlay;
  454. { Demonstrate the GetImage and PutImage commands }
  455.  
  456. const
  457.   r  = 20;
  458.   StartX = 100;
  459.   StartY = 50;
  460.  
  461. var
  462.   CurPort : ViewPortType;
  463.  
  464. procedure MoveSaucer(var X, Y : integer; Width, Height : integer);
  465. var
  466.   Step : integer;
  467. begin
  468.   Step := Random(2*r);
  469.   if Odd(Step) then
  470.     Step := -Step;
  471.   X := X + Step;
  472.   Step := Random(r);
  473.   if Odd(Step) then
  474.     Step := -Step;
  475.   Y := Y + Step;
  476.  
  477.   { Make saucer bounce off viewport walls }
  478.   with CurPort do
  479.   begin
  480.     if (x1 + X + Width - 1 > x2) then
  481.       X := x2-x1 - Width + 1
  482.     else
  483.       if (X < 0) then
  484.         X := 0;
  485.     if (y1 + Y + Height - 1 > y2) then
  486.       Y := y2-y1 - Height + 1
  487.     else
  488.       if (Y < 0) then
  489.         Y := 0;
  490.   end;
  491. end; { MoveSaucer }
  492.  
  493. var
  494.   Pausetime : word;
  495.   Saucer    : pointer;
  496.   X, Y      : integer;
  497.   ulx, uly  : word;
  498.   lrx, lry  : word;
  499.   Size      : word;
  500.   I         : word;
  501. begin
  502.   ClearDevice;
  503.   FullPort;
  504.  
  505.   { PaintScreen }
  506.   ClearDevice;
  507.   MainWindow('GetImage / PutImage Demonstration');
  508.   StatusLine('Esc aborts or press a key...');
  509.   GetViewSettings(CurPort);
  510.  
  511.   { DrawSaucer }
  512.   Ellipse(StartX, StartY, 0, 360, r, (r div 3)+2);
  513.   Ellipse(StartX, StartY-4, 190, 357, r, r div 3);
  514.   Line(StartX+7, StartY-6, StartX+10, StartY-12);
  515.   Circle(StartX+10, StartY-12, 2);
  516.   Line(StartX-7, StartY-6, StartX-10, StartY-12);
  517.   Circle(StartX-10, StartY-12, 2);
  518.   SetFillStyle(SolidFill, MaxColor);
  519.   FloodFill(StartX+1, StartY+4, GetColor);
  520.  
  521.   { ReadSaucerImage }
  522.   ulx := StartX-(r+1);
  523.   uly := StartY-14;
  524.   lrx := StartX+(r+1);
  525.   lry := StartY+(r div 3)+3;
  526.  
  527.   Size := ImageSize(ulx, uly, lrx, lry);
  528.   GetMem(Saucer, Size);
  529.   GetImage(ulx, uly, lrx, lry, Saucer^);
  530. {  PutImage(ulx, uly, Saucer^, XORput);               { erase image }
  531.  
  532.   { Plot some "stars" }
  533.   for I := 1 to 1000 do
  534.      PutPixel(Random(MaxX), Random(MaxY), RandColor);
  535.   X := MaxX div 2;
  536.   Y := MaxY div 2;
  537.   PauseTime := 70;
  538.  
  539.   { Move the saucer around }
  540.   repeat
  541. {     PutImage(X, Y, Saucer^, XORput);                 { draw image }
  542.      Delay(PauseTime);
  543. {     PutImage(X, Y, Saucer^, XORput);                 { erase image }
  544.      MoveSaucer(X, Y, lrx - ulx + 1, lry - uly + 1);  { width/height }
  545.   until KeyPressed;
  546.   FreeMem(Saucer, size);
  547.   WaitToGo;
  548. end; { PutImagePlay }
  549.  
  550. procedure PolyPlay;
  551. { Draw random polygons with random fill styles on the screen }
  552. const
  553.   MaxPts = 5;
  554. type
  555.   PolygonType = array[1..MaxPts] of PointType;
  556. var
  557.   Poly : PolygonType;
  558.   I, Color : word;
  559. begin
  560.   MainWindow('FillPoly demonstration');
  561.   StatusLine('Esc aborts or press a key...');
  562.   repeat
  563.     Color := RandColor;
  564.     SetFillStyle(Random(11)+1, Color);
  565.     SetColor(Color);
  566.     for I := 1 to MaxPts do
  567.       with Poly[I] do
  568.       begin
  569.         X := Random(MaxX);
  570.         Y := Random(MaxY);
  571.       end;
  572.     FillPoly(MaxPts, Poly);
  573.   until KeyPressed;
  574.   WaitToGo;
  575. end; { PolyPlay }
  576.  
  577. procedure FillStylePlay;
  578. { Display all of the predefined fill styles available }
  579. var
  580.   Style    : word;
  581.   Width    : word;
  582.   Height   : word;
  583.   X, Y     : word;
  584.   I, J     : word;
  585.   ViewInfo : ViewPortType;
  586.  
  587. procedure DrawBox(X, Y : word);
  588. begin
  589.   SetFillStyle(Style, MaxColor);
  590.   with ViewInfo do
  591.     Bar(X, Y, X+Width, Y+Height);
  592.   Rectangle(X, Y, X+Width, Y+Height);
  593.   OutTextXY(X+(Width div 2), Y+Height+4, Int2Str(Style));
  594.   Inc(Style);
  595. end; { DrawBox }
  596.  
  597. begin
  598.   MainWindow('Pre-defined fill styles');
  599.   GetViewSettings(ViewInfo);
  600.   with ViewInfo do
  601.   begin
  602.     Width := 2 * ((x2+1) div 13);
  603.     Height := 2 * ((y2-10) div 10);
  604.   end;
  605.   X := Width div 2;
  606.   Y := Height div 2;
  607.   Style := 0;
  608.   for J := 1 to 3 do
  609.   begin
  610.     for I := 1 to 4 do
  611.     begin
  612.       DrawBox(X, Y);
  613.       Inc(X, (Width div 2) * 3);
  614.     end;
  615.     X := Width div 2;
  616.     Inc(Y, (Height div 2) * 3);
  617.   end;
  618.   SetTextJustify(LeftText, TopText);
  619.   WaitToGo;
  620. end; { FillStylePlay }
  621.  
  622. procedure FillPatternPlay;
  623. { Display some user defined fill patterns }
  624. const
  625.   Patterns : array[0..11] of FillPatternType = (
  626.   ($AA, $55, $AA, $55, $AA, $55, $AA, $55 üÖü üÖü  !BBäx!!!BBäx!BBäx"""DDêp""DDêp>"""BBääêp""!"BDäêêp>IÉÆ|      ° @≥î>00>><Dêx  !BBäx""DDêp&<"DDêê&22TTêêê$> $< @äêp>          ⁿBBBB<  @@Ç****DDDDDDDU¬U¬U¬U¬U¬U¬U¬▌w▌w▌w▌w▌w▌w▌w°°°≥■°°≥≥■≥≥■■°°°    ≤  ≤  ≤≤         °                     ≡≡≡≡≡≡≡≡≡≡≡≡≡≡       ;DDD;    $"Bdÿ>@@@>||>Ac]AAA1N"A""2,  `1NA"*III*<Bü üB<<BüüüB<A" \"QIE" < <BBBB  @@    ~ ?  @ÇB$$B ""A$$"AII6 üBr»$**IIII**ccregion.  The region is defined as any pixel of
  627.             OldColor which