예제 #1
0
 internal static RectangleFP ToRectangleFP(Rectangle rect)
 {
     return new RectangleFP(
             SingleFP.FromInt(rect.GetMinX()),
             SingleFP.FromInt(rect.GetMinY()),
             SingleFP.FromInt(rect.GetMaxX()),
             SingleFP.FromInt(rect.GetMaxY()));
 }
예제 #2
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Unions the pair of source <code>Rectangle</code> objects
  * and puts the result into the specified destination
  * <code>Rectangle</code> object.  One of the source rectangles
  * can also be the destination to avoid creating a third Rectangle
  * object, but in this case the original points of this source
  * rectangle will be overwritten by this method.
  * @param src1 the first of a pair of <code>Rectangle</code>
  * objects to be combined with each other
  * @param src2 the second of a pair of <code>Rectangle</code>
  * objects to be combined with each other
  * @param dest the <code>Rectangle</code> that holds the
  * results of the union of <code>src1</code> and
  * <code>src2</code>
  */
 public static void Union(Rectangle src1,
         Rectangle src2,
         Rectangle dest)
 {
     int x1 = Math.Min(src1.GetMinX(), src2.GetMinX());
     int y1 = Math.Min(src1.GetMinY(), src2.GetMinY());
     int x2 = Math.Max(src1.GetMaxX(), src2.GetMaxX());
     int y2 = Math.Max(src1.GetMaxY(), src2.GetMaxY());
     dest.SetFrameFromDiagonal(x1, y1, x2, y2);
 }
예제 #3
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Adds a <code>Rectangle</code> object to this
  * <code>Rectangle</code>.  The resulting <code>Rectangle</code>
  * is the union of the two <code>Rectangle</code> objects.
  * @param r the <code>Rectangle</code> to add to this
  * <code>Rectangle</code>.
  */
 public void Add(Rectangle r)
 {
     int x1 = Math.Min(GetMinX(), r.GetMinX());
     int x2 = Math.Max(GetMaxX(), r.GetMaxX());
     int y1 = Math.Min(GetMinY(), r.GetMinY());
     int y2 = Math.Max(GetMaxY(), r.GetMaxY());
     SetRect(x1, y1, x2 - x1, y2 - y1);
 }
예제 #4
0
 ////////////////////////////////////////////////////////////////////////////
 //--------------------------------- REVISIONS ------------------------------
 // Date       Name                 Tracking #         Description
 // ---------  -------------------  -------------      ----------------------
 // 13JUN2009  James Shen                 	          Initial Creation
 ////////////////////////////////////////////////////////////////////////////
 /**
  * Intersects the pair of specified source <code>Rectangle</code>
  * objects and puts the result into the specified destination
  * <code>Rectangle</code> object.  One of the source rectangles
  * can also be the destination to avoid creating a third Rectangle
  * object, but in this case the original points of this source
  * rectangle will be overwritten by this method.
  * @param src1 the first of a pair of <code>Rectangle</code>
  * objects to be intersected with each other
  * @param src2 the second of a pair of <code>Rectangle</code>
  * objects to be intersected with each other
  * @param dest the <code>Rectangle</code> that holds the
  * results of the intersection of <code>src1</code> and
  * <code>src2</code>
  */
 public static void Intersect(Rectangle src1,
         Rectangle src2,
         Rectangle dest)
 {
     int x1 = Math.Max(src1.GetMinX(), src2.GetMinX());
     int y1 = Math.Max(src1.GetMinY(), src2.GetMinY());
     int x2 = Math.Min(src1.GetMaxX(), src2.GetMaxX());
     int y2 = Math.Min(src1.GetMaxY(), src2.GetMaxY());
     dest.SetFrame(x1, y1, x2 - x1, y2 - y1);
 }