PTPDFRect

@interface PTPDFRect : NSObject

Rect is a utility class used to manipulate PDF rectangle objects (refer to section 3.8.3 of the PDF Reference Manual).

Rect can be associated with a SDF/Cos rectangle array using Rect(Obj*) constructor or later using Rect::Attach(Obj*) or Rect::Update(Obj*) methods.

Rect keeps a local cache for rectangle points so it is necessary to call Rect::Update() method if the changes to the Rect should be saved in the attached Cos/SDF array.

Note

- Although rectangles are conventionally specified by their lower-left and upper-right corners, it is acceptable to specify any two diagonally opposite corners.
  • Rect default constructor.

    Declaration

    Objective-C

    - (instancetype)init;

    Swift

    init!()
  • Undocumented

    Declaration

    Objective-C

    - (instancetype)initWithRect: (PTObj*)rect;

    Swift

    init!(rect: PTObj!)
  • Undocumented

    Declaration

    Objective-C

    - (instancetype)initWithX1: (double)x1 y1:  (double)y1 x2:  (double)x2 y2:  (double)y2;

    Swift

    init!(x1: Double, y1: Double, x2: Double, y2: Double)
  • Attach the Cos/SDF object to the Rect.

    Declaration

    Objective-C

    - (void)Attach:(PTObj *)obj;

    Swift

    func attach(_ obj: PTObj!)

    Parameters

    obj

    - underlying Cos/SDF object. Must be an SDF::Array with four SDF::Number elements.

  • Saves changes made to the Rect object in the attached (or specified) SDF/Cos rectangle.

    Declaration

    Objective-C

    - (BOOL)Update:(PTObj *)obj;

    Swift

    func update(_ obj: PTObj!) -> Bool

    Parameters

    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.

    Return Value

    true if the attached Cos/SDF rectangle array was successfully updated, false otherwise.

  • Set the coordinates of the rectangle

    Declaration

    Objective-C

    - (void)Set:(double)x1 y1:(double)y1 x2:(double)x2 y2:(double)y2;

    Swift

    func set(_ x1: Double, y1: Double, x2: Double, y2: Double)

    Parameters

    x1

    The left-most position of the rect.

    y1

    The bottom-most position of the rect.

    x2

    The right-most position of the rect.

    y2

    The top-most position of the rect. The rect is not attached to any Cos/SDF object.

  • Declaration

    Objective-C

    - (double)Width;

    Swift

    func width() -> Double

    Return Value

    rectangle’s width

  • Declaration

    Objective-C

    - (double)Height;

    Swift

    func height() -> Double

    Return Value

    rectangle’s height

  • Determines if the specified point is contained within the rectangular region defined by this Rectangle

    Declaration

    Objective-C

    - (BOOL)Contains:(double)x y:(double)y;

    Swift

    func contains(_ x: Double, y: Double) -> Bool

    Parameters

    x

    horizontal x value of the point to check

    y

    vertical y value of the point to check

    Return Value

    true is the point is in the rectangle, false otherwise.

  • Makes a Rect equal to the intersection of two existing rectangles.

    Note

    The intersection is the largest rectangle contained in both existing rectangles.

    Declaration

    Objective-C

    - (BOOL)IntersectRect:(PTPDFRect *)rect1 rect2:(PTPDFRect *)rect2;

    Swift

    func intersect(_ rect1: PTPDFRect!, rect2: PTPDFRect!) -> Bool

    Parameters

    rect1

    - A Rect object that contains a source rectangle.

    rect2

    - A Rect object that contains a source rectangle.

    Return Value

    true if the intersection is not empty; 0 if the intersection is empty.

  • 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.

    Note

    Although rectangles are conventionally specified by their lower-left and upper-right corners, it is acceptable to specify any two diagonally opposite corners.

    Declaration

    Objective-C

    - (void)Normalize;

    Swift

    func normalize()
  • Expands the rectangle by the specified size, in all directions.

    Declaration

    Objective-C

    - (void)InflateWithAmount:(double)amount;

    Swift

    func inflate(withAmount amount: Double)

    Parameters

    amount

    Specifies the amount to increase the rectangle in all directions.

  • Expands the rectangle by the specified size, in all directions.

    Declaration

    Objective-C

    - (void)InflateWithXY:(double)x y:(double)y;

    Swift

    func inflate(withXY x: Double, y: Double)

    Parameters

    x

    Specifies the amount to increase the rectangle’s Left (x1) and Right (x2) properties.

    y

    Specifies the amount to increase the rectangle’s Top (y1) and Bottom (y2) properties.

  • Declaration

    Objective-C

    - (double)GetX1;

    Swift

    func getX1() -> Double

    Return Value

    The horizontal value of lower-left point.

  • Declaration

    Objective-C

    - (double)GetY1;

    Swift

    func getY1() -> Double

    Return Value

    The vertical value of lower-left point.

  • Declaration

    Objective-C

    - (double)GetX2;

    Swift

    func getX2() -> Double

    Return Value

    The horizontal value of upper-right point.

  • Declaration

    Objective-C

    - (double)GetY2;

    Swift

    func getY2() -> Double

    Return Value

    The vertical value of upper-right point.

  • Set the horizontal value of lower-left point.

    Declaration

    Objective-C

    - (void)SetX1:(double)x1;

    Swift

    func setX1(_ x1: Double)

    Parameters

    x1

    The left-most position of the rect.

  • Set the vertical value of lower-left point.

    Declaration

    Objective-C

    - (void)SetY1:(double)y1;

    Swift

    func setY1(_ y1: Double)

    Parameters

    y1

    The bottom-most position of the rect.

  • Set the horizontal value of upper-right point.

    Declaration

    Objective-C

    - (void)SetX2:(double)x2;

    Swift

    func setX2(_ x2: Double)

    Parameters

    x2

    The right-most position of the rect.

  • Set the vertical value of upper-right point.

    Declaration

    Objective-C

    - (void)SetY2:(double)y2;

    Swift

    func setY2(_ y2: Double)

    Parameters

    y2

    The top-most position of the rect.