SPRectangle Class Reference
| 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
-
– initWithX:y:width:height:Initializes a rectangle with the specified components. Designated Initializer.
-
+ rectangleWithX:y:width:height:Factory method.
-
+ rectangleFactory method.
Methods
-
– containsX:y:Determines if a point is within the rectangle.
-
– containsPoint:Determines if a point is within the rectangle.
-
– containsRectangle:Determines if another rectangle is within the rectangle.
-
– intersectsRectangle:Determines if another rectangle contains or intersects the rectangle.
-
– intersectionWithRectangle:If the specified rectangle intersects with the rectangle, returns the area of intersection.
-
– uniteWithRectangle:Adds two rectangles together to create a new Rectangle object (by filling in the space between the two rectangles).
-
– 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.
-
– setX:y:width:height:Sets the members of the rectangle to the specified values.
-
– setEmptySets width and height components to zero.
-
– copyFromRectangle:Copies the values from another rectangle into the current rectangle.
-
– isEqualToRectangle:Compares two rectangles.
-
– normalizeIf the rectangle contains negative values for width or height, all coordinates are adjusted so that the rectangle describes the same region with positive values.
Properties
-
xThe x coordinate of the rectangle.
property -
yThe y coordinate of the rectangle.
property -
widthThe width of the rectangle.
property -
heightThe height of the rectangle.
property -
topThe y coordinate of the rectangle.
property -
bottomThe sum of the y and height properties.
property -
leftThe x coordinate of the rectangle.
property -
rightThe sum of the x and width properties.
property -
topLeftThe location of the top-left corner, determined by the x and y coordinates of the point.
property -
bottomRightThe location of the bottom-right corner, determined by the values of the right and bottom properties.
property -
sizeThe size of the Rectangle object, determined by the values of the width and height properties.
property -
isEmptyDetermines if a rectangle has an empty area.
property
Properties
bottom
The sum of the y and height properties.
@property (nonatomic, assign) float bottomDiscussion
The sum of the y and height properties.
Declared In
SPRectangle.hbottomRight
The location of the bottom-right corner, determined by the values of the right and bottom properties.
@property (nonatomic, copy) SPPoint *bottomRightDiscussion
The location of the bottom-right corner, determined by the values of the right and bottom properties.
Declared In
SPRectangle.hheight
The height of the rectangle.
@property (nonatomic, assign) float heightDiscussion
The height of the rectangle.
Declared In
SPRectangle.hisEmpty
Determines if a rectangle has an empty area.
@property (nonatomic, readonly) BOOL isEmptyDiscussion
Determines if a rectangle has an empty area.
Declared In
SPRectangle.hleft
The x coordinate of the rectangle.
@property (nonatomic, assign) float leftDiscussion
The x coordinate of the rectangle.
Declared In
SPRectangle.hright
The sum of the x and width properties.
@property (nonatomic, assign) float rightDiscussion
The sum of the x and width properties.
Declared In
SPRectangle.hsize
The size of the Rectangle object, determined by the values of the width and height properties.
@property (nonatomic, copy) SPPoint *sizeDiscussion
The size of the Rectangle object, determined by the values of the width and height properties.
Declared In
SPRectangle.htop
The y coordinate of the rectangle.
@property (nonatomic, assign) float topDiscussion
The y coordinate of the rectangle.
Declared In
SPRectangle.htopLeft
The location of the top-left corner, determined by the x and y coordinates of the point.
@property (nonatomic, copy) SPPoint *topLeftDiscussion
The location of the top-left corner, determined by the x and y coordinates of the point.
Declared In
SPRectangle.hwidth
The width of the rectangle.
@property (nonatomic, assign) float widthDiscussion
The width of the rectangle.
Declared In
SPRectangle.hClass Methods
Instance Methods
containsPoint:
Determines if a point is within the rectangle.
- (BOOL)containsPoint:(SPPoint *)pointDiscussion
Determines if a point is within the rectangle.
Declared In
SPRectangle.hcontainsRectangle:
Determines if another rectangle is within the rectangle.
- (BOOL)containsRectangle:(SPRectangle *)rectangleDiscussion
Determines if another rectangle is within the rectangle.
Declared In
SPRectangle.hcontainsX:y:
Determines if a point is within the rectangle.
- (BOOL)containsX:(float)x y:(float)yDiscussion
Determines if a point is within the rectangle.
Declared In
SPRectangle.hcopyFromRectangle:
Copies the values from another rectangle into the current rectangle.
- (void)copyFromRectangle:(SPRectangle *)rectangleDiscussion
Copies the values from another rectangle into the current rectangle.
Declared In
SPRectangle.hinflateXBy: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)dyDiscussion
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.hinitWithX:y:width:height:
Initializes a rectangle with the specified components. Designated Initializer.
- (instancetype)initWithX:(float)x y:(float)y width:(float)width height:(float)heightDiscussion
Initializes a rectangle with the specified components. Designated Initializer.
Declared In
SPRectangle.hintersectionWithRectangle:
If the specified rectangle intersects with the rectangle, returns the area of intersection.
- (SPRectangle *)intersectionWithRectangle:(SPRectangle *)rectangleDiscussion
If the specified rectangle intersects with the rectangle, returns the area of intersection.
Declared In
SPRectangle.hintersectsRectangle:
Determines if another rectangle contains or intersects the rectangle.
- (BOOL)intersectsRectangle:(SPRectangle *)rectangleDiscussion
Determines if another rectangle contains or intersects the rectangle.
Declared In
SPRectangle.hisEqualToRectangle:
Compares two rectangles.
- (BOOL)isEqualToRectangle:(SPRectangle *)otherDiscussion
Compares two rectangles.
Declared In
SPRectangle.hnormalize
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)normalizeDiscussion
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.hsetEmpty
Sets width and height components to zero.
- (void)setEmptyDiscussion
Sets width and height components to zero.
Declared In
SPRectangle.hsetX: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)heightDiscussion
Sets the members of the rectangle to the specified values.
Declared In
SPRectangle.huniteWithRectangle:
Adds two rectangles together to create a new Rectangle object (by filling in the space between the two rectangles).
- (SPRectangle *)uniteWithRectangle:(SPRectangle *)rectangleDiscussion
Adds two rectangles together to create a new Rectangle object (by filling in the space between the two rectangles).
Declared In
SPRectangle.h