MBQuadrangle

Objective-C


@interface MBQuadrangle : NSObject

Swift

class MBQuadrangle : NSObject

Class represents the quadrangle (arbitrary geometric object with 4 different corner points

  • Upper left point

    Declaration

    Objective-C

    @property (nonatomic) CGPoint upperLeft;

    Swift

    var upperLeft: CGPoint { get set }
  • Upper right point

    Declaration

    Objective-C

    @property (nonatomic) CGPoint upperRight;

    Swift

    var upperRight: CGPoint { get set }
  • Lower left point

    Declaration

    Objective-C

    @property (nonatomic) CGPoint lowerLeft;

    Swift

    var lowerLeft: CGPoint { get set }
  • Lower right point

    Declaration

    Objective-C

    @property (nonatomic) CGPoint lowerRight;

    Swift

    var lowerRight: CGPoint { get set }
  • Designated initializer which initializes all four corners of the quadrangle

    Declaration

    Objective-C

    - (nonnull instancetype)initWithUpperLeft:(CGPoint)upperLeft
                                   upperRight:(CGPoint)upperRight
                                    lowerLeft:(CGPoint)lowerLeft
                                   lowerRight:(CGPoint)lowerRight;

    Swift

    init(upperLeft: CGPoint, upperRight: CGPoint, lowerLeft: CGPoint, lowerRight: CGPoint)

    Parameters

    upperLeft

    upper left corner of the quadrangle

    upperRight

    upper right corner of the quadrangle

    lowerLeft

    lower left corner of the quadrangle

    lowerRight

    lower right corner of the quadrangle

    Return Value

    initialized quadrangle with four corners

  • Returns points of the quadrangle in array in the following order:

    • upperLeft, upperRight, lowerLeft, lowerRight.

    The array contains object obtained by, e.g: [NSValue valueWithCGPoint:CGPointMake(0.0, 1.0)]

    Declaration

    Objective-C

    - (nonnull NSArray *)toPointsArray;

    Swift

    func toPointsArray() -> [Any]

    Return Value

    points of the quadrangle in an array

  • Creates new quadrangle from this quadrangle, transformed by specified affine transformation.

    Declaration

    Objective-C

    - (nonnull instancetype)quadrangleWithTransformation:
        (CGAffineTransform)transform;

    Swift

    func withTransformation(_ transform: CGAffineTransform) -> Self
  • Returns the center point of the Quadrangle

    Declaration

    Objective-C

    - (CGPoint)center;

    Swift

    func center() -> CGPoint

    Return Value

    center point