new Rect()
Rect is a struct used to manipulate PDF rectangle objects
Methods
-
<static> init(x1, y1, x2, y2)
-
Create a Rect and initialize it using specified parameters.
Parameters:
Name Type Description x1number The left-most position of the rect.
y1number The bottom-most position of the rect.
x2number The right-most position of the rect.
y2number The top-most position of the rect.
Returns:
A promise that resolves to a Rect (rectangle) object The rect is not attached to any Cos/SDF object.
- Type
- PDFNet.rect
-
assign(right)
-
Copy Constructor
Parameters:
Name Type Description rightPDFNet.Rect -
attach(obj)
-
attach the Cos/SDF object to the Rect.
Parameters:
Name Type Description objPDFNet.Obj underlying Cos/SDF object. Must be an SDF::Array with four SDF::Number elements.
-
contains(x, y)
-
Determines if the specified point is contained within the rectangular region defined by this Rectangle
Parameters:
Name Type Description xnumber horizontal x value of the point to check
ynumber vertical y value of the point to check
Returns:
A promise that resolves to true is the point is in the rectangle, false otherwise.
- Type
- boolean
-
get()
-
Get the coordinates of the rectangle
-
height()
-
Returns:
A promise that resolves to rectangle's height
- Type
- number
-
inflate1(amount)
-
Expands the rectangle by the specified size, in all directions.
Parameters:
Name Type Description amountnumber Specifies the amount to increase the rectangle in all directions.
-
inflate2(x, y)
-
Expands the rectangle by the specified size, in all directions.
Parameters:
Name Type Description xnumber Specifies the amount to increase the rectangle's Left (x1) and Right (x2) properties.
ynumber Specifies the amount to increase the rectangle's Top (y1) and Bottom (y2) properties.
-
intersectRect(rect1, rect2)
-
Makes a Rect equal to the intersection of two existing rectangles.
Parameters:
Name Type Description rect1PDFNet.rect A Rect object that contains a source rectangle.
rect2PDFNet.rect A Rect object that contains a source rectangle.
Returns:
A promise that resolves to true if the intersection is not empty; 0 if the intersection is empty.
- Type
- boolean
-
normalize()
-
Arrange the points in the rectangle so that the first point is the lower-left corner and the second point is the upper-right corner of the rectangle.
-
set(x1, y1, x2, y2)
-
Set the coordinates of the rectangle
Parameters:
Name Type Description x1number The left-most position of the rect.
y1number The bottom-most position of the rect.
x2number The right-most position of the rect.
y2number The top-most position of the rect. The rect is not attached to any Cos/SDF object.
-
update(obj)
-
Saves changes made to the Rect object in the attached (or specified) SDF/Cos rectangle.
Parameters:
Name Type Description objPDFNet.Obj an optional parameter indicating a SDF array that should be updated and attached to this Rect. If parameter rect is NULL or is omitted, update is performed on previously attached Cos/SDF rectangle.
Returns:
A promise that resolves to true if the attached Cos/SDF rectangle array was successfully updated, false otherwise.
- Type
- boolean
-
width()
-
Returns:
A promise that resolves to rectangle's width
- Type
- number