CGRect
A structure that contains the location and dimensions of a rectangle.
Static Member Summary
Static Public Members | ||
public static get |
The zero rectangle is equivalent to one created by calling CGRect(x: 0, y: 0, width: 0, height: 0). |
Static Method Summary
Static Public Methods | ||
public static |
|
Constructor Summary
Public Constructor | ||
public |
constructor(origin: CGPoint, size: CGSize) Creates a rectangle with the specified origin and size. |
Member Summary
Public Members | ||
public get |
customMirror: Mirror |
|
public get |
customPlaygroundQuickLook: PlaygroundQuickLook |
|
public get |
A textual representation of the rectangle's origin and size values. |
|
public get |
|
|
public get |
Regardless of whether the height is stored in the CGRect data structure as a positive or negative number, this function returns the height as if the rectangle were standardized. |
|
public get |
|
|
public get |
An empty rectangle is either a null rectangle or a valid rectangle with zero height or width. |
|
public get |
An infinite rectangle is one that has no defined bounds. |
|
public get |
A null rectangle is the equivalent of an empty set. |
|
public get |
|
|
public get |
|
|
public get |
|
|
public get |
|
|
public get |
|
|
public get |
|
|
public |
origin: * |
|
public |
size: * |
|
public get |
|
|
public get |
Regardless of whether the width is stored in the CGRect data structure as a positive or negative number, this function returns the width as if the rectangle were standardized. |
Method Summary
Public Methods | ||
public |
add(rect2: *): * |
|
public |
Because affine transforms do not preserve rectangles in general, this function returns the smallest rectangle that contains the transformed corner points of the rect parameter. |
|
public |
A point is considered inside the rectangle if its coordinates lie inside the rectangle or on the minimum X or minimum Y edge. |
|
public |
copy(): * |
|
public |
dividedFrom(atDistance: number, fromEdge: CGRectEdge): {slice: CGRect, remainder: CGRect} Together the fromEdge and atDistance parameters define a line (parallel to the specified edge of the rectangle and at the specified distance from that edge) that divides the rectangle into two component rectangles. |
|
public |
Returns whether two rectangles are equal in size and position. |
|
public |
initDictionaryRepresentation(dict: Map): void Creates a rectangle from a canonical dictionary representation. |
|
public |
The rectangle is standardized and then the inset parameters are applied. |
|
public |
intersection(r2: CGRect): CGRect Both rectangles are standardized prior to calculating the intersection. |
|
public |
intersects(rect2: CGRect): boolean Returns whether two rectangles intersect. |
|
public |
|
|
public |
Returns a rectangle with an origin that is offset from that of the source rectangle. |
|
public |
sub(rect2: *): * |
|
public |
Both rectangles are standardized prior to calculating the union. |
|
public |
zero(): * |
Static Public Members
Static Public Methods
Public Constructors
Public Members
public get customMirror: Mirror source
public get customPlaygroundQuickLook: PlaygroundQuickLook source
public get debugDescription: string source
A textual representation of the rectangle's origin and size values.
public get height: number source
Regardless of whether the height is stored in the CGRect data structure as a positive or negative number, this function returns the height as if the rectangle were standardized. That is, the result is never a negative number.
public get isEmpty: boolean source
An empty rectangle is either a null rectangle or a valid rectangle with zero height or width.
public get isInfinite: boolean source
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.
public get isNull: boolean source
A null rectangle is the equivalent of an empty set. For example, the result of intersecting two disjoint rectangles is a null rectangle. A null rectangle cannot be drawn and interacts with other rectangles in special ways.
public origin: * source
public size: * source
Public Methods
public applying(t: CGAffineTransform): CGRect source
Because affine transforms do not preserve rectangles in general, this function returns the smallest rectangle that contains the transformed corner points of the rect parameter. If the affine transform t consists solely of scaling and translation operations, then the returned rectangle coincides with the rectangle constructed from the four transformed corners.
Params:
Name | Type | Attribute | Description |
t | CGAffineTransform | The affine transform to apply to the rect parameter. |
public contains(point: CGPoint): boolean source
A point is considered inside the rectangle if its coordinates lie inside the rectangle or on the minimum X or minimum Y edge.
Params:
Name | Type | Attribute | Description |
point | CGPoint | The point to examine. |
public dividedFrom(atDistance: number, fromEdge: CGRectEdge): {slice: CGRect, remainder: CGRect} source
Together the fromEdge and atDistance parameters define a line (parallel to the specified edge of the rectangle and at the specified distance from that edge) that divides the rectangle into two component rectangles.
Params:
Name | Type | Attribute | Description |
atDistance | number | A distance from the rectangle side specified in the fromEdge parameter, defining the line along which to divide the rectangle. |
|
fromEdge | CGRectEdge | The side of the rectangle from which to measure the atDistance parameter, defining the line along which to divide the rectangle. |
public equalTo(rect2: CGRect): boolean source
Returns whether two rectangles are equal in size and position.
Params:
Name | Type | Attribute | Description |
rect2 | CGRect | The rectangle to compare this rectangle with. |
public initDictionaryRepresentation(dict: Map): void source
Creates a rectangle from a canonical dictionary representation.
Params:
Name | Type | Attribute | Description |
dict | Map | A dictionary containing x, y, width, and height values for the rectangle to create, in the format used by the dictionaryRepresentation property. |
Return:
void |
public insetBy(dx: number, dy: number): CGRect source
The rectangle is standardized and then the inset parameters are applied. If the resulting rectangle would have a negative height or width, a null rectangle is returned.
Params:
Name | Type | Attribute | Description |
dx | number | 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. |
|
dy | number | 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. |
public intersection(r2: CGRect): CGRect source
Both rectangles are standardized prior to calculating the intersection.
Params:
Name | Type | Attribute | Description |
r2 | CGRect | Another rectangle to intersect with this rectangle. |
public intersects(rect2: CGRect): boolean source
Returns whether two rectangles intersect.
Params:
Name | Type | Attribute | Description |
rect2 | CGRect | The rectangle to test for intersection with this rectangle. |
public offsetBy(dx: number, dy: number): CGRect source
Returns a rectangle with an origin that is offset from that of the source rectangle.
public union(r2: CGRect): CGRect source
Both rectangles are standardized prior to calculating the union. If either of the rectangles is a null rectangle, a copy of the other rectangle is returned (resulting in a null rectangle if both rectangles are null). Otherwise a rectangle that completely contains the source rectangles is returned.
Params:
Name | Type | Attribute | Description |
r2 | CGRect | Another rectangle to be combined with this rectangle. |