Struct Rectangle
Namespace: Aspose.Imaging
Assembly: Aspose.Imaging.dll (25.2.0)
Stores a set of four integers that represent the location and size of a rectangle.
public struct Rectangle
Inherited Members
object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors
Rectangle(int, int, int, int)
Initializes a new instance of the Aspose.Imaging.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.
Rectangle(Point, Size)
Initializes a new instance of the Aspose.Imaging.Rectangle structure with the specified location and size.
public Rectangle(Point location, Size size)
Parameters
location
Point
A Aspose.Imaging.Point that represents the upper-left corner of the rectangular region.
size
Size
A Aspose.Imaging.Size that represents the width and height of the rectangular region.
Properties
Bottom
Gets or sets the y-coordinate that is the sum of the Aspose.Imaging.Rectangle.Y and Aspose.Imaging.Rectangle.Height property values of this Aspose.Imaging.Rectangle structure.
public int Bottom { get; set; }
Property Value
Empty
Gets a new instance of the Aspose.Imaging.Rectangle structure that has Aspose.Imaging.Rectangle.X, Aspose.Imaging.Rectangle.Y, Aspose.Imaging.Rectangle.Width and Aspose.Imaging.Rectangle.Height values set to zero.
public static Rectangle Empty { get; }
Property Value
Height
Gets or sets the height of this Aspose.Imaging.Rectangle structure.
public int Height { get; set; }
Property Value
IsEmpty
Gets a value indicating whether all numeric properties of this Aspose.Imaging.Rectangle have values of zero.
[JsonIgnore]
public bool IsEmpty { get; }
Property Value
Left
Gets or sets the x-coordinate of the left edge of this Aspose.Imaging.Rectangle structure.
public int Left { get; set; }
Property Value
Location
Gets or sets the coordinates of the upper-left corner of this Aspose.Imaging.Rectangle structure.
public Point Location { get; set; }
Property Value
Right
Gets or sets the x-coordinate that is the sum of Aspose.Imaging.Rectangle.X and Aspose.Imaging.Rectangle.Width property values of this Aspose.Imaging.Rectangle structure.
public int Right { get; set; }
Property Value
Size
Gets or sets the size of this Aspose.Imaging.Rectangle.
public Size Size { get; set; }
Property Value
Top
Gets or sets the y-coordinate of the top edge of this Aspose.Imaging.Rectangle structure.
public int Top { get; set; }
Property Value
Width
Gets or sets the width of this Aspose.Imaging.Rectangle structure.
public int Width { get; set; }
Property Value
X
Gets or sets the x-coordinate of the upper-left corner of this Aspose.Imaging.Rectangle structure.
public int X { get; set; }
Property Value
Y
Gets or sets the y-coordinate of the upper-left corner of this Aspose.Imaging.Rectangle structure.
public int Y { get; set; }
Property Value
Methods
Ceiling(RectangleF)
Converts the specified Aspose.Imaging.RectangleF structure to a Aspose.Imaging.Rectangle structure by rounding the Aspose.Imaging.RectangleF values to the next higher integer values.
public static Rectangle Ceiling(RectangleF value)
Parameters
value
RectangleF
The Aspose.Imaging.RectangleF structure to be converted.
Returns
Returns a Aspose.Imaging.Rectangle.
Contains(int, int)
Determines if the specified point is contained within this Aspose.Imaging.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
This method returns true if the point defined by x
and y
is contained within this Aspose.Imaging.Rectangle structure; otherwise false.
Contains(Point)
Determines if the specified point is contained within this Aspose.Imaging.Rectangle structure.
public bool Contains(Point point)
Parameters
point
Point
The Aspose.Imaging.Point to test.
Returns
This method returns true if the point represented by point
is contained within this Aspose.Imaging.Rectangle structure; otherwise false.
Contains(Rectangle)
Determines if the rectangular region represented by rect
is entirely contained within this Aspose.Imaging.Rectangle structure.
public bool Contains(Rectangle rect)
Parameters
rect
Rectangle
The Aspose.Imaging.Rectangle to test.
Returns
This method returns true if the rectangular region represented by rect
is entirely contained within this Aspose.Imaging.Rectangle structure; otherwise false.
Equals(object)
Tests whether obj
is a Aspose.Imaging.Rectangle structure with the same location and size of this Aspose.Imaging.Rectangle structure.
public override bool Equals(object obj)
Parameters
obj
object
The System.Object to test.
Returns
This method returns true if obj
is a Aspose.Imaging.Rectangle structure and its Aspose.Imaging.Rectangle.X, Aspose.Imaging.Rectangle.Y, Aspose.Imaging.Rectangle.Width, and Aspose.Imaging.Rectangle.Height properties are equal to the corresponding properties of this Aspose.Imaging.Rectangle structure; otherwise, false.
FromLeftTopRightBottom(int, int, int, int)
Creates a Aspose.Imaging.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 Aspose.Imaging.Rectangle structure.
top
int
The y-coordinate of the upper-left corner of this Aspose.Imaging.Rectangle structure.
right
int
The x-coordinate of the lower-right corner of this Aspose.Imaging.Rectangle structure.
bottom
int
The y-coordinate of the lower-right corner of this Aspose.Imaging.Rectangle structure.
Returns
The new Aspose.Imaging.Rectangle that this method creates.
FromPoints(Point, Point)
Creates a new Aspose.Imaging.Rectangle from two points specified. Two verticales of the created Aspose.Imaging.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 Aspose.Imaging.Point for the new rectangle.
point2
Point
The second Aspose.Imaging.Point for the new rectangle.
Returns
A newly created Aspose.Imaging.Rectangle.
GetHashCode()
Returns the hash code for this Aspose.Imaging.Rectangle structure.
public override int GetHashCode()
Returns
An integer that represents the hash code for this rectangle.
Inflate(Rectangle, int, int)
Creates and returns an inflated copy of the specified Aspose.Imaging.Rectangle structure. The copy is inflated by the specified amount. The original Aspose.Imaging.Rectangle structure remains unmodified.
public static Rectangle Inflate(Rectangle rect, int x, int y)
Parameters
rect
Rectangle
The Aspose.Imaging.Rectangle with which to start. This rectangle is not modified.
x
int
The amount to inflate this Aspose.Imaging.Rectangle horizontally.
y
int
The amount to inflate this Aspose.Imaging.Rectangle vertically.
Returns
The inflated Aspose.Imaging.Rectangle.
Inflate(int, int)
Inflates this Aspose.Imaging.Rectangle by the specified amount.
public void Inflate(int width, int height)
Parameters
width
int
The amount to inflate this Aspose.Imaging.Rectangle horizontally.
height
int
The amount to inflate this Aspose.Imaging.Rectangle vertically.
Inflate(Size)
Inflates this Aspose.Imaging.Rectangle by the specified amount.
public void Inflate(Size size)
Parameters
size
Size
The amount to inflate this rectangle.
Intersect(Rectangle, Rectangle)
Returns a third Aspose.Imaging.Rectangle structure that represents the intersection of two other Aspose.Imaging.Rectangle structures. If there is no intersection, an empty Aspose.Imaging.Rectangle is returned.
public static Rectangle Intersect(Rectangle a, Rectangle b)
Parameters
A first rectangle to intersect.
A second rectangle to intersect.
Returns
A Aspose.Imaging.Rectangle that represents the intersection of a
and b
.
Intersect(Rectangle)
Replaces this Aspose.Imaging.Rectangle with the intersection of itself and the specified Aspose.Imaging.Rectangle.
public void Intersect(Rectangle rect)
Parameters
rect
Rectangle
The Aspose.Imaging.Rectangle with which to intersect.
IntersectsWith(Rectangle)
Determines if this rectangle intersects with rect
.
public bool IntersectsWith(Rectangle rect)
Parameters
rect
Rectangle
The rectangle to test.
Returns
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 Aspose.Imaging.RectangleF to a Aspose.Imaging.Rectangle by rounding the Aspose.Imaging.RectangleF values to the nearest integer values.
public static Rectangle Round(RectangleF value)
Parameters
value
RectangleF
The Aspose.Imaging.RectangleF to be converted.
Returns
A new Aspose.Imaging.Rectangle.
ToString()
Converts the attributes of this Aspose.Imaging.Rectangle to a human-readable string.
public override string ToString()
Returns
A string that contains the position, width, and height of this Aspose.Imaging.Rectangle structure.
Truncate(RectangleF)
Converts the specified Aspose.Imaging.RectangleF to a Aspose.Imaging.Rectangle by truncating the Aspose.Imaging.RectangleF values.
public static Rectangle Truncate(RectangleF value)
Parameters
value
RectangleF
The Aspose.Imaging.RectangleF to be converted.
Returns
A new Aspose.Imaging.Rectangle.
Union(Rectangle, Rectangle)
Gets a Aspose.Imaging.Rectangle structure that contains the union of two Aspose.Imaging.Rectangle structures.
public static Rectangle Union(Rectangle a, Rectangle b)
Parameters
A first rectangle to union.
A second rectangle to union.
Returns
A Aspose.Imaging.Rectangle structure that bounds the union of the two Aspose.Imaging.Rectangle structures.
Operators
operator ==(Rectangle, Rectangle)
Tests whether two Aspose.Imaging.Rectangle structures have equal location and size.
public static bool operator ==(Rectangle left, Rectangle right)
Parameters
left
Rectangle
The Aspose.Imaging.Rectangle structure that is to the left of the equality operator.
right
Rectangle
The Aspose.Imaging.Rectangle structure that is to the right of the equality operator.
Returns
This operator returns true if the two Aspose.Imaging.Rectangle structures have equal Aspose.Imaging.Rectangle.X, Aspose.Imaging.Rectangle.Y, Aspose.Imaging.Rectangle.Width, and Aspose.Imaging.Rectangle.Height properties.
operator !=(Rectangle, Rectangle)
Tests whether two Aspose.Imaging.Rectangle structures differ in location or size.
public static bool operator !=(Rectangle left, Rectangle right)
Parameters
left
Rectangle
The Aspose.Imaging.Rectangle structure that is to the left of the inequality operator.
right
Rectangle
The Aspose.Imaging.Rectangle structure that is to the right of the inequality operator.
Returns
This operator returns true if any of the Aspose.Imaging.Rectangle.X, Aspose.Imaging.Rectangle.Y, Aspose.Imaging.Rectangle.Width or Aspose.Imaging.Rectangle.Height properties of the two Aspose.Imaging.Rectangle structures are unequal; otherwise false.