home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 287_01 / coord.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-05-23  |  1.0 KB  |  70 lines

  1. #include <stdio.h>
  2. #include <gds.h>
  3.  
  4. SetOrg(x,y)
  5. int x,y;
  6. {
  7.     ORGX=x;
  8.     ORGY=y;
  9. }
  10.  
  11. RelOrg(x,y)
  12. int x,y;
  13. {
  14.     ORGX += x;
  15.     ORGY += y;
  16. }
  17.  
  18. SetWin(x1,y1,x2,y2)
  19. int x1,y1,x2,y2;
  20. {
  21.     int temp;
  22.  
  23.     if (x1 > x2) {
  24.         temp=x1; 
  25.         x1=x2; 
  26.         x2=temp;
  27.     }
  28.     if (y1 > y2) {
  29.         temp=y1; 
  30.         y1=y2; 
  31.         y2=temp;
  32.     }
  33.     x1 += ORGX; 
  34.     x2 += ORGX;
  35.     y1 += ORGY; 
  36.     y2 += ORGY;
  37.     if (x1 > XLIMIT)
  38.         WINX2=WINX1=XLIMIT;
  39.     else {
  40.         if (x1 < 0)
  41.             WINX1=0;
  42.         else
  43.             WINX1=x1;
  44.         if (x2 > XLIMIT)
  45.             WINX2=XLIMIT;
  46.         else
  47.             WINX2=x2;
  48.     }
  49.     if (y1 > YLIMIT)
  50.         WINY2=WINY1=YLIMIT;
  51.     else {
  52.         if (y1 < 0)
  53.             WINY1=0;
  54.         else
  55.             WINY1=y1;
  56.         if (y2 > YLIMIT)
  57.             WINY2=YLIMIT;
  58.         else
  59.             WINY2=y2;
  60.     }
  61. }
  62.  
  63. ResetWin()
  64. {
  65.     WINX1=WINY1=0;
  66.     WINX2=XLIMIT;
  67.     WINY2=YLIMIT;
  68. }
  69.  
  70.