RectBase
public struct RectBase<VectorType> where VectorType : Addable
A 4-dimensional vector representing a rectangle. A rectangle contains an origin (point) and dimensions (size).
The dimensions of size must be non-negative.
-
The number of components in a
RectBaseinstance.Declaration
Swift
public static var numberOfComponents: Int { get }
-
The values of the vector.
Declaration
Swift
public private(set) var components: [VectorType] -
The x coordinate of the origin of the rect (the first component).
Declaration
Swift
public var x: VectorType { get set } -
The y coordinate of the origin of the rect (the second component).
Declaration
Swift
public var y: VectorType { get set } -
The width of the rect (the third component).
Declaration
Swift
public var width: VectorType { get set } -
The height of the rect (the fourth component).
Declaration
Swift
public var height: VectorType { get set } -
The origin of the rect (the first two components).
Declaration
Swift
public var origin: PointBase<VectorType> { get set } -
The size of the rect (the last two components).
Declaration
Swift
public var size: SizeBase<VectorType> { get set } -
The minimum value of x for this rect.
Declaration
Swift
public var minX: VectorType { get } -
The minimum value of y for this rect.
Declaration
Swift
public var minY: VectorType { get } -
The maximum value of x for this rect.
Declaration
Swift
public var maxX: VectorType { get } -
The maximum value of y for this rect.
Declaration
Swift
public var maxY: VectorType { get } -
Initialiaze the zero rect.
Declaration
Swift
public init() -
Initializes a
RectBasewith the given values.Declaration
Swift
public init(x: VectorType, y: VectorType, width: VectorType, height: VectorType)Parameters
xThe first component of the rect.
yThe second component of the rect.
zThe third component of the rect.
wThe fourth component of the rect.
-
Provides access to the underlying components of this instance.
Declaration
Swift
public subscript(index: Int) -> VectorType { get set }Parameters
indexThe index of the component to access.
Return Value
The component at the given index.
-
The unit rectangle in the
VectorTypespace. Has origin zero and size one.Declaration
Swift
public static var unitRect: RectBase<VectorType> { get }
-
Determines if this rect contains the given point.
Declaration
Swift
public func contains(point: PointBase<VectorType>) -> BoolParameters
pointThe given point.
Return Value
trueif this rect containspoint,falseotherwise.
-
Returns a point inside the rectangle by interpolating
point, starting atoriginand ending atorigin + size.Parameters
pointThe point representing a percent to interpolate by. The components of
pointmust be betweenVectorType.zeroandVectorType.one.
RectBase Structure Reference