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

  1. /* Listing 11-6 */
  2.  
  3. #define    Xmax    640
  4.  
  5. #define    TRUE    1
  6. #define    FALSE    0
  7.  
  8. main()
  9. {
  10.     int    x0    = 0;        /* corners of box at 0,0 and 150,100 */
  11.     int    y0    = 0;
  12.     int    x1    = 150;
  13.     int    y1    = 100;
  14.     int    n = 12;            /* pixel value */
  15.  
  16.  
  17.     while( x1 < Xmax )            /* slide box right */
  18.       XORBox( x0++, y0, x1++, y1, n );
  19.  
  20.     while( x0 > 0 )                /* slide box left */
  21.       XORBox( --x0, y0, --x1, y1, n );
  22. }
  23.  
  24.  
  25. XORBox ( x0, y0, x1, y1, n )
  26. int    x0,y0,x1,y1;        /* pixel coordinates of opposite corners */
  27. int    n;            /* pixel value */
  28. {
  29.     Rectangle( x0, y0, x1, y1, n );                 /* draw the box */
  30.     Rectangle( x0, y0, x1, y1, n );                /* erase the box */
  31. }
  32.  
  33.  
  34. Rectangle( x0, y0, x1, y1, n )
  35. int    x0,y0,x1,y1;
  36. int    n;
  37. {
  38.     Line10( x0, y0, x0, y1, n );
  39.     Line10( x0, y0, x1, y0, n );
  40.     Line10( x1, y1, x0, y1, n );
  41.     Line10( x1, y1, x1, y0, n );
  42. }
  43.