Next: Geometry Functions Up: Points, Sizes and Rectangles Previous: NSSize

NSRect

An NSRect is a struct describing both the position and the size of a rectangle:
typedef struct _NSRect
{
  NSPoint origin;
  NSSize size;
} NSRect;
Using NSRect is similar to using NSPoint and NSSize:
NSRect testRect;

testRect = NSMakeRect (8.1, -3, 10, 15);
NSLog (@"x origin: %f", testRect.origin.x); // 8.1
NSLog (@"y origin: %f", testRect.origin.y); // -3
NSLog (@"width: %f", testRect.size.width); // 10
NSLog (@"height: %f", testRect.size.height); // 15
Note that you first access the origin, and then its coordinates, and similarly for the size.

The constant NSZeroRect represents a rect with NSZeroPoint origin and NSZeroSize size.



Nicola Pero 2000-07-29