home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / XenonSource.exe / gamesystem / source / gs_rect.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-03  |  1.1 KB  |  41 lines

  1. //-------------------------------------------------------------
  2. //
  3. // Class:    gsCRectangle
  4. //
  5. // Author:    John M Phillips
  6. //
  7. // Started:    12/03/00
  8. //
  9. // Base:    gsCObject
  10. //
  11. // Derived:    None
  12. //
  13. //-------------------------------------------------------------
  14.  
  15. #include "gamesystem.h"
  16.  
  17. //-------------------------------------------------------------
  18. // Clip dest against this and adjust source as well
  19.  
  20. void gsCRect::clip(gsCRect& source,gsCRect& dest)
  21. {
  22.     if (dest.m_rect.left < m_rect.left) {
  23.         source.m_rect.left += (m_rect.left - dest.m_rect.left);
  24.         dest.m_rect.left = m_rect.left;
  25.         }
  26.     if (dest.m_rect.right > m_rect.right) {
  27.         source.m_rect.right -= (dest.m_rect.right - m_rect.right);
  28.         dest.m_rect.right = m_rect.right;
  29.         }
  30.     if (dest.m_rect.top < m_rect.top) {
  31.         source.m_rect.top += (m_rect.top - dest.m_rect.top);
  32.         dest.m_rect.top = m_rect.top;
  33.         }
  34.     if (dest.m_rect.bottom > m_rect.bottom) {
  35.         source.m_rect.bottom -= (dest.m_rect.bottom - m_rect.bottom);
  36.         dest.m_rect.bottom = m_rect.bottom;
  37.         }
  38. }
  39.  
  40. //-------------------------------------------------------------
  41.