/// <summary>
        /// Returns the intersection of two Rectangleis.
        /// <para>Intersection is a Rectanglei that is only the space
        /// that both Rectangleis occupy.</para>
        /// </summary>
        public static Rectanglei Intersection(Rectanglei a, Rectanglei b)
        {
            // Modifed From http://kickjava.com/src/java/awt/Rectanglei.java.htm
            int tx1 = a.X;
            int ty1 = a.Y;
            int rx1 = b.X;
            int ry1 = b.Y;

            int tx2 = a.Right;
            int ty2 = a.Bottom;
            int rx2 = b.Right;
            int ry2 = b.Bottom;

            if (tx1 < rx1)
            {
                tx1 = rx1;
            }
            if (ty1 < ry1)
            {
                ty1 = ry1;
            }
            if (tx2 > rx2)
            {
                tx2 = rx2;
            }
            if (ty2 > ry2)
            {
                ty2 = ry2;
            }

            tx2 -= tx1;
            ty2 -= ty1;

            return(new Rectanglei(tx1, ty1, tx2, ty2));
        }
 /// <summary>
 /// Returns whether the given Rectanglei is
 /// intersecting with this Rectanglei.
 /// </summary>
 public bool Intersects(Rectanglei rect)
 {
     return(rect.Right >= X &&
            rect.Bottom >= Y &&
            rect.X <= Right &&
            rect.Y <= Bottom);
 }
        /// <summary>
        /// Returns the union of two Rectangleis.
        /// <para>Union is a Rectanglei that tightly fits both Rectangleis.</para>
        /// </summary>
        public static Rectanglei Union(Rectanglei a, Rectanglei b)
        {
            int x1 = Math.Min(a.X, b.Y);
            int x2 = Math.Max(a.Right, b.Right);
            int y1 = Math.Min(a.Y, b.Y);
            int y2 = Math.Max(a.Bottom, b.Bottom);

            return(new Rectanglei(x1, y1, x2 - x1, y2 - y1));
        }
        /// <summary>
        /// Returns a scaled version of this Rectanglei
        /// </summary>
        public Rectanglei GetScaled(int x, int y)
        {
            Rectanglei rect = this.Clone();

            rect.Width  *= x;
            rect.Height *= y;

            return(rect);
        }
        /// <summary>
        /// Returns whether this Rectanglei equals the other object in value.
        /// <para>Only true if the object is a RectangleiF or Rectanglei and
        /// their values are the same.</para>
        /// </summary>
        public override bool Equals(object obj)
        {
            if (obj != null)
            {
                if (obj is Rectanglei)
                {
                    Rectanglei other = (Rectanglei)obj;
                    return(X == other.X &&
                           Y == other.Y &&
                           Width == other.Width &&
                           Height == other.Height);
                }
                else if (obj is Rectanglei)
                {
                    Rectanglei other = (Rectanglei)obj;
                    return(X == other.X &&
                           Y == other.Y &&
                           Width == other.Width &&
                           Height == other.Height);
                }
            }

            return(false);
        }
 public static Rectanglei Divide(Rectanglei a, Rectanglei b)
 {
     return(new Rectanglei(a.X / b.X, a.Y / b.Y, a.Width / b.Width, a.Height / b.Height));
 }
 public static Rectanglei Subtract(Rectanglei a, Vector2i b)
 {
     return(new Rectanglei(a.X - b.X, a.Y - b.Y, a.Width, a.Height));
 }
 public static Rectanglei Add(Rectanglei a, Vector2i b)
 {
     return(new Rectanglei(a.X + b.X, a.Y + b.Y, a.Width, a.Height));
 }
 public static Rectanglei Multiply(Rectanglei a, Rectanglei b)
 {
     return(new Rectanglei(a.X * b.X, a.Y * b.Y, a.Width * b.Width, a.Height * b.Height));
 }
 public static Rectanglei operator -(Rectanglei a, Vector2i b)
 {
     return(Rectanglei.Subtract(a, b));
 }
 public static Rectanglei operator +(Rectanglei a, Vector2i b)
 {
     return(Rectanglei.Add(a, b));
 }
 public static Rectanglei operator /(Rectanglei a, Rectanglei b)
 {
     return(Rectanglei.Divide(a, b));
 }
 public static Rectanglei operator *(Rectanglei a, Rectanglei b)
 {
     return(Rectanglei.Multiply(a, b));
 }
 /// <summary>
 /// Returns the intersection of this Rectanglei and another.
 /// <para>Intersection is a Rectanglei that is only the space
 /// that both Rectangleis occupy.</para>
 /// </summary>
 public Rectanglei Intersection(Rectanglei other)
 {
     return(Rectanglei.Intersection(this, other));
 }
 /// <summary>
 /// Returns the union of this Rectanglei and another.
 /// <para>Union is a Rectanglei that tightly fits both Rectangleis.</para>
 /// </summary>
 public Rectanglei Union(Rectanglei other)
 {
     return(Rectanglei.Union(this, other));
 }