Class RectangleExtensions
Offers some extensions and helper-methods for the work with rectangles.
Inherited Members
Namespace: RGB.NET.Core
Assembly: RGB.NET.Core.dll
Syntax
public static class RectangleExtensions
Methods
| Edit this page View SourceCalculateIntersectPercentage(in Rectangle, in Rectangle)
Calculates the percentage of intersection of a rectangle.
Declaration
public static float CalculateIntersectPercentage(this in Rectangle rect, in Rectangle intersectingRect)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The rectangle to calculate the intersection for. |
Rectangle | intersectingRect | The intersecting rectangle. |
Returns
Type | Description |
---|---|
float | The percentage of intersection. |
CalculateIntersection(in Rectangle, in Rectangle)
Calculates the Rectangle representing the intersection of this Rectangle and the one provided as parameter.
Declaration
public static Rectangle CalculateIntersection(this in Rectangle rect, in Rectangle intersectingRectangle)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The rectangle to calculate the intersection for. |
Rectangle | intersectingRectangle | The intersecting Rectangle. |
Returns
Type | Description |
---|---|
Rectangle | A new Rectangle representing the intersection this Rectangle and the one provided as parameter. |
Contains(in Rectangle, in Point)
Declaration
public static bool Contains(this in Rectangle rect, in Point point)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The containing rectangle. |
Point | point | The Point to test. |
Returns
Type | Description |
---|---|
bool |
|
Contains(in Rectangle, in Rectangle)
Declaration
public static bool Contains(this in Rectangle rect, in Rectangle rect2)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The containing rectangle. |
Rectangle | rect2 | The Rectangle to test. |
Returns
Type | Description |
---|---|
bool |
|
Contains(in Rectangle, float, float)
Determines if the specified location is contained within this Rectangle.
Declaration
public static bool Contains(this in Rectangle rect, float x, float y)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The containing rectangle. |
float | x | The X-location to test. |
float | y | The Y-location to test. |
Returns
Type | Description |
---|---|
bool |
|
Rotate(in Rectangle, in Rotation, in Point)
Rotates the specified Rectangle by the specified amuont around the specified origin.
Declaration
public static Point[] Rotate(this in Rectangle rect, in Rotation rotation, in Point origin = default)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The Rectangle to rotate. |
Rotation | rotation | The rotation. |
Point | origin | The origin to rotate around. [0,0] if not set. |
Returns
Type | Description |
---|---|
Point[] | A array of Point containing the new locations of the corners of the original rectangle. |
Remarks
The returned array of Point is filled with the new locations of the rectangle clockwise starting from the top left: [0] = top left [1] = top right [2] = bottom right [3] = bottom left
SetHeight(in Rectangle, float)
Declaration
public static Rectangle SetHeight(this in Rectangle rect, float height)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The rectangle to modify. |
float | height | The new height of the rectangle. |
Returns
Type | Description |
---|---|
Rectangle | The modified Rectangle. |
SetLocation(in Rectangle, in Point)
Sets the Location of the specified rectangle.
Declaration
public static Rectangle SetLocation(this in Rectangle rect, in Point location)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The rectangle to modify. |
Point | location | The new location of the rectangle. |
Returns
Type | Description |
---|---|
Rectangle | The modified Rectangle. |
SetSize(in Rectangle, in Size)
Sets the Size of the specified rectangle.
Declaration
public static Rectangle SetSize(this in Rectangle rect, in Size size)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The rectangle to modify. |
Size | size | The new size of the rectangle. |
Returns
Type | Description |
---|---|
Rectangle | The modified Rectangle. |
SetWidth(in Rectangle, float)
Declaration
public static Rectangle SetWidth(this in Rectangle rect, float width)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The rectangle to modify. |
float | width | The new width of the rectangle. |
Returns
Type | Description |
---|---|
Rectangle | The modified Rectangle. |
SetX(in Rectangle, float)
Declaration
public static Rectangle SetX(this in Rectangle rect, float x)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The rectangle to modify. |
float | x | The new x-location of the rectangle. |
Returns
Type | Description |
---|---|
Rectangle | The modified Rectangle. |
SetY(in Rectangle, float)
Declaration
public static Rectangle SetY(this in Rectangle rect, float y)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The rectangle to modify. |
float | y | The new y-location of the rectangle. |
Returns
Type | Description |
---|---|
Rectangle | The modified Rectangle. |
Translate(in Rectangle, in Point)
Moves the specified Rectangle by the specified amount.
Declaration
public static Rectangle Translate(this in Rectangle rect, in Point point)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The Rectangle to move. |
Point | point | The amount to move. |
Returns
Type | Description |
---|---|
Rectangle | The moved rectangle. |
Translate(in Rectangle, float, float)
Moves the specified Rectangle by the specified amount.
Declaration
public static Rectangle Translate(this in Rectangle rect, float x = 0, float y = 0)
Parameters
Type | Name | Description |
---|---|---|
Rectangle | rect | The Rectangle to move. |
float | x | The x-ammount to move. |
float | y | The y-ammount to move. |
Returns
Type | Description |
---|---|
Rectangle | The moved rectangle. |