Show / Hide Table of Contents

Struct Rectangle

Represents a rectangle defined by it's position and it's size.

Implements
IEquatable<Rectangle>
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: RGB.NET.Core
Assembly: RGB.NET.Core.dll
Syntax
public readonly struct Rectangle : IEquatable<Rectangle>

Constructors

| Edit this page View Source

Rectangle(Point, Size)

Initializes a new instance of the Rectangle class using the specified Point and Size.

Declaration
public Rectangle(Point location, Size size)
Parameters
Type Name Description
Point location

The location of this of this Rectangle.

Size size

The size of of this Rectangle.

| Edit this page View Source

Rectangle(params Point[])

Initializes a new instance of the Rectangle class using the specified array of Point. The Location and Size is calculated to contain all points provided as parameters.

Declaration
public Rectangle(params Point[] points)
Parameters
Type Name Description
Point[] points

The array of Point used to calculate the Location and Size.

| Edit this page View Source

Rectangle(params Rectangle[])

Initializes a new instance of the Rectangle class using the specified array of Rectangle. The Location and Size is calculated to completely contain all rectangles provided as parameters.

Declaration
public Rectangle(params Rectangle[] rectangles)
Parameters
Type Name Description
Rectangle[] rectangles

The array of Rectangle used to calculate the Location and Size.

| Edit this page View Source

Rectangle(Size)

Initializes a new instance of the Rectangle class using the Location(0,0) and the specified Size.

Declaration
public Rectangle(Size size)
Parameters
Type Name Description
Size size

The size of of this Rectangle.

| Edit this page View Source

Rectangle(IEnumerable<Point>)

Initializes a new instance of the Rectangle class using the specified list of Point. The Location and Size is calculated to contain all points provided as parameters.

Declaration
public Rectangle(IEnumerable<Point> points)
Parameters
Type Name Description
IEnumerable<Point> points

The list of Point used to calculate the Location and Size.

| Edit this page View Source

Rectangle(IEnumerable<Rectangle>)

Initializes a new instance of the Rectangle class using the specified list of Rectangle. The Location and Size is calculated to completely contain all rectangles provided as parameters.

Declaration
public Rectangle(IEnumerable<Rectangle> rectangles)
Parameters
Type Name Description
IEnumerable<Rectangle> rectangles

The list of Rectangle used to calculate the Location and Size.

| Edit this page View Source

Rectangle(float, float, float, float)

Initializes a new instance of the Rectangle class using the provided values for Location ans Size.

Declaration
public Rectangle(float x, float y, float width, float height)
Parameters
Type Name Description
float x

The x-value of the RGB.NET.Core.Location of this Rectangle.

float y

The y-value of the RGB.NET.Core.Location-position of this Rectangle.

float width

The width of the Size of this Rectangle.

float height

The height of the Size of this Rectangle.

Properties

| Edit this page View Source

Center

Gets a new Point representing the center-point of the Rectangle.

Declaration
public Point Center { get; }
Property Value
Type Description
Point
| Edit this page View Source

IsEmpty

Gets a bool indicating if both, the width and the height of the rectangle is greater than zero. True if the rectangle has a width or a height of zero; otherwise, false.

Declaration
public bool IsEmpty { get; }
Property Value
Type Description
bool
| Edit this page View Source

Location

Gets the Point representing the top-left corner of the Rectangle.

Declaration
public Point Location { get; }
Property Value
Type Description
Point
| Edit this page View Source

Size

Gets the Size of the Rectangle.

Declaration
public Size Size { get; }
Property Value
Type Description
Size

Methods

| Edit this page View Source

Equals(Rectangle)

Tests whether the specified Rectangle is equivalent to this Rectangle.

Declaration
public bool Equals(Rectangle other)
Parameters
Type Name Description
Rectangle other

The rectangle to test.

Returns
Type Description
bool

true if other is equivalent to this Rectangle; otherwise, false.

| Edit this page View Source

Equals(object?)

Tests whether the specified object is a Rectangle and is equivalent to this Rectangle.

Declaration
public override bool Equals(object? obj)
Parameters
Type Name Description
object obj

The object to test.

Returns
Type Description
bool

true if obj is a Rectangle equivalent to this Rectangle; otherwise, false.

Overrides
ValueType.Equals(object)
| Edit this page View Source

GetHashCode()

Returns a hash code for this Rectangle.

Declaration
public override int GetHashCode()
Returns
Type Description
int

An integer value that specifies the hash code for this Rectangle.

Overrides
ValueType.GetHashCode()
| Edit this page View Source

ToString()

Converts the Location- and Size-position of this Rectangle to a human-readable string.

Declaration
public override string ToString()
Returns
Type Description
string

A string that contains the Location and Size of this Rectangle. For example "[Location: [X: 100, Y: 10], Size: [Width: 20, Height: [40]]".

Overrides
ValueType.ToString()

Operators

| Edit this page View Source

operator /(in Rectangle, in Rectangle)

Returns a Rectangle normalized to the specified reference.

Declaration
public static Rectangle operator /(in Rectangle rectangle1, in Rectangle rectangle2)
Parameters
Type Name Description
Rectangle rectangle1

The rectangle to nromalize.

Rectangle rectangle2

The reference used for normalization.

Returns
Type Description
Rectangle

A normalized rectangle.

| Edit this page View Source

operator ==(in Rectangle, in Rectangle)

Returns a value that indicates whether two specified Rectangle are equal.

Declaration
public static bool operator ==(in Rectangle rectangle1, in Rectangle rectangle2)
Parameters
Type Name Description
Rectangle rectangle1

The first Rectangle to compare.

Rectangle rectangle2

The second Rectangle to compare.

Returns
Type Description
bool

true if rectangle1 and rectangle2 are equal; otherwise, false.

| Edit this page View Source

operator !=(in Rectangle, in Rectangle)

Returns a value that indicates whether two specified Rectangle are equal.

Declaration
public static bool operator !=(in Rectangle rectangle1, in Rectangle rectangle2)
Parameters
Type Name Description
Rectangle rectangle1

The first Rectangle to compare.

Rectangle rectangle2

The second Rectangle to compare.

Returns
Type Description
bool

true if rectangle1 and rectangle2 are not equal; otherwise, false.

Implements

IEquatable<T>

Extension Methods

RectangleExtensions.CalculateIntersectPercentage(in Rectangle, in Rectangle)
RectangleExtensions.CalculateIntersection(in Rectangle, in Rectangle)
RectangleExtensions.Contains(in Rectangle, in Point)
RectangleExtensions.Contains(in Rectangle, in Rectangle)
RectangleExtensions.Contains(in Rectangle, float, float)
RectangleExtensions.Rotate(in Rectangle, in Rotation, in Point)
RectangleExtensions.SetHeight(in Rectangle, float)
RectangleExtensions.SetLocation(in Rectangle, in Point)
RectangleExtensions.SetSize(in Rectangle, in Size)
RectangleExtensions.SetWidth(in Rectangle, float)
RectangleExtensions.SetX(in Rectangle, float)
RectangleExtensions.SetY(in Rectangle, float)
RectangleExtensions.Translate(in Rectangle, in Point)
RectangleExtensions.Translate(in Rectangle, float, float)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX