Ejemplo n.º 1
0
 /// <summary>
 ///     Unions two specified <see cref="RectangleF">rectangles</see>
 /// </summary>
 public static RectangleF Union(RectangleF value1, RectangleF value2)
 {
     var x = Math.Min(value1.X, value2.X);
     var y = Math.Min(value1.Y, value2.Y);
     return new RectangleF(x, y,
         Math.Max(value1.Right, value2.Right) - x,
         Math.Max(value1.Bottom, value2.Bottom) - y);
 }
Ejemplo n.º 2
0
 /// <summary>
 ///     Unions two specified <see cref="RectangleF">rectangles</see>
 /// </summary>
 public static void Union(ref RectangleF value1, ref RectangleF value2, out RectangleF result)
 {
     result.X = Math.Min(value1.X, value2.X);
     result.Y = Math.Min(value1.Y, value2.Y);
     result.Width = Math.Max(value1.Right, value2.Right) - result.X;
     result.Height = Math.Max(value1.Bottom, value2.Bottom) - result.Y;
 }
Ejemplo n.º 3
0
 /// <summary>
 ///     Returns a new <see cref="RectangleF" /> that contains overlapping region of two other rectangles.
 /// </summary>
 public static RectangleF Intersect(RectangleF value1, RectangleF value2)
 {
     RectangleF rectangle;
     Intersect(ref value1, ref value2, out rectangle);
     return rectangle;
 }
Ejemplo n.º 4
0
 /// <summary>
 ///     Returns a new <see cref="RectangleF" /> that contains overlapping region of two other rectangles.
 /// </summary>
 public static void Intersect(ref RectangleF value1, ref RectangleF value2, out RectangleF result)
 {
     if (value1.Intersects(value2))
     {
         var rightSide = Math.Min(value1.X + value1.Width, value2.X + value2.Width);
         var leftSide = Math.Max(value1.X, value2.X);
         var topSide = Math.Max(value1.Y, value2.Y);
         var bottomSide = Math.Min(value1.Y + value1.Height, value2.Y + value2.Height);
         result = new RectangleF(leftSide, topSide, rightSide - leftSide, bottomSide - topSide);
     }
     else
     {
         result = new RectangleF(0, 0, 0, 0);
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 ///     Returns whether thee other <see cref="RectangleF" /> intersects with this rectangle.
 /// </summary>
 public void Intersects(ref RectangleF value, out bool result) => result = value.Left < Right && Left < value.Right &&
                                                                           value.Top < Bottom && Top < value.Bottom;
Ejemplo n.º 6
0
 /// <summary>
 ///     Returns whether the other <see cref="RectangleF" /> intersects with this RectangleF.
 /// </summary>
 public bool Intersects(RectangleF value) => value.Left <= Right && Left <= value.Right &&
                                             value.Top <= Bottom && Top <= value.Bottom;
Ejemplo n.º 7
0
 /// <summary>
 ///     Returns whether the current instance is equal to specified <see cref="RectangleF" />.
 /// </summary>
 public bool Equals(RectangleF other) => this == other;
Ejemplo n.º 8
0
 /// <summary>
 ///     Returns whether the specified <see cref="RectangleF" /> lies within the bounds of this <see cref="RectangleF" />.
 /// </summary>
 public void Contains(ref RectangleF value, out bool result) => result = (X <= value.X) &&
                                                                         (value.X + value.Width <= X + Width) &&
                                                                         (Y <= value.Y) &&
                                                                         (value.Y + value.Height <= Y + Height);
Ejemplo n.º 9
0
 /// <summary>
 ///     Returns whether the specified <see cref="RectangleF" /> lies within the bounds of this <see cref="RectangleF" />.
 /// </summary>
 public bool Contains(RectangleF value)
     => (X <= value.X) && (value.X + value.Width <= X + Width) && (Y <= value.Y) && (value.Y + value.Height <= Y + Height);