public static bool Equals(RectangleI rect1, RectangleI rect2) { if (rect1.IsEmpty) { return(rect2.IsEmpty); } return(rect1.X.Equals(obj: rect2.X) && rect1.Y.Equals(obj: rect2.Y) && rect1.Width.Equals(obj: rect2.Width) && rect1.Height.Equals(obj: rect2.Height)); }
public void Intersect(RectangleI rect) { if (!IntersectsWith(rect: rect)) { this = Empty; } else { var num1 = Math.Max(val1: Left, val2: rect.Left); var num2 = Math.Max(val1: Top, val2: rect.Top); this._width = Math.Max(val1: Math.Min(val1: Right, val2: rect.Right) - num1, val2: 0); this._height = Math.Max(val1: Math.Min(val1: Bottom, val2: rect.Bottom) - num2, val2: 0); this._x = num1; this._y = num2; } }
internal static PointI OffsetPinchPoints( PointI targetPoint, RectangleI boundingRectangle, uint distance, float direction) { var num1 = distance / 2.0; var num2 = direction * Math.PI / 180.0; var offsetX = (int)Math.Round(a: num1 * Math.Cos(d: num2)); var offsetY = (int)Math.Round(a: num1 * Math.Sin(a: num2)); if (targetPoint.X + offsetX > boundingRectangle.Right || targetPoint.X + offsetX < boundingRectangle.Left || targetPoint.Y + offsetY > boundingRectangle.Bottom || targetPoint.Y + offsetY < boundingRectangle.Top) { Log.Out(msg: "Target points are outside of target object"); } targetPoint.Offset(offsetX: offsetX, offsetY: offsetY); return(targetPoint); }
public void Union(RectangleI rect) { if (IsEmpty) { this = rect; } else { if (rect.IsEmpty) { return; } var num1 = Math.Min(val1: Left, val2: rect.Left); var num2 = Math.Min(val1: Top, val2: rect.Top); this._width = Math.Max(val1: Math.Max(val1: Right, val2: rect.Right) - num1, val2: 0); this._height = Math.Max(val1: Math.Max(val1: Bottom, val2: rect.Bottom) - num2, val2: 0); this._x = num1; this._y = num2; } }
public bool Equals(RectangleI value) { return(Equals(rect1: this, rect2: value)); }
public static RectangleI Inflate(RectangleI rect, int width, int height) { rect.Inflate(width: width, height: height); return(rect); }
public static RectangleI Inflate(RectangleI rect, SizeI size) { rect.Inflate(width: size._width, height: size._height); return(rect); }
public static RectangleI Offset(RectangleI rect, int offsetX, int offsetY) { rect.Offset(offsetX: offsetX, offsetY: offsetY); return(rect); }
public static RectangleI Union(RectangleI rect, PointI point) { rect.Union(rect: new RectangleI(point1: point, point2: point)); return(rect); }
public static RectangleI Union(RectangleI rect1, RectangleI rect2) { rect1.Union(rect: rect2); return(rect1); }
public static RectangleI Intersect(RectangleI rect1, RectangleI rect2) { rect1.Intersect(rect: rect2); return(rect1); }
public bool IntersectsWith(RectangleI rect) { return(!IsEmpty && !rect.IsEmpty && rect.Left <= Right && rect.Right >= Left && rect.Top <= Bottom && rect.Bottom >= Top); }
public bool Contains(RectangleI rect) { return(!IsEmpty && !rect.IsEmpty && this._x <= rect._x && this._y <= rect._y && this._x + this._width >= rect._x + rect._width && this._y + this._height >= rect._y + rect._height); }