Exemplo n.º 1
0
        /// <summary>
        /// Intersects the pair of specified source <code>Rectangle2D</code>
        /// objects and puts the result into the specified destination
        /// <code>Rectangle2D</code> object.  One of the source rectangles
        /// can also be the destination to avoid creating a third Rectangle2D
        /// object, but in this case the original points of this source
        /// rectangle will be overwritten by this method. </summary>
        /// <param name="src1"> the first of a pair of <code>Rectangle2D</code>
        /// objects to be intersected with each other </param>
        /// <param name="src2"> the second of a pair of <code>Rectangle2D</code>
        /// objects to be intersected with each other </param>
        /// <param name="dest"> the <code>Rectangle2D</code> that holds the
        /// results of the intersection of <code>src1</code> and
        /// <code>src2</code>
        /// @since 1.2 </param>
        public static void Intersect(Rectangle2D src1, Rectangle2D src2, Rectangle2D dest)
        {
            double x1 = System.Math.Max(src1.MinX, src2.MinX);
            double y1 = System.Math.Max(src1.MinY, src2.MinY);
            double x2 = System.Math.Min(src1.MaxX, src2.MaxX);
            double y2 = System.Math.Min(src1.MaxY, src2.MaxY);

            dest.SetFrame(x1, y1, x2 - x1, y2 - y1);
        }