Link Search Menu Expand Document

Rect

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

public struct Rect 

Inheritance

CustomDebugStringConvertible, Equatable

Initializers

init(origin:size:)

Creates a rectangle with the specified origin and size.

public init(origin: Point, size: Size) 

init(x:y:width:height:)

Creates a rectangle with coordinates and dimensions specified as floating-point values.

public init(x: Double, y: Double, width: Double, height: Double) 

init(x:y:width:height:)

Creates a rectangle with coordinates and dimensions specified as integer values.

public init(x: Int, y: Int, width: Int, height: Int) 

init()

Creates a rectangle with origin (0,0) and size (0,0).

public init() 

Properties

infinite

A rectangle that has infinite extent.

public static var infinite: Rect 

null

The null rectangle, representing an invalid value.

public static var null: Rect 

zero

The rectangle whose origin and size are both zero.

public static var zero: Rect 

origin

A point that specifies the coordinates of the rectangle’s origin.

public var origin: Point

size

A size that specifies the height and width of the rectangle.

public var size: Size

height

Returns the height of a rectangle.

public var height: Double 

width

Returns the width of a rectangle.

public var width: Double 

minX

Returns the smallest value for the x-coordinate of the rectangle.

public var minX: Double 

midX

Returns the x-coordinate that establishes the center of a rectangle.

public var midX: Double 

maxX

Returns the largest value of the x-coordinate for the rectangle.

public var maxX: Double 

minY

Returns the smallest value for the y-coordinate of the rectangle.

public var minY: Double 

midY

Returns the y-coordinate that establishes the center of the rectangle.

public var midY: Double 

maxY

Returns the largest value for the y-coordinate of the rectangle.

public var maxY: Double 

standardized

Returns a rectangle with a positive width and height.

public var standardized: Rect 

integral

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

public var integral: Rect 

isEmpty

Returns whether a rectangle has zero width or height, or is a null rectangle.

public var isEmpty: Bool 

isInfinite

Returns whether a rectangle is infinite.

public var isInfinite: Bool 

isNull

Returns whether the rectangle is equal to the null rectangle.

public var isNull: Bool 

debugDescription

public var debugDescription: String 

Methods

applying(_:)

Applies an affine transform to a rectangle.

public func applying(_ transform: AffineTransform) -> Rect 

insetBy(dx:dy:)

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

public func insetBy(dx: Double, dy: Double) -> Rect 

offsetBy(dx:dy:)

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

public func offsetBy(dx: Double, dy: Double) -> Rect 

union(_:)

Returns the smallest rectangle that contains the two source rectangles.

public func union(_ rect: Rect) -> Rect 

intersection(_:)

Returns the intersection of two rectangles.

public func intersection(_ rect: Rect) -> Rect 

intersects(_:)

Returns whether two rectangles intersect.

public func intersects(_ rect: Rect) -> Bool 

contains(_:)

Returns whether a rectangle contains a specified point.

public func contains(_ point: Point) -> Bool 

contains(_:)

Returns whether the first rectangle contains the second rectangle.

public func contains(_ rect2: Rect) -> Bool 

Operators

==

public static func == (lhs: Rect, rhs: Rect) -> Bool