Structure
Rect
public struct Rect : Equatable
A Rect
represents a rectangle in a two-dimensional plane.
Relationships
Conforms To
Equatable
Initializers
init()
public init()
init(topLeft:size:)
public init(topLeft:Point=Point(), size:Size)
init(bottomLeft:size:)
public init(bottomLeft:Point, size:Size)
init(topRight:size:)
public init(topRight:Point, size:Size)
init(bottomRight:size:)
public init(bottomRight:Point, size:Size)
Properties
topLeft
public var topLeft : Point
The topLeft coordinate of the rect. This value is modifiable and will alter the position.
size
public var size : Size
The size of the rect. This value is modifiable.
zero
static public let zero
The rect at the origin with zero size.
left
public var left : Int
The coordinate along the x-axis at the left of rect. This value is modifiable and will alter only the left coordinate, thus, the size will change.
top
public var top : Int
The coordinate along the y-axis at the top of rect. This value is modifiable and will alter only the top coordinate, thus, the size will change.
right
public var right : Int
The coordinate along the x-axis at the right of rect. This value is modifiable and will alter only the right coordinate, thus, the size will change.
bottom
public var bottom : Int
The coordinate along the y-axis at the bottom of rect. This value is modifiable and will alter only the bottom coordinate, thus, the size will change.
width
public var width : Int
The width of the rectangle. This value is modifiable and will alter the right coodinate.
height
public var height : Int
The height of the rectangle. This value is modifiable and will alter the bottom coordinate.
topRight
public var topRight : Point
The topRight corner of the rectangle. This value is modifiable and will alter the position.
bottomLeft
public var bottomLeft : Point
The bottomLeft coordinate of the rect. This value is modifiable and will alter the position.
bottomRight
public var bottomRight : Point
The bottomRight coordinate of the rect. This value is modifiable and will alter the position.
centerX
public var centerX : Int
The center x-value coordinate of the rect. This value is modifiable and will alter the position along the x-coordinate.
centerY
public var centerY : Int
The center y-value coordinate of the rect. This value is modifiable and will alter the position along the y-coordinate.
center
public var center : Point
The center coordinate of the rect. This value is modifiable and will alter the position.
Methods
local(to:)
public func local(to origin:Rect) -> Rect
containment(target:)
public func containment(target:Point) -> ContainmentSet
containment(target:)
public func containment(target:Rect) -> ContainmentSet
unioned(with:)
public func unioned(with other:Rect) -> Rect
Union of this Rect
with the specified target Rect
Returns
A new Rect
exactly large enough to contain both rectangles
inflated(by:)
public func inflated(by change:Int) -> Rect
Returns a new rect expanded by the amount specified while preserving the center point (negative numbers reduce the dimensions)
Parameters
Name | Type | Description |
---|---|---|
change | Int |
The amount by which to increase each dimension |
Returns
The inflated rect
inflate(by:)
public mutating func inflate(by change:Int)
Expands the rect by the amount specified while preserving the center point (negative numbers reduce the dimensions)
Parameters
Name | Type | Description |
---|---|---|
change | Int |
The amount by which to increase all dimensions |
inflated(by:)
public func inflated(by change:Size) -> Rect
Returns a new rect expanded by the amount specified while preserving the center point (negative numbers reduce the dimensions)
Parameters
Name | Type | Description |
---|---|---|
change | Size |
The amount by which to increase each dimension |
Returns
The inflated rect
inflate(by:)
public mutating func inflate(by change:Size)
Expands the rect by the amount specified while preserving the center point (negative numbers reduce the dimensions)
Parameters
Name | Type | Description |
---|---|---|
change | Size |
The amount by which to increase each dimension |
Operators
==
static public func == (lhs:Rect, rhs:Rect) -> Bool
Equivalence operator for two Rect
s