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
RectBase
instance.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
RectBase
with the given values.Declaration
Swift
public init(x: VectorType, y: VectorType, width: VectorType, height: VectorType)
Parameters
x
The first component of the rect.
y
The second component of the rect.
z
The third component of the rect.
w
The fourth component of the rect.
-
Provides access to the underlying components of this instance.
Declaration
Swift
public subscript(index: Int) -> VectorType { get set }
Parameters
index
The index of the component to access.
Return Value
The component at the given index.
-
The unit rectangle in the
VectorType
space. 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>) -> Bool
Parameters
point
The given point.
Return Value
true
if this rect containspoint
,false
otherwise.
-
Returns a point inside the rectangle by interpolating
point
, starting atorigin
and ending atorigin + size
.Parameters
point
The point representing a percent to interpolate by. The components of
point
must be betweenVectorType.zero
andVectorType.one
.