Rect2i

Objective-C


@interface Rect2i : NSObject

Swift

class Rect : NSObject

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

Properties

  • x

    Declaration

    Objective-C

    @property int x

    Swift

    var x: Int32 { get set }
  • y

    Declaration

    Objective-C

    @property int y

    Swift

    var y: Int32 { get set }
  • Declaration

    Objective-C

    @property int width

    Swift

    var width: Int32 { get set }
  • Declaration

    Objective-C

    @property int height

    Swift

    var height: Int32 { get set }

Constructors

  • Declaration

    Objective-C

    - (instancetype)init;

    Swift

    init()
  • Declaration

    Objective-C

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

    Swift

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

    Objective-C

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

    Swift

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

    Objective-C

    - (instancetype)initWithPoint:(Point2i*)point size:(Size2i*)size;

    Swift

    init(point: Point2i, size: Size2i)
  • 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 Point2i *)tl;

    Swift

    func tl() -> Point2i
  • -br

    Returns the bottom right coordinate of the rectangle

    Declaration

    Objective-C

    - (nonnull Point2i *)br;

    Swift

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

    Declaration

    Objective-C

    - (nonnull Size2i *)size;

    Swift

    func size() -> Size2i
  • 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 Point2i *)point;

    Swift

    func contains(_ point: Point2i) -> 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 Rect2i *)clone;

    Swift

    func clone() -> Rect
  • 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