IRect#
IRect is a rectangular bounding box, very similar to Rect, except that all corner coordinates are integers. IRect is used to specify an area of pixels, e.g. to receive image data during rendering. Otherwise, e.g. considerations concerning emptiness and validity of rectangles also apply to this class. Methods and attributes have the same names, and in many cases are implemented by re-using the respective Rect counterparts.
Attribute / Method |
Short Description |
|---|---|
Checks containment of another object |
|
Calculate rectangle area |
|
Common part with another rectangle |
|
Checks for non-empty intersection |
|
Transform with a point and a matrix |
|
Matrix that transforms to another rectangle |
|
The Euclidean norm |
|
Makes a rectangle finite |
|
Bottom left point, synonym bl |
|
Bottom right point, synonym br |
|
Height of the rectangle |
|
Whether rectangle is empty |
|
Whether rectangle is infinite |
|
The Rect equivalent |
|
Top left point, synonym tl |
|
Top right point, synonym tr |
|
Quad made from rectangle corners |
|
Width of the rectangle |
|
X coordinate of the top left corner |
|
X coordinate of the bottom right corner |
|
Y coordinate of the top left corner |
|
Y coordinate of the bottom right corner |
Class API
- class IRect#
- IRect()#
- IRect(float x0, float y0, float x1, float y1)#
- IRect(IRect irect)#
Overloaded constructors. Also see examples below and those for the Rect class.
If another irect is specified, a new copy will be made.
If sequence is specified, it must be a sequence type of 4 numbers (see SequenceTypes). Non-integer numbers will be truncated, non-numeric values will raise an exception.
The other parameters mean integer coordinates.
- GetArea([unit])#
Calculates the area of the rectangle and, with no parameter, equals
abs(IRect). Like an empty rectangle, the area of an infinite rectangle is also zero.- Parameters:
unit (string) – Specify required unit: respective squares of “px” (pixels, default), “in” (inches), “cm” (centimeters), or “mm” (millimeters).
- Return type:
float
- Intersect(ir)#
The intersection (common rectangular area) of the current rectangle and ir is calculated and replaces the current rectangle. If either rectangle is empty, the result is also empty. If either rectangle is infinite, the other one is taken as the result – and hence also infinite if both rectangles were infinite.
- Parameters:
ir (Rect) – Second rectangle.
- Contains(x)#
Checks whether x is contained in the rectangle. It may be
Rect,Pointor a number. If x is an empty rectangle, this is always true. Conversely, if the rectangle is empty this is alwaysfalse, if x is not an empty rectangle and not a number. If x is a number, it will be checked to be one of the four components. x in irect andirect.contains(x)are equivalent.
- Intersects(Rect r)#
Checks whether the rectangle and the
Rect“r” contain a common non-empty IRect. This will always befalseif either is infinite or empty.- Parameters:
r (Rect) – the rectangle to check.
- Return type:
bool
- ToRect(rect)#
Compute the matrix which transforms this rectangle to a given one. See
MuPDFRect.ToRect().
- Morph(Point p, Matrix m)#
Return a new quad after applying a matrix to it using a fixed point.
- Norm()#
Return the Euclidean norm of the rectangle treated as a vector of four numbers.
- Normalize()#
Make the rectangle finite. This is done by shuffling rectangle corners. After this, the bottom right corner will indeed be south-eastern to the top left one. See Rect for a more details.
- Width#
Contains the width of the bounding box. Equals
abs(x1 - x0).- Type:
int
- Height#
Contains the height of the bounding box. Equals
abs(y1 - y0).- Type:
int
- X0#
X-coordinate of the left corners.
- Type:
int
- Y0#
Y-coordinate of the top corners.
- Type:
int
- X1#
X-coordinate of the right corners.
- Type:
int
- Y1#
Y-coordinate of the bottom corners.
- Type:
int
- IsInfinite#
true if rectangle is infinite,
falseotherwise.- Type:
bool
- IsEmpty#
true if rectangle is empty,
falseotherwise.- Type:
bool
