Show / Hide Table of Contents

Class RectangleExtensions

Offers some extensions and helper-methods for the work with rectangles.

Inheritance
object
RectangleExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: RGB.NET.Core
Assembly: RGB.NET.Core.dll
Syntax
public static class RectangleExtensions

Methods

| Edit this page View Source

CalculateIntersectPercentage(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.

| Edit this page View Source

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.

| Edit this page View Source

Contains(in Rectangle, in Point)

Determines if the specified Point is contained within this Rectangle.

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

true if the rectangle contains the specified point; otherwise false.

| Edit this page View Source

Contains(in Rectangle, in Rectangle)

Determines if the specified Rectangle is contained within this 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

true if the rectangle contains the specified rect; otherwise false.

| Edit this page View Source

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

true if the rectangle contains the specified coordinates; otherwise false.

| Edit this page View Source

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

| Edit this page View Source

SetHeight(in Rectangle, float)

Sets the Height of the Size of the specified rectangle.

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

SetWidth(in Rectangle, float)

Sets the Width of the Size of the specified rectangle.

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.

| Edit this page View Source

SetX(in Rectangle, float)

Sets the X of the Location of the specified rectangle.

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.

| Edit this page View Source

SetY(in Rectangle, float)

Sets the Y of the Location of the specified rectangle.

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX