Rectangle Class

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

Module: aspose.imaging

Full Name: aspose.imaging.Rectangle

Constructors

NameDescription
Rectangle()Initializes a new instance of the Rectangle class
Rectangle(location, size)Initializes a new instance of the Rectangle structure with the specified location and size.
Rectangle(x, y, width, height)Initializes a new instance of the Rectangle structure with the specified location and size.

Properties

NameTypeAccessDescription
bottomintr/wGets or sets the y-coordinate that is the sum of the Rectangle.y and Rectangle.height property values of this Rectangle structure.
empty [static]RectanglerGets a new instance of the Rectangle structure that has Rectangle.x, Rectangle.y, Rectangle.width and Rectangle.height values set to zero.
heightintr/wGets or sets the height of this Rectangle structure.
is_emptyboolrGets a value indicating whether all numeric properties of this Rectangle have values of zero.
leftintr/wGets or sets the x-coordinate of the left edge of this Rectangle structure.
locationPointr/wGets or sets the coordinates of the upper-left corner of this Rectangle structure.
rightintr/wGets or sets the x-coordinate that is the sum of Rectangle.x and Rectangle.width property values of this Rectangle structure.
sizeSizer/wGets or sets the size of this Rectangle.
topintr/wGets or sets the y-coordinate of the top edge of this Rectangle structure.
widthintr/wGets or sets the width of this Rectangle structure.
xintr/wGets or sets the x-coordinate of the upper-left corner of this Rectangle structure.
yintr/wGets or sets the y-coordinate of the upper-left corner of this Rectangle structure.

Methods

NameDescription
ceiling(value)Converts the specified RectangleF structure to a Rectangle structure by rounding the RectangleF values to the next higher integer values.
contains(point)Determines if the specified point is contained within this Rectangle structure.
contains(rect)Determines if the rectangular region represented by rect is entirely contained within this Rectangle structure.
contains(x, y)Determines if the specified point is contained within this Rectangle structure.
contains_point(point)Determines if the specified point is contained within this Rectangle structure.
contains_rect(rect)Determines if the rectangular region represented by rect is entirely contained within this Rectangle structure.
from_left_top_right_bottom(left, top, right, bottom)Creates a Rectangle structure with the specified edge locations.
from_points(point1, point2)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.
inflate(rect, x, y)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.
inflate(size)Inflates this Rectangle by the specified amount.
inflate(width, height)Inflates this Rectangle by the specified amount.
inflate_rect(rect, x, y)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.
intersect(a, b)Returns a third Rectangle structure that represents the intersection of two other Rectangle structures. If there is no intersection, an empty Rectangle is returned.
intersect(rect)Replaces this Rectangle with the intersection of itself and the specified Rectangle.
intersect_rects(a, b)Returns a third Rectangle structure that represents the intersection of two other Rectangle structures. If there is no intersection, an empty Rectangle is returned.
intersects_with(rect)Determines if this rectangle intersects with rect.
normalize()Normalizes the rectangle by making it’s width and height positive, left less than right and top less than bottom.
offset(pos)Adjusts the location of this rectangle by the specified amount.
offset(x, y)Adjusts the location of this rectangle by the specified amount.
round(value)Converts the specified RectangleF to a Rectangle by rounding the RectangleF values to the nearest integer values.
truncate(value)Converts the specified RectangleF to a Rectangle by truncating the RectangleF values.
union(a, b)Gets a Rectangle structure that contains the union of two Rectangle structures.

Constructor: Rectangle()

 Rectangle() 

Initializes a new instance of the Rectangle class

Constructor: Rectangle(location, size)

 Rectangle(location, size) 

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

Parameters:

ParameterTypeDescription
locationPointA Point that represents the upper-left corner of the rectangular region.
sizeSizeA Size that represents the width and height of the rectangular region.

Constructor: Rectangle(x, y, width, height)

 Rectangle(x, y, width, height) 

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

Parameters:

ParameterTypeDescription
xintThe x-coordinate of the upper-left corner of the rectangle.
yintThe y-coordinate of the upper-left corner of the rectangle.
widthintThe width of the rectangle.
heightintThe height of the rectangle.

Method: ceiling(value) [static]

 ceiling(value) 

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

Parameters:

ParameterTypeDescription
valueRectangleFThe RectangleF structure to be converted.

Returns

TypeDescription
RectangleReturns a Rectangle.

Method: contains(point)

 contains(point) 

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

Parameters:

ParameterTypeDescription
pointPointThe Point to test.

Returns

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

Method: contains(rect)

 contains(rect) 

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

Parameters:

ParameterTypeDescription
rectRectangleThe Rectangle to test.

Returns

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

