Click or drag to resize

RectExtensions Class

Helper extensions to handel Unity rectangles.
Inheritance Hierarchy
SystemObject
  KSPDev.ExtensionsRectExtensions

Namespace:  KSPDev.Extensions
Assembly:  KSPDev_Utils.1.2 (in KSPDev_Utils.1.2.dll) Version: 1.2 for KSP v1.6+
Syntax
C#
public static class RectExtensions
Request Example View Source

The RectExtensions type exposes the following members.

Methods
  NameDescription
Public methodStatic memberCode exampleIntersect
Returns the intersection of the specified rectangles.
Top
Examples
public static void Intersect() {
  var r1 = new Rect(10, 10, 200, 200);
  Debug.Log(r1.Intersect(new Rect(20, 20, 200, 200)));
  // Prints: (x:20.00, y:20.00, width:190.00, height:190.00)
  Debug.Log(r1.Intersect(new Rect(50, 50, 20, 20)));
  // Prints: (x:20.00, y:20.00, width:20.00, height:20.00)
  Debug.Log(r1.Intersect(new Rect(0, 0, 100, 100)));
  // Prints: (x:10.00, y:10.00, width:90.00, height:90.00)
  Debug.Log(r1.Intersect(new Rect(300, 300, 200, 200)));
  // Prints: (x:110.00, y:110.00, width:0.00, height:0.00)
}
See Also