Table of Contents

Struct Rectangle

Namespace
Aspose.Imaging
Assembly
Aspose.Imaging.dll

Stores a set of four integers that represent the location and size of a rectangle.

public struct Rectangle
Inherited Members

Constructors

Rectangle(Point, Size)

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

public Rectangle(Point location, Size size)

Parameters

location Point

A Point that represents the upper-left corner of the rectangular region.

size Size

A Size that represents the width and height of the rectangular region.

Rectangle(int, int, int, int)

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

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

Parameters

x int

The x-coordinate of the upper-left corner of the rectangle.

y int

The y-coordinate of the upper-left corner of the rectangle.

width int

The width of the rectangle.

height int

The height of the rectangle.

Properties

Bottom

Gets or sets the y-coordinate that is the sum of the Y and Height property values of this Rectangle structure.

public int Bottom { get; set; }

Property Value

int

The y-coordinate that is the sum of Y and Height of this Rectangle.

Empty

Gets a new instance of the Rectangle structure that has X, Y, Width and Height values set to zero.

public static Rectangle Empty { get; }

Property Value

Rectangle

Height

Gets or sets the height of this Rectangle structure.

public int Height { get; set; }

Property Value

int

The height of this Rectangle structure.

IsEmpty

Gets a value indicating whether all numeric properties of this Rectangle have values of zero.

public bool IsEmpty { get; }

Property Value

bool

This property returns true if the Width, Height, X, and Y properties of this Rectangle all have values of zero; otherwise, false.

Left

Gets or sets the x-coordinate of the left edge of this Rectangle structure.

public int Left { get; set; }

Property Value

int

The x-coordinate of the left edge of this Rectangle structure.

Location

Gets or sets the coordinates of the upper-left corner of this Rectangle structure.

public Point Location { get; set; }

Property Value

Point

A Point that represents the upper-left corner of this Rectangle structure.

Right

Gets or sets the x-coordinate that is the sum of X and Width property values of this Rectangle structure.

public int Right { get; set; }

Property Value

int

The x-coordinate that is the sum of X and Width of this Rectangle.

Size

Gets or sets the size of this Rectangle.

public Size Size { get; set; }

Property Value

Size

A Size that represents the width and height of this Rectangle structure.

Top

Gets or sets the y-coordinate of the top edge of this Rectangle structure.

public int Top { get; set; }

Property Value

int

The y-coordinate of the top edge of this Rectangle structure.

Width

Gets or sets the width of this Rectangle structure.

public int Width { get; set; }

Property Value

int

The width of this Rectangle structure.

X

Gets or sets the x-coordinate of the upper-left corner of this Rectangle structure.

public int X { get; set; }

Property Value

int

The x-coordinate of the upper-left corner of this Rectangle structure.

Y

Gets or sets the y-coordinate of the upper-left corner of this Rectangle structure.

public int Y { get; set; }

Property Value

int

The y-coordinate of the upper-left corner of this Rectangle structure.

Methods

Ceiling(RectangleF)

Converts the specified RectangleF structure to a Rectangle structure by rounding the RectangleF values to the next higher integer values.

public static Rectangle Ceiling(RectangleF value)

Parameters

value RectangleF

The RectangleF structure to be converted.

Returns

Rectangle

Returns a Rectangle.

Contains(Point)

Determines if the specified point is contained within this Rectangle structure.

public bool Contains(Point point)

Parameters

point Point

The Point to test.

Returns

bool

This method returns true if the point represented by point is contained within this Rectangle structure; otherwise false.

Contains(Rectangle)

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

public bool Contains(Rectangle rect)

Parameters

rect Rectangle

The Rectangle to test.

Returns

bool

This method returns true if the rectangular region represented by rect is entirely contained within this Rectangle structure; otherwise false.

Contains(int, int)

Determines if the specified point is contained within this Rectangle structure.

public bool Contains(int x, int y)

Parameters

x int

The x-coordinate of the point to test.

y int

The y-coordinate of the point to test.

Returns

bool

This method returns true if the point defined by x and y is contained within this Rectangle structure; otherwise false.

Equals(object)

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

public override bool Equals(object obj)

Parameters

obj object

The object to test.

Returns

bool

This method returns true if obj is a Rectangle structure and its X, Y, Width, and Height properties are equal to the corresponding properties of this Rectangle structure; otherwise, false.

FromLeftTopRightBottom(int, int, int, int)

Creates a Rectangle structure with the specified edge locations.

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

Parameters

left int

The x-coordinate of the upper-left corner of this Rectangle structure.

top int

The y-coordinate of the upper-left corner of this Rectangle structure.

right int

