/[projectaxis]/projectaxis/IsoEngine/IsoGeometryTools.cpp
ViewVC logotype

Diff of /projectaxis/IsoEngine/IsoGeometryTools.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by vovansim, Sat Jun 7 01:43:40 2003 UTC revision 1.3 by vovansim, Sat Jun 7 03:55:14 2003 UTC
# Line 12  Line 12 
12   * different chunks of code and having to convert between them.   * different chunks of code and having to convert between them.
13   *   *
14   * Revision history:   * Revision history:
15     *     v1.4 - added the UnionRect method
16   *     v1.3 - added the IsRectEmpty and the IntersectRect methods   *     v1.3 - added the IsRectEmpty and the IntersectRect methods
17   *     v1.2 - added the setRect method   *     v1.2 - added the setRect method
18   *     v1.1 - added the PointInRect and the setRectEmpty methods   *     v1.1 - added the PointInRect and the setRectEmpty methods
19   *   *
20   * @author <A href="mailto:vovansim@hotmail.com">Vovansim (aka Scorpion)</A>   * @author <A href="mailto:vovansim@hotmail.com">Vovansim (aka Scorpion)</A>
21   * @version 1.3   * @version 1.4
22   * @date June 4, 2003   * @date June 6, 2003
23   */   */
24    
25  #include "IsoGeometryTools.h"  #include "IsoGeometryTools.h"
# Line 180  bool IntersectRect(RECT* destination, RE Line 181  bool IntersectRect(RECT* destination, RE
181    return !IsRectEmpty(destination);    return !IsRectEmpty(destination);
182  }  }
183    
184    /** Makes the dimensions of destination rectangle equal to the union of the two source rectangles.
185     *
186     * @note The union is the smallest rectangle that contains both source rectangles.
187     *
188     * @param destination a destination rectangle.
189     * @param rectangle1 a source rectangle.
190     * @param rectangle2 a source rectangle.
191     * @return true if the union is non-empty, false if it is.
192     */
193    bool UnionRect(RECT* destination, RECT* rectangle1, RECT* rectangle2) {
194            //Choose the left value:
195            if(rectangle1->left < rectangle2->left) {
196                    destination->left = rectangle1->left;
197            } else {
198                    destination->left = rectangle2->left;
199            }
200            
201            //Choose the top value:
202            if(rectangle1->top < rectangle2->top) {
203                    destination->top = rectangle1->top;
204            } else {
205                    destination->top = rectangle2->top;
206            }
207            
208            //Choose the right value:
209            if(rectangle1->right > rectangle2->right) {
210                    destination->right = rectangle1->right;
211            } else {
212                    destination->right = rectangle2->right;
213            }
214            
215            //Choose the bottom value:
216            if(rectangle1->bottom > rectangle2->bottom) {
217                    destination->bottom = rectangle1->bottom;
218            } else {
219                    destination->bottom = rectangle2->bottom;
220            }
221    
222            return !IsRectEmpty(destination);
223    }
224    
225  /** Makes an SDL_Rect out of a RECT. */  /** Makes an SDL_Rect out of a RECT. */
226  SDL_Rect* GetSDLRect(RECT* r) {  SDL_Rect* GetSDLRect(RECT* r) {
227    SDL_Rect* result = new SDL_Rect();    SDL_Rect* result = new SDL_Rect();

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26