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
rectThe 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
xThe x-coordinate of the top left corner of the rectangle.
yThe y-coordinate of the top left corner of the rectangle.
widthThe width of the rectangle.
heightThe height of the rectangle.
Return Value
The newly created Rect.
-
Converts this Rect to a CGRect.
Declaration
Swift
public func toCGRect() -> CGRectReturn 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() -> DoubleReturn 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() -> DoubleReturn 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() -> DoubleReturn 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() -> DoubleReturn Value
The y-coordinate of the bottom right corner.
-
Gets the top left corner of this Rect.
Declaration
Swift
public func getLocation() -> PointReturn Value
The coordinate of the top left corner.
-
Gets the bottom right corner of this Rect.
Declaration
Swift
public func getBottomRight() -> PointReturn 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
dxThe value with which the width is inflated.
dyThe 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) -> RectParameters
rectThe Rect whose width and height are inflated.
dxThe value with which the width is inflated.
dyThe 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) -> RectParameters
sA 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) -> RectParameters
leftThe x-coordinate of the top left corner of the new Rect.
topThe y-coordinate of the top left corner of the new Rect.
rightThe x-coordinate of the bottom right corner of the new Rect.
bottomThe 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) -> RectParameters
aThe first rect to unite.
bThe 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!) -> RectParameters
rectThe 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) -> BoolParameters
rThe 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) -> BoolParameters
rThe 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
dxThe value with which the x-coordinate of the top left corner is corrected.
dyThe 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) -> RectReturn 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
Rect Structure Reference