Table of Contents

Struct Rectangle

Namespace
System.Drawing
Assembly
nanoFramework.Graphics.Core.dll

Stores the location and size of a rectangular region.

public struct Rectangle
Inherited Members

Constructors

Rectangle(Point, Size)

Initializes a new instance of the Rectangle class with the specified location and size.

public Rectangle(Point location, Size size)

Parameters

location Point
size Size

Rectangle(int, int, int, int)

Initializes a new instance of the Rectangle class with the specified location and size.

public Rectangle(int x, int y, int width, int height)

Parameters

x int
y int
width int
height int

Fields

Empty

Creates a new instance of the Rectangle class with member data left uninitialized.

public static readonly Rectangle Empty

Field Value

Rectangle

Properties

Bottom

Gets the y-coordinate of the lower-right corner of the rectangular region defined by this Rectangle.

public readonly int Bottom { get; }

Property Value

int

Height

Gets or sets the width of the rectangular region defined by this Rectangle.

public int Height { readonly get; set; }

Property Value

int

IsEmpty

Tests whether this Rectangle has a Width or a Height of 0.

public readonly bool IsEmpty { get; }

Property Value

bool

Left

Gets the x-coordinate of the upper-left corner of the rectangular region defined by this Rectangle .

public readonly int Left { get; }

Property Value

int

Location

Gets or sets the coordinates of the upper-left corner of the rectangular region represented by this Rectangle.

public Point Location { readonly get; set; }

Property Value

Point

Right

Gets the x-coordinate of the lower-right corner of the rectangular region defined by this Rectangle.

public readonly int Right { get; }

Property Value

int

Size

Gets or sets the size of this Rectangle.

public Size Size { readonly get; set; }

Property Value

Size

Top

Gets the y-coordinate of the upper-left corner of the rectangular region defined by this Rectangle.

public readonly int Top { get; }

Property Value

int

Width

Gets or sets the width of the rectangular region defined by this Rectangle.

public int Width { readonly get; set; }

Property Value

int

X

Gets or sets the x-coordinate of the upper-left corner of the rectangular region defined by this Rectangle.

public int X { readonly get; set; }

Property Value

int

Y

Gets or sets the y-coordinate of the upper-left corner of the rectangular region defined by this Rectangle.

public int Y { readonly get; set; }

Property Value

int

Methods

Contains(Point)

Determines if the specified point is contained within the rectangular region defined by this Rectangle .

public readonly bool Contains(Point pt)

Parameters

pt Point

Returns

bool

Contains(Rectangle)

Determines if the rectangular region represented by rect is entirely contained within the rectangular region represented by this Rectangle .

public readonly bool Contains(Rectangle rect)

Parameters

rect Rectangle

Returns

bool

Contains(int, int)

Determines if the specified point is contained within the rectangular region defined by this Rectangle .

public readonly bool Contains(int x, int y)

Parameters

x int
y int

Returns

bool

Equals(Rectangle)

Tests whether other has the same location and size of this Rectangle.

public readonly bool Equals(Rectangle other)

Parameters

other Rectangle

Returns

bool

Equals(object?)

Tests whether other is a Rectangle with the same location and size of this Rectangle.

public override readonly bool Equals(object? other)

Parameters

other object

Returns

bool

FromLTRB(int, int, int, int)

Creates a new Rectangle with the specified location and size.

public static Rectangle FromLTRB(int left, int top, int right, int bottom)

Parameters

left int
top int
right int
bottom int

Returns

Rectangle

GetHashCode()

Serves as the default hash function.

public override readonly int GetHashCode()

Returns

int

A hash code for the current object.

Inflate(Rectangle, int, int)

Creates a Rectangle that is inflated by the specified amount.

public static Rectangle Inflate(Rectangle rect, int x, int y)

Parameters

rect Rectangle
x int
y int

Returns

Rectangle

Inflate(Size)

Inflates this Rectangle by the specified amount.

public void Inflate(Size size)

Parameters

size Size

Inflate(int, int)

Inflates this Rectangle by the specified amount.

public void Inflate(int width, int height)

Parameters

width int
height int

Intersect(Rectangle)

Creates a Rectangle that represents the intersection between this Rectangle and rect.

public void Intersect(Rectangle rect)

Parameters

rect Rectangle

Intersect(Rectangle, Rectangle)

Creates a rectangle that represents the intersection between a and b. If there is no intersection, an empty rectangle is returned.

public static Rectangle Intersect(Rectangle a, Rectangle b)

Parameters

a Rectangle
b Rectangle

Returns

Rectangle

IntersectsWith(Rectangle)

Determines if this rectangle intersects with rect.

public readonly bool IntersectsWith(Rectangle rect)

Parameters

rect Rectangle

Returns

bool

Offset(Point)

Adjusts the location of this rectangle by the specified amount.

public void Offset(Point pos)

Parameters

pos Point

Offset(int, int)

Adjusts the location of this rectangle by the specified amount.

public void Offset(int x, int y)

Parameters

x int
y int

ToString()

Converts the attributes of this Rectangle to a human readable string.

public override readonly string ToString()

Returns

string

Union(Rectangle, Rectangle)

Creates a rectangle that represents the union between a and b.

public static Rectangle Union(Rectangle a, Rectangle b)

Parameters

a Rectangle
b Rectangle

Returns

Rectangle

Operators

operator ==(Rectangle, Rectangle)

Tests whether two Rectangle objects have equal location and size.

public static bool operator ==(Rectangle left, Rectangle right)

Parameters

left Rectangle
right Rectangle

Returns

bool

operator !=(Rectangle, Rectangle)

Tests whether two Rectangle objects differ in location or size.

public static bool operator !=(Rectangle left, Rectangle right)

Parameters

left Rectangle
right Rectangle

Returns

bool