The x-coordinate of the lower-right corner of this Rectangle structure.

bottom int

The y-coordinate of the lower-right corner of this Rectangle structure.

Returns

Rectangle

The new Rectangle that this method creates.

FromPoints(Point, Point)

Creates a new Rectangle from two points specified. Two verticales of the created Rectangle will be equal to the passed point1 and point2. These would be typically the opposite vertices.

public static Rectangle FromPoints(Point point1, Point point2)

Parameters

point1 Point

The first Point for the new rectangle.

point2 Point

The second Point for the new rectangle.

Returns

Rectangle

A newly created Rectangle.

GetHashCode()

Returns the hash code for this Rectangle structure.

public override int GetHashCode()

Returns

int

An integer that represents the hash code for this rectangle.

Inflate(Rectangle, int, int)

Creates and returns an inflated copy of the specified Rectangle structure. The copy is inflated by the specified amount. The original Rectangle structure remains unmodified.

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

Parameters

rect Rectangle

The Rectangle with which to start. This rectangle is not modified.

x int

The amount to inflate this Rectangle horizontally.

y int

The amount to inflate this Rectangle vertically.

Returns

Rectangle

The inflated Rectangle.

Inflate(Size)

Inflates this Rectangle by the specified amount.

public void Inflate(Size size)

Parameters

size Size

The amount to inflate this rectangle.

Inflate(int, int)

Inflates this Rectangle by the specified amount.

public void Inflate(int width, int height)

Parameters

width int

The amount to inflate this Rectangle horizontally.

height int

The amount to inflate this Rectangle vertically.

Intersect(Rectangle)

Replaces this Rectangle with the intersection of itself and the specified Rectangle.

public void Intersect(Rectangle rect)

Parameters

rect Rectangle

The Rectangle with which to intersect.

Intersect(Rectangle, Rectangle)

Returns a third Rectangle structure that represents the intersection of two other Rectangle structures. If there is no intersection, an empty Rectangle is returned.

public static Rectangle Intersect(Rectangle a, Rectangle b)

Parameters

a Rectangle

A first rectangle to intersect.

b Rectangle

A second rectangle to intersect.

Returns

Rectangle

A Rectangle that represents the intersection of a and b.

IntersectsWith(Rectangle)

Determines if this rectangle intersects with rect.

public bool IntersectsWith(Rectangle rect)

Parameters

rect Rectangle

The rectangle to test.

Returns

bool

This method returns true if there is any intersection, otherwise false.

Normalize()

Normalizes the rectangle by making it's width and height positive, left less than right and top less than bottom.

public void Normalize()

Offset(Point)

Adjusts the location of this rectangle by the specified amount.

public void Offset(Point pos)

Parameters

pos Point

Amount to offset the location.

Offset(int, int)

Adjusts the location of this rectangle by the specified amount.

public void Offset(int x, int y)

Parameters

x int

The horizontal offset.

y int

The vertical offset.

Round(RectangleF)

Converts the specified RectangleF to a Rectangle by rounding the RectangleF values to the nearest integer values.

public static Rectangle Round(RectangleF value)

Parameters

value RectangleF

The RectangleF to be converted.

Returns

Rectangle

A new Rectangle.

ToString()

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

public override string ToString()

Returns

string

A string that contains the position, width, and height of this Rectangle structure.

Truncate(RectangleF)

Converts the specified RectangleF to a Rectangle by truncating the RectangleF values.

public static Rectangle Truncate(RectangleF value)

Parameters

value RectangleF

The RectangleF to be converted.

Returns

Rectangle

A new Rectangle.

Union(Rectangle, Rectangle)

Gets a Rectangle structure that contains the union of two Rectangle structures.

public static Rectangle Union(Rectangle a, Rectangle b)

Parameters

a Rectangle

A first rectangle to union.

b Rectangle

A second rectangle to union.

Returns

Rectangle

A Rectangle structure that bounds the union of the two Rectangle structures.

Operators

operator ==(Rectangle, Rectangle)

Tests whether two Rectangle structures have equal location and size.

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

Parameters

left Rectangle

The Rectangle structure that is to the left of the equality operator.

right Rectangle

The Rectangle structure that is to the right of the equality operator.

Returns

bool

This operator returns true if the two Rectangle structures have equal X, Y, Width, and Height properties.

operator !=(Rectangle, Rectangle)

Tests whether two Rectangle structures differ in location or size.

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

Parameters

left Rectangle

The Rectangle structure that is to the left of the inequality operator.

right Rectangle

The Rectangle structure that is to the right of the inequality operator.

Returns

bool

This operator returns true if any of the X, Y, Width or Height properties of the two Rectangle structures are unequal; otherwise false.