home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / c / other / graphics / figure.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-31  |  1.8 KB  |  57 lines

  1. /* FIGURE.C illustrates graphics drawing functions including:
  2.  *      _setpixel   _lineto     _moveto     _rectangle      _ellipse
  3.  *      _arc        _pie
  4.  *
  5.  * Window versions of graphics drawing functions (such as _rectangle_w,
  6.  * _ellipse_wxy, and _lineto_w) are illustrated in WINDOW.C and GEDIT.C.
  7.  */
  8.  
  9. #include <conio.h>
  10. #include <stdlib.h>
  11. #include <graph.h>
  12.  
  13. main()
  14. {
  15.     short x, y;
  16.     short mode = _VRES16COLOR;
  17.  
  18.     while( !_setvideomode( mode ) )     /* Find best graphics mode   */
  19.         mode--;
  20.     if( mode == _TEXTMONO )
  21.         exit( 1 );                      /* No graphics available     */
  22.  
  23.     for( x = 10, y = 50; y < 90; x += 2, y += 3 )/* Draw pixels      */
  24.         _setpixel( x, y );
  25.     getch();
  26.  
  27.     for( x = 60, y = 50; y < 90; y += 3 )        /* Draw lines       */
  28.     {
  29.         _moveto( x, y );
  30.         _lineto( x + 20, y );
  31.     }
  32.     getch();
  33.  
  34.     x = 110; y = 70;                             /* Draw rectangles  */
  35.     _rectangle( _GBORDER,       x - 20, y - 20, x, y );
  36.     _rectangle( _GFILLINTERIOR, x + 20, y + 20, x, y );
  37.     getch();
  38.  
  39.     x = 160;                                     /* Draw ellipses    */
  40.     _ellipse( _GBORDER,       x - 20, y - 20, x, y );
  41.     _ellipse( _GFILLINTERIOR, x + 20, y + 20, x, y );
  42.     getch();
  43.  
  44.     x = 210;                                     /* Draw arcs        */
  45.     _arc( x - 20, y - 20, x, y, x, y - 10, x - 10, y );
  46.     _arc( x + 20, y + 20, x, y, x + 10, y + 20, x + 20, y + 10 );
  47.     getch();
  48.  
  49.     x = 260;                                    /* Draw pies        */
  50.     _pie( _GBORDER,       x - 20, y - 20, x, y, x, y - 10, x - 10, y );
  51.     _pie( _GFILLINTERIOR, x + 20, y + 20, x, y,
  52.                           x + 10, y + 20, x + 20, y + 10 );
  53.     getch();
  54.  
  55.     exit( !_setvideomode( _DEFAULTMODE ) );
  56. }
  57.