home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / PASTUT34 / GRAPHICS.TXT < prev    next >
Text File  |  1993-06-12  |  3KB  |  80 lines

  1.                        GRAPHICS.
  2.                        ▀▀▀▀▀▀▀▀▀
  3.  
  4. More than 70 graphics functions and procedures are provided with Turbo
  5. Pascal version 6.0 and together with 20 Crt functions and procedures
  6. provide an excellent environment for screen graphics.
  7.  
  8. A typical graphics command is LINE(x1,y1,x2,y2: integer);
  9.  
  10. The syntax in version 3 was different and the definition of a graphics
  11. screen was also different, so care must be taken if converting between
  12. versions. Borland provide a 'Unit' called Graph3 which can be used in
  13. place of the new unit called Graph so that version 3 graphics can still
  14. be used.
  15.  
  16. With version 6.0, the first requirement is to make the units Crt and
  17. Graph available to the user program by the declaration:
  18.  
  19. USES Crt,Graph;
  20.  
  21. The following six statements (or similar) should then be included in the
  22. program, after the appropriate declaration of the variables:
  23.  
  24. var
  25.    GraphDriver,GraphMode,Detect  : integer;
  26.    MaxX,MaxY                     : integer;
  27.    ....
  28.    ....
  29. Begin
  30.   Detect:=0;
  31.   GraphDriver:=Detect;
  32.   InitGraph(GraphDriver,GraphMode,'');
  33.   MaxX:=GetMaxX;
  34.   MaxY:=GetMaxY;
  35.   SetViewPort(0,0,MaxX,MaxY,ClipOff);
  36.   ....
  37.  
  38.  
  39. The first three commands initialize the graphics to suit the present
  40. hardware, but it is essential that the appropriate *.BGI file is
  41. available on the default drive. i.e. the file CGA.BGI should be
  42. available for a CGA monitor (320 x 200) or EGAVGA.BGI for a VGA display
  43. (640 x 480 pixels). The last three commands determine the size of the
  44. screen in pixels and in this case set the whole screen for graphics output.
  45.  
  46. The background and foreground colours should be set by use of the commands:
  47.  
  48. SetBkColor(ColorNum:word);         {Note the American spelling of Color}
  49.  
  50. SetColor(ColorNum:word);
  51.  
  52. The various colours have predefined constant values.
  53.  
  54. Black   =0;
  55. Blue    =1;
  56. ......
  57. Red     =4;
  58. ......
  59. White   =15;
  60.  
  61. The program GRAPHICS.PAS illustrates the graphics procedures by drawing
  62. a parabola on the screen as a series of very small straight lines. This
  63. program is incomplete in order that the user can add the necessary
  64. statements to show markers on the axes, with appropriate values.
  65.  
  66. Although this is only a very simple program, it would have been wise to
  67. place all the graphics initialization statements into a procedure, to
  68. allow greater flexibility and extension. (But note that the procedure
  69. InitGraph exists and has already been called above, so avoid a second
  70. use of this name).
  71.  
  72. To appreciate the many graphics procedures provided by Turbo Pascal,
  73. users should run the program BGIDEMO.EXE which is available on the
  74. diskettes supplied by Borland.
  75.  
  76.  
  77. GRAPHICS.TXT
  78. Revised 22.1.93
  79.  
  80.