Framework | ApplicationServices/ApplicationServices.h |
Companion guide | |
Declared in | CABase.h CGGeometry.h |
CGGeometry Reference defines structures for geometric primitives and functions that operate on them. The data structure CGPoint
represents a point in a two-dimensional coordinate system. The data structure CGRect
represents the location and dimensions of a rectangle. The data structure CGSize
represents the dimensions of width and height.
CGPointCreateDictionaryRepresentation
CGSizeCreateDictionaryRepresentation
CGRectCreateDictionaryRepresentation
CGPointMakeWithDictionaryRepresentation
CGSizeMakeWithDictionaryRepresentation
CGRectMakeWithDictionaryRepresentation
CGRectDivide
CGRectInset
CGRectIntegral
CGRectIntersection
CGRectOffset
CGRectStandardize
CGRectUnion
Returns a dictionary representation of the provided point.
CFDictionaryRef CGPointCreateDictionaryRepresentation( CGPoint point );
A point.
The dictionary representation of the point.
CGGeometry.h
Returns whether two points are equal.
bool CGPointEqualToPoint ( CGPoint point1, CGPoint point2 );
The first point to examine.
The second point to examine.
Returns 1
if the two specified points are the same; otherwise, 0
.
CGGeometry.h
Returns a CGPoint
structure filled in with the coordinate values you provide.
CGPoint CGPointMake ( CGFloat x, CGFloat y );
The x-coordinate of the point to construct.
The y-coordinate of the point to construct.
Returns a CGPoint
structure, representing a single (x,y) coordinate pair.
CGGeometry.h
Fills in a CGPoint
structure using the contents of the provided dictionary.
bool CGPointMakeWithDictionaryRepresentation( CFDictionaryRef dict, CGPoint *point );
A dictionary that was previously returned from the function CGPointCreateDictionaryRepresentation
.
On return, the point created from the provided dictionary.
true
if successful; false
otherwise.
CGGeometry.h
Returns whether a rectangle contains a specified point.
bool CGRectContainsPoint ( CGRect rect, CGPoint point );
The rectangle to examine.
The point to examine.
Returns 1
if the specified point is located within the specified rectangle; otherwise, 0
.
CGGeometry.h
Returns whether the first rectangle contains the second rectangle.
bool CGRectContainsRect ( CGRect rect1, CGRect rect2 );
The rectangle to examine for containment of the rectangle passed in rect2
.
The rectangle to examine for being contained in the rectangle passed in rect1
.
Returns 1
if the rectangle specified by rect2
is contained in the rectangle passed in rect1
; otherwise, 0
. The first rectangle contains the second if the union of the two rectangles is equal to the first rectangle.
CGGeometry.h
Returns a dictionary representation of the provided rectangle.
CFDictionaryRef CGRectCreateDictionaryRepresentation( CGRect rect );
A rectangle.
The dictionary representation of the rectangle.
CGGeometry.h
Divides a source rectangle into two component rectangles.
void CGRectDivide ( CGRect rect, CGRect *slice, CGRect *remainder, CGFloat amount, CGRectEdge edge );
The source CGRect
structure.
On input, a pointer to an uninitialized CGRect
structure. On return, a CGRect
structure filled in with the specified edge and values that extends the distance beyond the edge specified by the amount parameter.
On input, a pointer to an uninitialized rectangle CGRect
structure. On return, the CGRect
structure contains the portion of the source CGRect
structure that remains after CGRectEdge
produces the “slice” rectangle.
A distance from the rectangle side that is specified in the edge parameter. This distance defines the line, parallel to the specified side, that Quartz uses to divide the source CGRect
structure.
A CGRectEdge
value (CGRectMinXEdge
, CGRectMinYEdge
, CGRectMaxXEdge
, or CGRectMaxYEdge
) that specifies the side of the rectangle from which the distance passed in the amount
parameter is measured. CGRectDivide
produces a “slice” rectangle that contains the specified edge and extends amount
distance beyond it.
CGGeometry.h
Returns whether two rectangles are equal in size and position.
bool CGRectEqualToRect ( CGRect rect1, CGRect rect2 );
The first rectangle to examine.
The second rectangle to examine.
Returns 1
if the two specified rectangles have equal size and origin values, or are both null
. Otherwise, returns 0
.
CGGeometry.h
Returns the height of a rectangle.
CGFloat CGRectGetHeight ( CGRect rect );
The rectangle to examine.
The height of the specified rectangle.
CGGeometry.h
Returns the x-coordinate that establishes the right edge of a rectangle.
CGFloat CGRectGetMaxX ( CGRect rect );
The rectangle to examine.
The x-coordinate of the top-right corner of the specified rectangle.
CGGeometry.h
Returns the y-coordinate that establishes the top edge of a rectangle.
CGFloat CGRectGetMaxY ( CGRect rect );
The rectangle to examine.
The y-coordinate of the top-right corner of the specified rectangle.
CGGeometry.h
Returns the x- coordinate that establishes the center of a rectangle.
CGFloat CGRectGetMidX ( CGRect rect );
The rectangle to examine.
The x-coordinate of the center of the specified rectangle.
CGGeometry.h
Returns the y-coordinate that establishes the center of a rectangle.
CGFloat CGRectGetMidY ( CGRect rect );
The rectangle to examine.
The y-coordinate of the center of the specified rectangle.
CGGeometry.h
Returns the x-coordinate that establishes the left edge of a rectangle.
CGFloat CGRectGetMinX ( CGRect rect );
The rectangle to examine.
The x-coordinate of the bottom-left corner of the specified rectangle.
CGGeometry.h
Returns the y-coordinate that establishes the bottom edge of a rectangle.
CGFloat CGRectGetMinY ( CGRect rect );
The rectangle to examine.
The y-coordinate of the bottom-left corner of the specified rectangle.
CGGeometry.h
Returns the width of a rectangle.
CGFloat CGRectGetWidth ( CGRect rect );
The rectangle to examine.
The width of the specified rectangle.
CGGeometry.h
Returns a rectangle that is smaller or larger than the source rectangle, with the same center point.
CGRect CGRectInset ( CGRect rect, CGFloat dx, CGFloat dy );
The source CGRect
structure.
The x-coordinate value to use for adjusting the source rectangle. To create an inset rectangle, specify a positive value. To create a larger, encompassing rectangle, specify a negative value.
The y-coordinate value to use for adjusting the source rectangle. To create an inset rectangle, specify a positive value. To create a larger, encompassing rectangle, specify a negative value.
A filled-in CGRect
structure. The origin value is offset in the x-axis by the distance specified by the dx
parameter and in the y-axis by the distance specified by the dy
parameter, and its size adjusted by (2*dx,2*dy)
, relative to the source rectangle. If dx
and dy
are positive values, then the rectangle’s size is decreased. If dx
and dy
are negative values, the rectangle’s size is increased.
CGGeometry.h
Returns the smallest rectangle that results from converting the source rectangle values to integers.
CGRect CGRectIntegral ( CGRect rect );
The source rectangle.
A filled-in CGRect
structure whose values represent the rectangle with the smallest integer values for its origin and size that contains the source rectangle. That is, given a rectangle with fractional origin or size values, CGRectIntegral
rounds the rectangle’s origin downward and its size upward to the nearest whole integers, such that the result contains the original rectangle.
CGGeometry.h
Returns the intersection of two rectangles.
CGRect CGRectIntersection ( CGRect r1, CGRect r2 );
The first source rectangle.
The second source rectangle.
A filled-in CGRect
structure that represents the intersection of the two specified rectangles. If the two rectangles do not intersect, returns the null rectangle. To check for this condition, use CGRectIsNull
.
CGGeometry.h
Returns whether two rectangles intersect.
bool CGRectIntersectsRect ( CGRect rect1, CGRect rect2 );
The first rectangle to examine.
The second rectangle to examine.
Returns 1
if the two specified rectangles intersect; otherwise, 0
. The first rectangle intersects the second if the intersection of the rectangles is not equal to the null rectangle.
CGGeometry.h
Returns whether a rectangle has zero width or height, or is a null rectangle.
bool CGRectIsEmpty ( CGRect rect );
The rectangle to examine.
Returns 1
if the specified rectangle is empty; otherwise, 0
.
An empty rectangle is either a null rectangle or a valid rectangle with zero height or width. See also CGRectIsNull
.
CGGeometry.h
Returns whether a rectangle is infinite.
bool CGRectIsInfinite ( CGRect rect );
The rectangle to examine.
Returns true
if the specified rectangle is infinite, false
otherwise.
An infinite rectangle is one that has no defined bounds. Infinite rectangles can be created as output from a tiling filter. For example, the Core Image framework perspective tile filter creates an image whose extent is described by an infinite rectangle.
CGGeometry.h
Returns whether the origin and size of the rectangle can be represented exactly as integers.
bool CGRectIsIntegral ( CGRect rect );
The rectangle to examine.
Returns true
if the origin and size of the rectangle can be represented exactly as integers; false
otherwise.
CGGeometry.h
Returns whether a rectangle is invalid.
bool CGRectIsNull ( CGRect rect );
The rectangle to examine.
Returns 1
if the specified rectangle is null; otherwise, 0
.
A null rectangle is one that is not valid (you cannot draw a null rectangle). For example, the result of intersecting two disjoint rectangles is a null rectangle. See also CGRectIsEmpty
.
CGGeometry.h
Returns a CGRect
structure filled in with the coordinate and dimension values you provide.
CGRect CGRectMake ( CGFloat x, CGFloat y, CGFloat width, CGFloat height );
The x-coordinate of the rectangle’s origin point.
The y-coordinate of the rectangle’s origin point.
The width of the rectangle.
The height of the rectangle.
Returns a rectangle with the specified location and dimensions.
CGGeometry.h
Fills in a CGRect
structure using the contents of the provided dictionary.
bool CGRectMakeWithDictionaryRepresentation( CFDictionaryRef dict, CGRect *rect );
A dictionary that was previously returned from the function CGRectCreateDictionaryRepresentation
.
On return, the rectangle created from the provided dictionary.
true
if successful; false
otherwise.
CGGeometry.h
Returns a rectangle with an origin that is offset from that of the source rectangle.
CGRect CGRectOffset ( CGRect rect, CGFloat dx, CGFloat dy );
The source rectangle.
The offset value for the x-coordinate.
The offset value for the y-coordinate.
A filled-in CGRect
structure that is the same size as the source, but with its origin offset by dx
units along the x-axis and dy
units along the y-axis with respect to the source.
CGGeometry.h
Returns a rectangle with a positive width and height.
CGRect CGRectStandardize ( CGRect rect );
The source rectangle.
A filled-in CGRect
structure that represents the source rectangle, but with positive width and height values.
CGGeometry.h
Returns the smallest rectangle that contains the two provided rectangles.
CGRect CGRectUnion ( CGRect r1, CGRect r2 );
The first source rectangle.
The second source rectangle.
A filled-in CGRect
structure that represents the smallest rectangle that completely contains both of the source rectangles.
If one of the rectangles has 0 (or negative) width or height, a copy of the other rectangle is returned; but if both have 0 (or negative) width or height, the returned rectangle has its origin at (0.0, 0.0) and has 0 width and height.
CGGeometry.h
Returns a dictionary representation of the provided size.
CFDictionaryRef CGSizeCreateDictionaryRepresentation( CGSize size );
A size.
The dictionary representation of the size.
CGGeometry.h
Returns whether two sizes are equal.
bool CGSizeEqualToSize ( CGSize size1, CGSize size2 );
The first size to examine.
The second size to examine.
Returns 1
if the two specified sizes are equal; otherwise, 0
.
CGGeometry.h
Returns a CGSize
structure filled in with dimension values you provide.
CGSize CGSizeMake ( CGFloat width, CGFloat height );
A width value.
A height value.
Returns a CGSize
structure with the specified width and height.
CGGeometry.h
Fills in a CGSize
structure using the contents of the provided dictionary.
bool CGSizeMakeWithDictionaryRepresentation( CFDictionaryRef dict, CGSize *size );
A dictionary that was previously returned from the function CGSizeCreateDictionaryRepresentation
.
On return, the size created from the provided dictionary.
true
if successful; false
otherwise.
CGGeometry.h
A structure that contains a point in a two-dimensional coordinate system.
struct CGPoint { CGFloat x; CGFloat y; }; typedef struct CGPoint CGPoint;
x
The x-coordinate of the point.
y
The y-coordinate of the point.
CGGeometry.h
A structure that contains the location and dimensions of a rectangle.
struct CGRect { CGPoint origin; CGSize size; }; typedef struct CGRect CGRect;
origin
A CGPoint
structure that specifies the coordinates of the rectangle’s origin. The origin is located in the lower-left of the rectangle.
size
A CGSize
structure that specifies the height and width of the rectangle.
CGGeometry.h
A structure that contains width and height values.
struct CGSize { CGFloat width; CGFloat height; }; typedef struct CGSize CGSize;
width
A width value.
height
A height value.
CGGeometry.h
A rectangle that has infinite extent.
const CGRect CGRectInfinite;
CGRectInfinite
A rectangle that has infinite extent.
Available in Mac OS X v10.4 and later.
Declared in CGGeometry.h
.
CGGeometry.h
A zero point, zero rectangle, or zero size.
const CGPoint CGPointZero; const CGRect CGRectZero; const CGSize CGSizeZero;
CGPointZero
A point constant with location (0, 0)
. The zero point is equivalent to CGPointMake(0,0)
.
Available in Mac OS X v10.0 and later.
Declared in CGGeometry.h
.
CGRectZero
A rectangle constant with location (0,0)
, and width and height of 0. The zero rectangle is equivalent to CGRectMake(0,0,0,0)
.
Available in Mac OS X v10.0 and later.
Declared in CGGeometry.h
.
CGSizeZero
A size constant with width and height of 0. The zero size is equivalent to CGSizeMake(0,0)
.
Available in Mac OS X v10.0 and later.
Declared in CGGeometry.h
.
CGGeometry.h
The null or empty rectangle.
const CGRect CGRectNull;
CGRectNull
The null rectangle. This is the rectangle returned when, for example, you intersect two disjoint rectangles. Note that the null rectangle is not the same as the zero rectangle.
Available in Mac OS X v10.0 and later.
Declared in CGGeometry.h
.
CGGeometry.h
Coordinates that establish the edges of a rectangle.
enum CGRectEdge { CGRectMinXEdge, CGRectMinYEdge, CGRectMaxXEdge, CGRectMaxYEdge }; typedef enum CGRectEdge CGRectEdge;
CGRectMinXEdge
The x-coordinate that establishes the left edge of a rectangle.
Available in Mac OS X v10.0 and later.
Declared in CGGeometry.h
.
CGRectMinYEdge
The y-coordinate that establishes the minimum edge of a rectangle. In Mac OS X, this is typically the bottom edge of the rectangle. If the coordinate system is flipped (or if you are using the default coordinate system in iPhone OS), this constant refers to the top edge of the rectangle.
Available in Mac OS X v10.0 and later.
Declared in CGGeometry.h
.
CGRectMaxXEdge
The x-coordinate that establishes the right edge of a rectangle.
Available in Mac OS X v10.0 and later.
Declared in CGGeometry.h
.
CGRectMaxYEdge
The y-coordinate that establishes the maximum edge of a rectangle. In Mac OS X, this is typically the top edge of the rectangle. If the coordinate system is flipped (or if you are using the default coordinate system in iPhone OS), this constant refers to the bottom edge of the rectangle.
Available in Mac OS X v10.0 and later.
Declared in CGGeometry.h
.
CGGeometry.h
Informational macros for the CGFloat
type.
#define CGFLOAT_MIN FLT_MIN// 32-bit |
#define CGFLOAT_MIN DBL_MIN// 64-bit |
CGFLOAT_MIN
The minimum allowable value for a CGFloat
type. For 32-bit code, this value is 1.17549435e-38F
. For 64-bit code, it is 2.2250738585072014e-308
.
Available in Mac OS X v10.5 and later.
Declared in CABase.h
.
CGFLOAT_MAX
The maximum allowable value for a CGFloat
type. For 32-bit code, this value is 3.40282347e+38F
. For 64-bit code, it is 1.7976931348623157e+308
.
Available in Mac OS X v10.5 and later.
Declared in CABase.h
.
CGFLOAT_IS_DOUBLE
Indicates whether CGFloat
is defined as a float
or double
type.
Available in Mac OS X v10.5 and later.
Declared in CABase.h
.
© 2003, 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-01-06)