AdditiveRectangleType

public protocol AdditiveRectangleType : RectangleType where Self.Vector : VectorAdditive

Protocol refining RectangleType with VectorAdditive extensions.

  • Returns a copy of this rectangle with its location offset by a given Vector amount.

    Declaration

    Swift

    func offsetBy(_ vector: Vector) -> Self
  • Returns a copy of this rectangle with its size increased by a given Vector amount.

    Declaration

    Swift

    func resizedBy(_ vector: Vector) -> Self
  • vertices Default implementation

    Returns a list of vertices corresponding to the extremes of this rectangle.

    Precondition

    Currently limited to vectors with < 64 scalars.

    Order of vertices in the result is not defined.

    Default Implementation

    Returns a list of vertices corresponding to the extremes of this rectangle.

    Order of vertices in the result is not defined.

    Precondition

    Currently limited to vectors with < 64 scalars.

    Declaration

    Swift

    var vertices: [Vector] { get }

Available where Self: ConstructableRectangleType

  • offsetBy(_:) Default implementation

    Default Implementation

    Returns a copy of this rectangle with its location offset by a given Vector amount.

    let rect = Rectangle2D(x: 20, y: 30, width: 50, height: 50)
    
    let result = rect.offsetBy(.init(x: 5, y: 10))
    
    print(result) // Prints "(location: (x: 25, y: 40), size: (width: 50, height: 50))"
    

    Declaration

    Swift

    func offsetBy(_ vector: Vector) -> Self
  • resizedBy(_:) Default implementation

    Default Implementation

    Returns a copy of this rectangle with its size increased by a given Vector amount.

    let rect = Rectangle2D(x: 20, y: 30, width: 50, height: 50)
    
    let result = rect.resizedBy(.init(x: 10, y: 20))
    
    print(result) // Prints "(location: (x: 20, y: 30), size: (width: 60, height: 70))"
    

    Declaration

    Swift

    func resizedBy(_ vector: Vector) -> Self