Rect2f

Objective-C

@interface Rect2f : NSObject

Swift

class Rect2f : NSObject

Represents a rectange the coordinate and dimension values of which are of type float

Properties

  • x

    Declaration

    Objective-C

    @property float x

    Swift

    var x: Float { get set }
  • y

    Declaration

    Objective-C

    @property float y

    Swift

    var y: Float { get set }
  • Declaration

    Objective-C

    @property float width

    Swift

    var width: Float { get set }
  • Declaration

    Objective-C

    @property float height

    Swift

    var height: Float { get set }

Constructors

  • Declaration

    Objective-C

    - (instancetype)init;

    Swift

    init()
  • Declaration

    Objective-C

    - (instancetype)initWithX:(float)x y:(float)y width:(float)width height:(float)height;

    Swift

    init(x: Float, y: Float, width: Float, height: Float)
  • Declaration

    Objective-C

    - (instancetype)initWithPoint:(Point2f*)point1 point:(Point2f*)point2;

    Swift

    init(point point1: Point2f, point point2: Point2f)
  • Declaration

    Objective-C

    - (instancetype)initWithPoint:(Point2f*)point size:(Size2f*)size;

    Swift

    init(point: Point2f, size: Size2f)
  • Declaration

    Objective-C

    - (instancetype)initWithVals:(NSArray<NSNumber*>*)vals;

    Swift

    init(vals: [NSNumber])

Methods

  • -tl

    Returns the top left coordinate of the rectangle

    Declaration

    Objective-C

    - (nonnull Point2f *)tl;

    Swift

    func tl() -> Point2f
  • -br

    Returns the bottom right coordinate of the rectangle

    Declaration

    Objective-C

    - (nonnull Point2f *)br;

    Swift

    func br() -> Point2f
  • Returns the size of the rectangle

    Declaration

    Objective-C

    - (nonnull Size2f *)size;

    Swift

    func size() -> Size2f
  • Returns the area of the rectangle

    Declaration

    Objective-C

    - (double)area;

    Swift

    func area() -> Double
  • Determines if the rectangle is empty

    Declaration

    Objective-C

    - (BOOL)empty;

    Swift

    func empty() -> Bool
  • Determines if the rectangle contains a given point

    Declaration

    Objective-C

    - (BOOL)contains:(nonnull Point2f *)point;

    Swift

    func contains(_ point: Point2f) -> Bool

    Parameters

    point

    The point

  • Set the rectangle coordinates and dimensions from the values of an array

    Declaration

    Objective-C

    - (void)set:(nonnull NSArray<NSNumber *> *)vals;

    Swift

    func set(vals: [NSNumber])

    Parameters

    vals

    The array of values from which to set the rectangle coordinates and dimensions

Common Methods

  • Clone object

    Declaration

    Objective-C

    - (nonnull Rect2f *)clone;

    Swift

    func clone() -> Rect2f
  • Compare for equality

    Declaration

    Objective-C

    - (BOOL)isEqual:(nullable id)object;

    Swift

    func isEqual(_ object: Any?) -> Bool

    Parameters

    other

    Object to compare

  • Calculate hash value for this object

    Declaration

    Objective-C

    - (NSUInteger)hash;

    Swift

    func hash() -> UInt
  • Returns a string that describes the contents of the object

    Declaration

    Objective-C

    - (nonnull NSString *)description;

    Swift

    func description() -> String