Clone() public method

${core_Rectangle2D_method_Clone_D}
public Clone ( ) : Rectangle2D
return Rectangle2D
Ejemplo n.º 1
0
        /// <summary>${core_Rectangle2D_method_union_Rectangle2D_D}</summary>
        /// <param name="rect">${core_Rectangle2D_method_union_Rectangle2D_param_rect}</param>
        /// <returns>${core_Rectangle2D_method_union_return}</returns>
        public Rectangle2D Union(Rectangle2D rect)
        {
            if (Rectangle2D.IsNullOrEmpty(rect))
            {
                return this.Clone();
            }
            if (Rectangle2D.IsNullOrEmpty(this))
            {
                return rect.Clone();
            }
            else
            {
                double minLeft = Math.Min(this.Left, rect.Left);
                double minBottom = Math.Min(this.Bottom, rect.Bottom);
                double maxRight = Math.Max(this.Right, rect.Right);
                double maxTop = Math.Max(this.Top, rect.Top);
                Rectangle2D clone = this.Clone();
                clone._width = Math.Max((double)(maxRight - minLeft), (double)0.0);
                clone._height = Math.Max((double)(maxTop - minBottom), (double)0.0);
                clone._x = minLeft;
                clone._y = minBottom;

                return clone;
            }
        }