Rect

public struct Rect : CustomStringConvertible, Equatable

A structure that contains integer location and dimensions of a rectangle. For our purposes, the the origin is in the upper-left corner and the rectangle extends towards the lower-right corner

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

    Declaration

    Swift

    public let origin: Point
  • A size that specifies the height and width of the rectangle.

    Declaration

    Swift

    public let size: Size
  • Returns the width of a rectangle.

    Declaration

    Swift

    public var width: Int { get }
  • Returns the height of a rectangle.

    Declaration

    Swift

    public var height: Int { get }
  • Returns the smallest value for the x-coordinate of the rectangle.

    Declaration

    Swift

    public var minX: Int { get }
  • Returns the smallest value for the y-coordinate of the rectangle.

    Declaration

    Swift

    public var minY: Int { get }
  • Returns the x- coordinate that establishes the center of a rectangle.

    Declaration

    Swift

    public var midX: Int { get }
  • Returns the y-coordinate that establishes the center of the rectangle.

    Declaration

    Swift

    public var midY: Int { get }
  • Returns the largest value of the x-coordinate for the rectangle.

    Declaration

    Swift

    public var maxX: Int { get }
  • Returns the largest value for the y-coordinate of the rectangle.

    Declaration

    Swift

    public var maxY: Int { get }
  • A textual representation of the rectangle’s origin and size values.

    Declaration

    Swift

    public var description: String { get }
  • Creates a rectangle with the specified origin and size.

    Declaration

    Swift

    public init(origin: Point, size: Size)
  • Creates a rectangle with coordinates and dimensions specified as floating-point values.

    Declaration

    Swift

    public init(x: Int, y: Int, width: Int, height: Int)
  • Returns whether the rectangle contains the point.

    Declaration

    Swift

    public func contains(_ loc: Point) -> Bool
  • Returns whether the rectangle contains the other rectangle.

    Declaration

    Swift

    public func contains(_ other: Rect) -> Bool
  • The rectangle whose origin and size are both zero.

    Declaration

    Swift

    public static let zero: Rect