home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / video / 11 / 11_7.c < prev   
Encoding:
C/C++ Source or Header  |  1988-08-11  |  808 b   |  36 lines

  1. /* Listing 11-7 */
  2.  
  3. #define    Xmax    640            /* screen dimensions in 640x350 mode */
  4. #define    Ymax    350
  5.  
  6. main()
  7. {
  8.     int    x0    = 150;        /* fixed endpoint at 150,100 */
  9.     int    y0    = 100;
  10.     int    x    = 0;        /* moving endpoint at 0,0 */
  11.     int    y    = 0;
  12.     int    n    = 12;        /* pixel value */
  13.  
  14.  
  15.     for( ; x<Xmax; x++ )            /* move right */
  16.       XORLine( x0, y0, x, y, n );
  17.  
  18.     for( --x; y<Ymax; y++ )            /* move down */
  19.       XORLine( x0, y0, x, y, n );
  20.  
  21.     for( --y; x>=0; --x )            /* move left */
  22.       XORLine( x0, y0, x, y, n );
  23.  
  24.     for( x++; y>=0; --y )            /* move up */
  25.       XORLine( x0, y0, x, y, n );
  26. }
  27.  
  28.  
  29. XORLine ( x0, y0, x1, y1, n )
  30. int    x0,y0,x1,y1;        /* endpoints */
  31. int    n;            /* pixel value */
  32. {
  33.     Line10( x0, y0, x1, y1, n );             /* the line is onscreen */
  34.     Line10( x0, y0, x1, y1, n );               /* the line is erased */
  35. }
  36.