Method: contains(x, y)

 contains(x, y) 

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

Parameters:

ParameterTypeDescription
xintThe x-coordinate of the point to test.
yintThe y-coordinate of the point to test.

Returns

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

Method: contains_point(point)

 contains_point(point) 

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

Parameters:

ParameterTypeDescription
pointPointThe Point to test.

Returns

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

Method: contains_rect(rect)

 contains_rect(rect) 

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

Parameters:

ParameterTypeDescription
rectRectangleThe Rectangle to test.

Returns

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

Method: from_left_top_right_bottom(left, top, right, bottom) [static]

 from_left_top_right_bottom(left, top, right, bottom) 

Creates a Rectangle structure with the specified edge locations.

Parameters:

ParameterTypeDescription
leftintThe x-coordinate of the upper-left corner of this Rectangle structure.
topintThe y-coordinate of the upper-left corner of this Rectangle structure.
rightintThe x-coordinate of the lower-right corner of this Rectangle structure.
bottomintThe y-coordinate of the lower-right corner of this Rectangle structure.

Returns

TypeDescription
RectangleThe new Rectangle that this method creates.

Method: from_points(point1, point2) [static]

 from_points(point1, point2) 

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.

Parameters:

ParameterTypeDescription
point1PointThe first Point for the new rectangle.
point2PointThe second Point for the new rectangle.

Returns

TypeDescription
RectangleA newly created Rectangle.

Method: inflate(rect, x, y) [static]

 inflate(rect, x, y) 

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.

Parameters:

ParameterTypeDescription
rectRectangleThe Rectangle with which to start. This rectangle is not modified.
xintThe amount to inflate this Rectangle horizontally.
yintThe amount to inflate this Rectangle vertically.

Returns

TypeDescription
RectangleThe inflated Rectangle.

Method: inflate(size)

 inflate(size) 

Inflates this Rectangle by the specified amount.

Parameters:

ParameterTypeDescription
sizeSizeThe amount to inflate this rectangle.

Method: inflate(width, height)

 inflate(width, height) 

Inflates this Rectangle by the specified amount.

Parameters:

ParameterTypeDescription
widthintThe amount to inflate this Rectangle horizontally.
heightintThe amount to inflate this Rectangle vertically.

Method: inflate_rect(rect, x, y) [static]

 inflate_rect(rect, x, y) 

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.

Parameters:

ParameterTypeDescription
rectRectangleThe Rectangle with which to start. This rectangle is not modified.
xintThe amount to inflate this Rectangle horizontally.
yintThe amount to inflate this Rectangle vertically.

Returns

TypeDescription
RectangleThe inflated Rectangle.

Method: intersect(a, b) [static]

 intersect(a, b) 

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

Parameters:

ParameterTypeDescription
aRectangleA first rectangle to intersect.
bRectangleA second rectangle to intersect.

Returns

TypeDescription
RectangleA Rectangle that represents the intersection of a and b.

Method: intersect(rect)

 intersect(rect) 

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

Parameters:

ParameterTypeDescription
rectRectangleThe Rectangle with which to intersect.

Method: intersect_rects(a, b) [static]

 intersect_rects(a, b) 

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

Parameters:

ParameterTypeDescription
aRectangleA first rectangle to intersect.
bRectangleA second rectangle to intersect.

Returns

TypeDescription
RectangleA Rectangle that represents the intersection of a and b.

Method: intersects_with(rect)

 intersects_with(rect) 

Determines if this rectangle intersects with rect.

Parameters:

ParameterTypeDescription
rectRectangleThe rectangle to test.

Returns

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

Method: offset(pos)

 offset(pos) 

Adjusts the location of this rectangle by the specified amount.

Parameters:

ParameterTypeDescription
posPointAmount to offset the location.

Method: offset(x, y)

 offset(x, y) 

Adjusts the location of this rectangle by the specified amount.

Parameters:

ParameterTypeDescription
xintThe horizontal offset.
yintThe vertical offset.

Method: round(value) [static]

 round(value) 

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

Parameters:

ParameterTypeDescription
valueRectangleFThe RectangleF to be converted.

Returns

TypeDescription
RectangleA new Rectangle.

Method: truncate(value) [static]

 truncate(value) 

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

Parameters:

ParameterTypeDescription
valueRectangleFThe RectangleF to be converted.

Returns

TypeDescription
RectangleA new Rectangle.

Method: union(a, b) [static]

 union(a, b) 

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

Parameters:

ParameterTypeDescription
aRectangleA first rectangle to union.
bRectangleA second rectangle to union.

Returns

TypeDescription
RectangleA Rectangle structure that bounds the union of the two Rectangle structures.