DivisibleRectangleType
public protocol DivisibleRectangleType : AdditiveRectangleType where Self.Vector : VectorDivisible
Protocol refining RectangleType with VectorDivisible extensions.
Divisible rectangle types can be split into smaller rectangles, as well as be inflated/inset.
-
Gets the center point of this rectangle.
Declaration
Swift
var center: Vector { get } -
Initializes a new rectangle centered around a given point encompassing a given size.
Declaration
Swift
init(center: Vector, size: Vector) -
Returns a new rectangle which is an inflated version of this rectangle (i.e. bounds are larger by
size, but center remains the same).Equivalent to insetting the rectangle by a negative amount.
Seealso
insetBy(_:)Declaration
Swift
func inflatedBy(_ size: Vector) -> Self -
Returns a new rectangle which is an inset version of this rectangle (i.e. bounds are smaller by
size, but center remains the same).Equivalent to inflating the rectangle by a negative amount.
Seealso
inflatedBy(_:)Declaration
Swift
func insetBy(_ size: Vector) -> Self -
Returns a new rectangle with the same size as the current instance, where the center of the boundaries lay on
center.Declaration
Swift
func movingCenter(to center: Vector) -> Self -
Returns a new rectangle with its bounds scaled around a given center point by a given factor.
Declaration
Swift
func scaledBy(_ factor: Vector.Scalar, around center: Vector) -> Self -
Returns a new rectangle with the same center point as the current instance, where the size of the rectangle is multiplied by a given numerical factor.
Declaration
Swift
func scaledAroundCenterBy(_ factor: Vector.Scalar) -> Self -
Subdivides this rectangle into
2 ^ D(whereDis the dimensional size ofSelf.Vector) rectangles that occupy the same area as this rectangle but subdivide it into equally-sized rectangles.The ordering of the subdivisions is not defined.
Declaration
Swift
func subdivided() -> [Self]
-
centerXExtension methodGets or sets the center X position of this Rectangle.
Declaration
Swift
var centerX: Vector.Scalar { get set } -
centerYExtension methodGets or sets the center Y position of this Rectangle.
Declaration
Swift
var centerY: Vector.Scalar { get set } -
inflatedBy(x:Extension methody: ) Returns a Rectangle which is an inflated version of this Rectangle (i.e. bounds are larger by
size, but center remains the same).Declaration
Swift
func inflatedBy(x: Vector.Scalar, y: Vector.Scalar) -> Self -
insetBy(x:Extension methody: ) Returns a Rectangle which is an inset version of this Rectangle (i.e. bounds are smaller by
size, but center remains the same).Declaration
Swift
func insetBy(x: Vector.Scalar, y: Vector.Scalar) -> Self -
movingCenter(toX:Extension methody: ) Returns a new Rectangle with the same width and height as the current instance, where the center of the boundaries lay on the coordinates composed of
[x, y].Declaration
Swift
func movingCenter(toX x: Vector.Scalar, y: Vector.Scalar) -> Self
-
centerDefault implementationDefault Implementation
Gets or sets the center point of this rectangle.
When assigning the center of a rectangle, the size remains unchanged while the coordinates of the vectors change to position the rectangle’s center on the provided coordinates.
Declaration
Swift
var center: Vector { get set } -
inflatedBy(_:Default implementation) Default Implementation
Returns a rectangle which is an inflated version of this rectangle (i.e. bounds are larger by
size, but center remains the same).Equivalent to insetting the rectangle by a negative amount.
Seealso
insetBy(_:)Declaration
Swift
func inflatedBy(_ size: Vector) -> Self -
insetBy(_:Default implementation) Default Implementation
Returns a rectangle which is an inset version of this rectangle (i.e. bounds are smaller by
size, but center remains the same).Equivalent to inflating the rectangle by a negative amount.
Seealso
inflatedBy(_:)Declaration
Swift
func insetBy(_ size: Vector) -> Self -
movingCenter(to:Default implementation) Default Implementation
Returns a new rectangle with the same size as the current instance, where the center of the boundaries lay on
center.Declaration
Swift
func movingCenter(to center: Vector) -> Self -
scaledBy(_:Default implementationaround: ) Default Implementation
Returns a new rectangle with the same center point as the current instance, where the size of the rectangle is multiplied by a given numerical factor.
Declaration
Swift
func scaledBy(_ factor: Vector.Scalar, around center: Vector) -> Self -
scaledAroundCenterBy(_:Default implementation) Default Implementation
Returns a new rectangle with the same center point as the current instance, where the size of the rectangle is multiplied by a given numerical factor.
Declaration
Swift
func scaledAroundCenterBy(_ factor: Vector.Scalar) -> Self
-
subdivided()Default implementationDefault Implementation
Subdivides this rectangle into
2 ^ D(whereDis the dimensional size ofSelf.Vector) rectangles that occupy the same area as this rectangle but subdivide it into equally-sized rectangles.The ordering of the subdivisions is not defined.
Declaration
Swift
@inlinable public func subdivided() -> [Self]