Inherits from SPPoolObject : NSObject
Conforms to NSCopying
Declared in SPRectangle.h

Overview

The SPRectangle class describes a rectangle by its top-left corner point (x, y) and by its width and height.

Tasks

Initialization

Methods

Properties

  •   x

    The x coordinate of the rectangle.

    property
  •   y

    The y coordinate of the rectangle.

    property
  •   width

    The width of the rectangle.

    property
  •   height

    The height of the rectangle.

    property
  •   top

    The y coordinate of the rectangle.

    property
  •   bottom

    The sum of the y and height properties.

    property
  •   left

    The x coordinate of the rectangle.

    property
  •   right

    The sum of the x and width properties.

    property
  •   topLeft

    The location of the top-left corner, determined by the x and y coordinates of the point.

    property
  •   bottomRight

    The location of the bottom-right corner, determined by the values of the right and bottom properties.

    property
  •   size

    The size of the Rectangle object, determined by the values of the width and height properties.

    property
  •   isEmpty

    Determines if a rectangle has an empty area.

    property

Properties

bottom

The sum of the y and height properties.

@property (nonatomic, assign) float bottom

Discussion

The sum of the y and height properties.

Declared In

SPRectangle.h

bottomRight

The location of the bottom-right corner, determined by the values of the right and bottom properties.

@property (nonatomic, copy) SPPoint *bottomRight

Discussion

The location of the bottom-right corner, determined by the values of the right and bottom properties.

Declared In

SPRectangle.h

height

The height of the rectangle.

@property (nonatomic, assign) float height

Discussion

The height of the rectangle.

Declared In

SPRectangle.h

isEmpty

Determines if a rectangle has an empty area.

@property (nonatomic, readonly) BOOL isEmpty

Discussion

Determines if a rectangle has an empty area.

Declared In

SPRectangle.h

left

The x coordinate of the rectangle.

@property (nonatomic, assign) float left

Discussion

The x coordinate of the rectangle.

Declared In

SPRectangle.h

right

The sum of the x and width properties.

@property (nonatomic, assign) float right

Discussion

The sum of the x and width properties.

Declared In

SPRectangle.h

size

The size of the Rectangle object, determined by the values of the width and height properties.

@property (nonatomic, copy) SPPoint *size

Discussion

The size of the Rectangle object, determined by the values of the width and height properties.

Declared In

SPRectangle.h

top

The y coordinate of the rectangle.

@property (nonatomic, assign) float top

Discussion

The y coordinate of the rectangle.

Declared In

SPRectangle.h

topLeft

The location of the top-left corner, determined by the x and y coordinates of the point.

@property (nonatomic, copy) SPPoint *topLeft

Discussion

The location of the top-left corner, determined by the x and y coordinates of the point.

Declared In

SPRectangle.h

width

The width of the rectangle.

@property (nonatomic, assign) float width

Discussion

The width of the rectangle.

Declared In

SPRectangle.h

x

The x coordinate of the rectangle.

@property (nonatomic, assign) float x

Discussion

The x coordinate of the rectangle.

Declared In

SPRectangle.h

y

The y coordinate of the rectangle.

@property (nonatomic, assign) float y

Discussion

The y coordinate of the rectangle.

Declared In

SPRectangle.h

Class Methods

rectangle

Factory method.

+ (instancetype)rectangle

Discussion

Factory method.

Declared In

SPRectangle.h

rectangleWithX:y:width:height:

Factory method.

+ (instancetype)rectangleWithX:(float)x y:(float)y width:(float)width height:(float)height

Discussion

Factory method.

Declared In

SPRectangle.h

Instance Methods

containsPoint:

Determines if a point is within the rectangle.

- (BOOL)containsPoint:(SPPoint *)point

Discussion

Determines if a point is within the rectangle.

Declared In

SPRectangle.h

containsRectangle:

Determines if another rectangle is within the rectangle.

- (BOOL)containsRectangle:(SPRectangle *)rectangle

Discussion

Determines if another rectangle is within the rectangle.

Declared In

SPRectangle.h

containsX:y:

Determines if a point is within the rectangle.

- (BOOL)containsX:(float)x y:(float)y

Discussion

Determines if a point is within the rectangle.

Declared In

SPRectangle.h

copyFromRectangle:

Copies the values from another rectangle into the current rectangle.

- (void)copyFromRectangle:(SPRectangle *)rectangle

Discussion

Copies the values from another rectangle into the current rectangle.

Declared In

SPRectangle.h

inflateXBy:yBy:

Increases the size of the specified rectangle by the specified amounts. The center point of the rectangle stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.

- (void)inflateXBy:(float)dx yBy:(float)dy

Discussion

Increases the size of the specified rectangle by the specified amounts. The center point of the rectangle stays the same, and its size increases to the left and right by the dx value, and to the top and the bottom by the dy value.

Declared In

SPRectangle.h

initWithX:y:width:height:

Initializes a rectangle with the specified components. Designated Initializer.

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

Discussion

Initializes a rectangle with the specified components. Designated Initializer.

Declared In

SPRectangle.h

intersectionWithRectangle:

If the specified rectangle intersects with the rectangle, returns the area of intersection.

- (SPRectangle *)intersectionWithRectangle:(SPRectangle *)rectangle

Discussion

If the specified rectangle intersects with the rectangle, returns the area of intersection.

Declared In

SPRectangle.h

intersectsRectangle:

Determines if another rectangle contains or intersects the rectangle.

- (BOOL)intersectsRectangle:(SPRectangle *)rectangle

Discussion

Determines if another rectangle contains or intersects the rectangle.

Declared In

SPRectangle.h

isEqualToRectangle:

Compares two rectangles.

- (BOOL)isEqualToRectangle:(SPRectangle *)other

Discussion

Compares two rectangles.

Declared In

SPRectangle.h

normalize

If the rectangle contains negative values for width or height, all coordinates are adjusted so that the rectangle describes the same region with positive values.

- (void)normalize

Discussion

If the rectangle contains negative values for width or height, all coordinates are adjusted so that the rectangle describes the same region with positive values.

Declared In

SPRectangle.h

setEmpty

Sets width and height components to zero.

- (void)setEmpty

Discussion

Sets width and height components to zero.

Declared In

SPRectangle.h

setX:y:width:height:

Sets the members of the rectangle to the specified values.

- (void)setX:(float)x y:(float)y width:(float)width height:(float)height

Discussion

Sets the members of the rectangle to the specified values.

Declared In

SPRectangle.h

uniteWithRectangle:

Adds two rectangles together to create a new Rectangle object (by filling in the space between the two rectangles).

- (SPRectangle *)uniteWithRectangle:(SPRectangle *)rectangle

Discussion

Adds two rectangles together to create a new Rectangle object (by filling in the space between the two rectangles).

Declared In

SPRectangle.h