Rectangle

public struct Rectangle : Hashable

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

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

    Declaration

    Swift

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

    Declaration

    Swift

    public var size: Size
  • x

    The x-coordinate of the origin.

    Declaration

    Swift

    @inlinable
    public var x: Float { get }
  • y

    The y-coordinate of the origin.

    Declaration

    Swift

    @inlinable
    public var y: Float { get }
  • The width of a rectangle.

    Declaration

    Swift

    @inlinable
    public var width: Float { get }
  • The height of a rectangle.

    Declaration

    Swift

    @inlinable
    public var height: Float { get }
  • The center point of the rectangle.

    Declaration

    Swift

    @inlinable
    public var center: Point { get }
  • The x-coordinate that establishes the center of a rectangle.

    Declaration

    Swift

    @inlinable
    public var midX: Float { get }
  • The y-coordinate that establishes the center of the rectangle.

    Declaration

    Swift

    @inlinable
    public var midY: Float { get }
  • The largest value of the x-coordinate for the rectangle.

    Declaration

    Swift

    @inlinable
    public var maxX: Float { get }
  • The largest value of the y-coordinate for the rectangle.

    Declaration

    Swift

    @inlinable
    public var maxY: Float { get }
  • Creates a rectangle with the specified origin and size.

    Declaration

    Swift

    @inlinable
    public init(origin: Point, size: Size)

    Parameters

    origin

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

    size

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

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

    Declaration

    Swift

    @inlinable
    public init(x: Float, y: Float, width: Float, height: Float)

    Parameters

    x

    The x-coordinate of the origin.

    y

    The y-coordinate of the origin.

    width

    The width of a rectangle.

    height

    The height of a rectangle.

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

    Declaration

    Swift

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

    Parameters

    x

    The x-coordinate of the origin.

    y

    The y-coordinate of the origin.

    width

    The width of a rectangle.

    height

    The height of a rectangle.

  • Declaration

    Swift

    public var debugDescription: String { get }