Rect
public struct Rect : Equatable
Represents a rectangle.
-
Initializes a new instance of the Rect structure with location (0,0) and zero width and height.
Declaration
Swift
public init()
Return Value
the newly created Rect.
-
Initializes a new instance of the Rect structure from the specified CGRect.
Declaration
Swift
public init(rect: CGRect)
Parameters
rect
The CGRect that provides data for the new rectangle.
Return Value
The newly created Rect.
-
Initializes a new instance of the Rect structure with the specified location, width and height.
Declaration
Swift
public init(x: Double, y: Double, width: Double, height: Double)
Parameters
x
The x-coordinate of the top left corner of the rectangle.
y
The y-coordinate of the top left corner of the rectangle.
width
The width of the rectangle.
height
The height of the rectangle.
Return Value
The newly created Rect.
-
Converts this Rect to a CGRect.
Declaration
Swift
public func toCGRect() -> CGRect
Return Value
A CGRect that corresponds to this Rect.
-
Gets the x-coordinate of the top left corner of this Rect.
Declaration
Swift
public func left() -> Double
Return Value
The x-coordinate of the top left corner.
-
Gets the x-coordinate of the bottom right corner of this Rect.
Declaration
Swift
public func right() -> Double
Return Value
The x-coordinate of the bottom right corner.
-
Gets the y-coordinate of the top left corner of this Rect.
Declaration
Swift
public func top() -> Double
Return Value
The y-coordinate of the top left corner.
-
Gets the y-coordinate of the bottom right corner of this Rect.
Declaration
Swift
public func bottom() -> Double
Return Value
The y-coordinate of the bottom right corner.
-
Gets the top left corner of this Rect.
Declaration
Swift
public func getLocation() -> Point
Return Value
The coordinate of the top left corner.
-
Gets the bottom right corner of this Rect.
Declaration
Swift
public func getBottomRight() -> Point
Return Value
The coordinate of the bottom right corner of this Rect.
-
Inflates the width and height of this Rect with the specified values.
Declaration
Swift
public mutating func inflate(_ dx: Double, dy: Double)
Parameters
dx
The value with which the width is inflated.
dy
The value with which the height is inflated.
-
Inflates the width and height of the specified Rect with the specified values.
Declaration
Swift
public static func inflate(_ rect: Rect, dx: Double, dy: Double) -> Rect
Parameters
rect
The Rect whose width and height are inflated.
dx
The value with which the width is inflated.
dy
The value with which the height is inflated.
Return Value
The inflated Rect.
-
Creates a Rect from the specified string.
Declaration
Swift
public static func fromString(_ s: String) -> Rect
Parameters
s
A string that contains the x and y coordinates, width and height of the new Rect. The values are expected to be separated by commas.
Return Value
The newly created Rect.
-
Creates a new Rect with the specified top-left and bottom-right coordinates.
Declaration
Swift
public static func fromLTRB(_ left: Double, top: Double, right: Double, bottom: Double) -> Rect
Parameters
left
The x-coordinate of the top left corner of the new Rect.
top
The y-coordinate of the top left corner of the new Rect.
right
The x-coordinate of the bottom right corner of the new Rect.
bottom
The y-coordinate of the bottom right corner of the new Rect.
Return Value
The newly created Rect.
-
Returns the union of the specified Rect objects.
Declaration
Swift
public static func union(_ a: Rect!, b: Rect) -> Rect
Parameters
a
The first rect to unite.
b
The second rect to unite.
Return Value
A Rect that represents the union of the two rectangles.
-
Returns the union of this Rect with the specified Rect object.
Declaration
Swift
public func union(_ rect: Rect!) -> Rect
Parameters
rect
The Rect to unite.
Return Value
A Rect that represents the union of the this Rect and the specified Rect.
-
Checks if the specified Rect intersects within this Rect.
Declaration
Swift
public func intersectsWith(_ r: Rect) -> Bool
Parameters
r
The Rect to check.
Return Value
true if the specified Rect intersects with this Rect; otherwise false.
-
Checks if the specified Rect is contained within this Rect.
Declaration
Swift
public func contains(_ r: Rect) -> Bool
Parameters
r
The Rect to check.
Return Value
true if the specified Rect is inside this Rect; otherwise false.
-
Offsets the location of this Rect with the specified x and y values.
Declaration
Swift
public mutating func offset(_ dx: Double, dy: Double)
Parameters
dx
The value with which the x-coordinate of the top left corner is corrected.
dy
The value with which the y-coordinate of the top left corner is corrected.
-
Prints the top-left and bottom-right coordinates of this Rect.
Declaration
Swift
public func printMe()
-
Scales the width and height of this Rect with the specified amount. Note that the coordinates of the four corners of
the Rect change as well.Declaration
Swift
public func scaledRect(_ scale: Double) -> Rect
Return Value
The scaled Rect.
-
A double field for the x-coordinate of the top-left corner of this Rect.
Declaration
Swift
public var x: Double
-
A double field for the y-coordinate of the top-left corner of this Rect.
Declaration
Swift
public var y: Double
-
A double field for the width of this Rect.
Declaration
Swift
public var width: Double
-
A double field for the height of this Rect.
Declaration
Swift
public var height: Double