Home Reference Source Repository
public class | source

CGRect

A structure that contains the location and dimensions of a rectangle.

See:

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

applying(t: CGAffineTransform): CGRect

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

Creates a rectangle from a canonical dictionary representation.

public

The rectangle is standardized and then the inset parameters are applied.

public

Both rectangles are standardized prior to calculating the intersection.

public

Returns whether two rectangles intersect.

public

lerp(r: CGRect, rate: number): CGRect

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

public static get zero: CGRect source

The zero rectangle is equivalent to one created by calling CGRect(x: 0, y: 0, width: 0, height: 0).

See:

Static Public Methods

public static rectWithXYWidthHeight(x: number, y: number, width: number, height: number): CGRect source

Params:

NameTypeAttributeDescription
x number
y number
width number
height number

Return:

CGRect

Public Constructors

public constructor(origin: CGPoint, size: CGSize) source

Creates a rectangle with the specified origin and size.

Params:

NameTypeAttributeDescription
origin CGPoint
size CGSize

See:

Public Members

public get debugDescription: string source

A textual representation of the rectangle's origin and size values.

See:

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.

See:

public get isEmpty: boolean source

An empty rectangle is either a null rectangle or a valid rectangle with zero height or width.

See:

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.

See:

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.

See:

public origin: * source

public size: * source

public get width: number source

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. That is, the result is never a negative number.

See:

Public Methods

public add(rect2: *): * source

Params:

NameTypeAttributeDescription
rect2 *

Return:

*

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:

NameTypeAttributeDescription
t CGAffineTransform

The affine transform to apply to the rect parameter.

Return:

CGRect

See:

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:

NameTypeAttributeDescription
point CGPoint

The point to examine.

Return:

boolean

See:

public copy(): * source

Return:

*

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:

NameTypeAttributeDescription
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.

Return:

{slice: CGRect, remainder: CGRect}

See:

public equalTo(rect2: CGRect): boolean source

Returns whether two rectangles are equal in size and position.

Params:

NameTypeAttributeDescription
rect2 CGRect

The rectangle to compare this rectangle with.

Return:

boolean

See:

public initDictionaryRepresentation(dict: Map): void source

Creates a rectangle from a canonical dictionary representation.

Params:

NameTypeAttributeDescription
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

See:

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:

NameTypeAttributeDescription
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.

Return:

CGRect

See:

public intersection(r2: CGRect): CGRect source

Both rectangles are standardized prior to calculating the intersection.

Params:

NameTypeAttributeDescription
r2 CGRect

Another rectangle to intersect with this rectangle.

Return:

CGRect

See:

public intersects(rect2: CGRect): boolean source

Returns whether two rectangles intersect.

Params:

NameTypeAttributeDescription
rect2 CGRect

The rectangle to test for intersection with this rectangle.

Return:

boolean

See:

public lerp(r: CGRect, rate: number): CGRect source

Params:

NameTypeAttributeDescription
r CGRect
rate number

Return:

CGRect

public offsetBy(dx: number, dy: number): CGRect source

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

Params:

NameTypeAttributeDescription
dx number

The offset value for the x-coordinate.

dy number

The offset value for the y-coordinate.

Return:

CGRect

See:

public sub(rect2: *): * source

Params:

NameTypeAttributeDescription
rect2 *

Return:

*

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:

NameTypeAttributeDescription
r2 CGRect

Another rectangle to be combined with this rectangle.

Return:

CGRect

See:

public zero(): * source

Return:

*