Function

CGRectDivide

Divides a source rectangle into two component rectangles.

Declaration

void CGRectDivide(CGRect rect, CGRect *slice, CGRect *remainder, CGFloat amount, CGRectEdge edge);

Parameters

rect

The source rectangle.

slice

On input, a pointer to an uninitialized rectangle. On return, the rectangle is filled in with the specified edge and values that extends the distance beyond the edge specified by the amount parameter. Must not be NULL.

remainder

On input, a pointer to an uninitialized rectangle. On return, the rectangle contains the portion of the source rectangle that remains after CGRectEdge produces the “slice” rectangle. Must not be NULL.

amount

A distance from the rectangle side that is specified in the edge parameter. This distance defines the line, parallel to the specified side, that Core Graphics uses to divide the source rectangle.

edge

An edge value 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.

Discussion

If rect is a null rectangle, this function outputs CGRectNull for both the slice and remainder rectangles.

See Also

Modifying Rectangles

CGRectInset

Returns a rectangle that is smaller or larger than the source rectangle, with the same center point.

CGRectIntegral

Returns the smallest rectangle that results from converting the source rectangle values to integers.

CGRectIntersection

Returns the intersection of two rectangles.

CGRectOffset

Returns a rectangle with an origin that is offset from that of the source rectangle.

CGRectStandardize

Returns a rectangle with a positive width and height.

CGRectUnion

Returns the smallest rectangle that contains the two source rectangles.