Class: Rect

PDFNet. Rect


new Rect( [x1] [, y1] [, x2] [, y2] [, mp_rect])

Rect is a struct used to manipulate PDF rectangle objects
Parameters:
Name Type Argument Description
x1 number <optional>
y1 number <optional>
x2 number <optional>
y2 number <optional>
mp_rect PDFNet.Obj <optional>
Properties:
Name Type Description
x1 number
y1 number
x2 number
y2 number
mp_rect PDFNet.Obj

Methods


<static> init(x1, y1, x2, y2)

Create a Rect and initialize it using specified parameters.
Parameters:
Name Type Description
x1 number The left-most position of the rect.
y1 number The bottom-most position of the rect.
x2 number The right-most position of the rect.
y2 number 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
Promise.<PDFNet.Rect>

attach(obj)

attach the Cos/SDF object to the Rect.
Parameters:
Name Type Description
obj PDFNet.Obj underlying Cos/SDF object. Must be an SDF::Array with four SDF::Number elements.
Returns:
Type
Promise.<void>

contains(x, y)

Determines if the specified point is contained within the rectangular region defined by this Rectangle
Parameters:
Name Type Description
x number horizontal x value of the point to check
y number 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
Promise.<boolean>

get()

Get the coordinates of the rectangle
Returns:
A promise that resolves to an object of type: "Object"
Type
Promise.<Object>

height()

Returns:
A promise that resolves to rectangle's height
Type
Promise.<number>

inflate1(amount)

Expands the rectangle by the specified size, in all directions.
Parameters:
Name Type Description
amount number Specifies the amount to increase the rectangle in all directions.
Returns:
Type
Promise.<void>

inflate2(x, y)

Expands the rectangle by the specified size, in all directions.
Parameters:
Name Type Description
x number Specifies the amount to increase the rectangle's Left (x1) and Right (x2) properties.
y number Specifies the amount to increase the rectangle's Top (y1) and Bottom (y2) properties.
Returns:
Type
Promise.<void>

intersectRect(rect1, rect2)

Makes a Rect equal to the intersection of two existing rectangles.
Parameters:
Name Type Description
rect1 PDFNet.Rect A Rect object that contains a source rectangle.
rect2 PDFNet.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
Promise.<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.
Returns:
Type
Promise.<void>

set(x1, y1, x2, y2)

Set the coordinates of the rectangle
Parameters:
Name Type Description
x1 number The left-most position of the rect.
y1 number The bottom-most position of the rect.
x2 number The right-most position of the rect.
y2 number The top-most position of the rect. The rect is not attached to any Cos/SDF object.
Returns:
Type
Promise.<void>

update( [obj])

Saves changes made to the Rect object in the attached (or specified) SDF/Cos rectangle.
Parameters:
Name Type Argument Description
obj PDFNet.Obj <optional>
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
Promise.<boolean>

width()

Returns:
A promise that resolves to rectangle's width
Type
Promise.<number>