Class Rectangle
Class that represent rectangle object.
public class Rectangle
- Inheritance
-
Rectangle
- Derived
- Inherited Members
Constructors
Rectangle(float, float)
Creates new instance of rectangle with (0, 0) as the lower left point.
public Rectangle(float width, float height)
Parameters
Rectangle(float, float, float, float)
Creates new instance.
public Rectangle(float x, float y, float width, float height)
Parameters
x
floatthe x coordinate of lower left point
y
floatthe y coordinate of lower left point
width
floatthe width value
height
floatthe height value
Rectangle(Rectangle)
Creates the copy of given Rectangle
public Rectangle(Rectangle rect)
Parameters
Fields
height
protected float height
Field Value
width
protected float width
Field Value
x
protected float x
Field Value
y
protected float y
Field Value
Methods
ApplyMargins(float, float, float, float, bool)
Change the rectangle according the specified margins.
public virtual Rectangle ApplyMargins(float topIndent, float rightIndent, float bottomIndent, float leftIndent, bool reverse)
Parameters
topIndent
floatthe value on which the top y coordinate will change.
rightIndent
floatthe value on which the right x coordinate will change.
bottomIndent
floatthe value on which the bottom y coordinate will change.
leftIndent
floatthe value on which the left x coordinate will change.
reverse
boolif true the rectangle will expand, otherwise it will shrink
Returns
- Rectangle
the rectangle with applied margins
CalculateBBox(IList<Point>)
Calculates the bounding box of passed points.
public static Rectangle CalculateBBox(IList<Point> points)
Parameters
Returns
- Rectangle
the bounding box of passed points.
Clone()
Creates a "deep copy" of this rectangle, meaning the object returned by this method will be independent of the object being cloned.
public virtual Rectangle Clone()
Returns
- Rectangle
the copied rectangle.
Contains(Rectangle)
Check if this rectangle contains the passed rectangle.
public virtual bool Contains(Rectangle rect)
Parameters
rect
Rectanglea rectangle which is to be checked if it is fully contained inside this rectangle.
Returns
- bool
true if this rectangle contains the passed rectangle, false otherwise.
Remarks
Check if this rectangle contains the passed rectangle.
A rectangle will envelop itself, meaning that for any rectangle
rect
the expression
rect.contains(rect)
always returns true.
CreateBoundingRectangleFromQuadPoint(PdfArray)
Create the bounding rectangle for the given array of quadpoints.
public static Rectangle CreateBoundingRectangleFromQuadPoint(PdfArray quadPoints)
Parameters
quadPoints
PdfArrayan array containing 8 numbers that correspond to 4 points.
Returns
- Rectangle
The smallest orthogonal rectangle containing the quadpoints.
CreateBoundingRectanglesFromQuadPoint(PdfArray)
Create a list of bounding rectangles from an 8 x n array of Quadpoints.
public static IList<Rectangle> CreateBoundingRectanglesFromQuadPoint(PdfArray quadPoints)
Parameters
quadPoints
PdfArray8xn array of numbers representing 4 points
Returns
DecreaseHeight(float)
Decreases the height of rectangle by the given value.
public virtual Rectangle DecreaseHeight(float extra)
Parameters
extra
floatthe value of the extra height to be subtracted.
Returns
Remarks
Decreases the height of rectangle by the given value. May be used in chain.
DecreaseWidth(float)
Decreases the width of rectangle by the given value.
public virtual Rectangle DecreaseWidth(float extra)
Parameters
extra
floatthe value of the extra width to be subtracted.
Returns
Remarks
Decreases the width of rectangle by the given value. May be used in chain.
EqualsWithEpsilon(Rectangle)
Compares instance of this rectangle with given deviation equals to 0.0001
public virtual bool EqualsWithEpsilon(Rectangle that)
Parameters
Returns
- bool
true if the difference between corresponding rectangle values is less than deviation and false otherwise.
EqualsWithEpsilon(Rectangle, float)
Compares instance of this rectangle with given deviation.
public virtual bool EqualsWithEpsilon(Rectangle that, float eps)
Parameters
Returns
- bool
true if the difference between corresponding rectangle values is less than deviation and false otherwise.
GetBottom()
Gets the Y coordinate of the lower edge of the rectangle.
public virtual float GetBottom()
Returns
- float
the Y coordinate of the lower edge of the rectangle.
Remarks
Gets the Y coordinate of the lower edge of the rectangle. Same as:
getY()
.
GetCommonRectangle(params Rectangle[])
Calculates the common rectangle which includes all the input rectangles.
public static Rectangle GetCommonRectangle(params Rectangle[] rectangles)
Parameters
rectangles
Rectangle[]list of input rectangles.
Returns
- Rectangle
common rectangle.
GetHeight()
Gets the height of rectangle.
public virtual float GetHeight()
Returns
- float
the height of rectangle.
GetIntersection(Rectangle)
Get the rectangle representation of the intersection between this rectangle and the passed rectangle
public virtual Rectangle GetIntersection(Rectangle rect)
Parameters
rect
Rectanglethe rectangle to find the intersection with
Returns
- Rectangle
the intersection rectangle if the passed rectangles intersects with this rectangle, a rectangle representing a line if the intersection is along an edge or a rectangle representing a point if the intersection is a single point, null otherwise
GetLeft()
Gets the X coordinate of the left edge of the rectangle.
public virtual float GetLeft()
Returns
- float
the X coordinate of the left edge of the rectangle.
Remarks
Gets the X coordinate of the left edge of the rectangle. Same as:
getX()
.
GetRectangleOnRotatedPage(Rectangle, PdfPage)
Gets the rectangle as it looks on the rotated page and returns the rectangle in coordinates relevant to the true page origin.
public static Rectangle GetRectangleOnRotatedPage(Rectangle rect, PdfPage page)
Parameters
rect
Rectanglethe rectangle as it looks on the rotated page.
page
PdfPagethe page on which one want to process the rectangle.
Returns
- Rectangle
the newly created rectangle with translated coordinates.
Remarks
Gets the rectangle as it looks on the rotated page and returns the rectangle in coordinates relevant to the true page origin. This rectangle can be used to add annotations, fields, and other objects to the rotated page.
GetRight()
Gets the X coordinate of the right edge of the rectangle.
public virtual float GetRight()
Returns
- float
the X coordinate of the right edge of the rectangle.
Remarks
Gets the X coordinate of the right edge of the rectangle. Same as:
getX() + getWidth()
.
GetTop()
Gets the Y coordinate of the upper edge of the rectangle.
public virtual float GetTop()
Returns
- float
the Y coordinate of the upper edge of the rectangle.
Remarks
Gets the Y coordinate of the upper edge of the rectangle. Same as:
getY() + getHeight()
.
GetWidth()
Gets the width of rectangle.
public virtual float GetWidth()
Returns
- float
the width of rectangle.
GetX()
Gets the X coordinate of lower left point.
public virtual float GetX()
Returns
- float
the X coordinate of lower left point.
GetY()
Gets the Y coordinate of lower left point.
public virtual float GetY()
Returns
- float
the Y coordinate of lower left point.
IncreaseHeight(float)
Increases the height of rectangle by the given value.
public virtual Rectangle IncreaseHeight(float extra)
Parameters
extra
floatthe value of the extra height to be added.
Returns
Remarks
Increases the height of rectangle by the given value. May be used in chain.
IncreaseWidth(float)
Increases the width of rectangle by the given value.
public virtual Rectangle IncreaseWidth(float extra)
Parameters
extra
floatthe value of the extra wudth to be added.
Returns
Remarks
Increases the width of rectangle by the given value. May be used in chain.
IntersectsLine(float, float, float, float)
Checks if rectangle have common points with line, specified by two points.
public virtual bool IntersectsLine(float x1, float y1, float x2, float y2)
Parameters
x1
floatthe x coordinate of first line's point.
y1
floatthe y coordinate of first line's point.
x2
floatthe x coordinate of second line's point.
y2
floatthe y coordinate of second line's point.
Returns
MoveDown(float)
Decreases the y coordinate.
public virtual Rectangle MoveDown(float move)
Parameters
move
floatthe value on which the position will be changed.
Returns
MoveLeft(float)
Decreases the x coordinate.
public virtual Rectangle MoveLeft(float move)
Parameters
move
floatthe value on which the position will be changed.
Returns
MoveRight(float)
Increases the x coordinate.
public virtual Rectangle MoveRight(float move)
Parameters
move
floatthe value on which the position will be changed.
Returns
MoveUp(float)
Increases the y coordinate.
public virtual Rectangle MoveUp(float move)
Parameters
move
floatthe value on which the position will be changed.
Returns
Overlaps(Rectangle)
Check if this rectangle and the passed rectangle overlap
public virtual bool Overlaps(Rectangle rect)
Parameters
rect
Rectanglea rectangle which is to be checked if it overlaps the passed rectangle
Returns
- bool
true if there is overlap of some kind
Overlaps(Rectangle, float)
Check if this rectangle and the passed rectangle overlap
public virtual bool Overlaps(Rectangle rect, float epsilon)
Parameters
rect
Rectanglea rectangle which is to be checked if it overlaps the passed rectangle
epsilon
floatif greater than zero, then this is the maximum distance that one rectangle can go to another, but they will not overlap, if less than zero, then this is the minimum required distance between the rectangles so that they do not overlap
Returns
- bool
true if there is overlap of some kind
SetBbox(float, float, float, float)
Sets the rectangle by the coordinates, specifying its lower left and upper right points.
public virtual Rectangle SetBbox(float llx, float lly, float urx, float ury)
Parameters
llx
floatthe X coordinate of lower left point
lly
floatthe Y coordinate of lower left point
urx
floatthe X coordinate of upper right point
ury
floatthe Y coordinate of upper right point
Returns
Remarks
Sets the rectangle by the coordinates, specifying its lower left and upper right points. May be used in chain.
Note: this method will normalize coordinates, so the rectangle will have non negative width and height,
and its x and y coordinates specified lower left point.
SetHeight(float)
Sets the height of rectangle.
public virtual Rectangle SetHeight(float height)
Parameters
height
floatthe the width of rectangle to be set.
Returns
Remarks
Sets the height of rectangle. May be used in chain.
SetWidth(float)
Sets the width of rectangle.
public virtual Rectangle SetWidth(float width)
Parameters
width
floatthe the width of rectangle to be set.
Returns
Remarks
Sets the width of rectangle. May be used in chain.
SetX(float)
Sets the X coordinate of lower left point.
public virtual Rectangle SetX(float x)
Parameters
x
floatthe X coordinate of lower left point to be set.
Returns
Remarks
Sets the X coordinate of lower left point. May be used in chain.
SetY(float)
Sets the Y coordinate of lower left point.
public virtual Rectangle SetY(float y)
Parameters
y
floatthe Y coordinate of lower left point to be set.
Returns
Remarks
Sets the Y coordinate of lower left point. May be used in chain.
ToPointsArray()
Convert rectangle to an array of points
public virtual Point[] ToPointsArray()
Returns
- Point[]
array of four extreme points of rectangle
ToString()
Gets the string representation of rectangle.
public override string ToString()
Returns
- string
the string representation of rectangle.