@@ -30,6 +30,12 @@ public struct Rect {
30
30
31
31
// MARK - Special Values
32
32
33
+ /// A rectangle that has infinite extent.
34
+ public static var infinite : Rect {
35
+ Rect ( x: - . leastNormalMagnitude, y: - . leastNormalMagnitude,
36
+ width: . greatestFiniteMagnitude, height: . greatestFiniteMagnitude)
37
+ }
38
+
33
39
/// The null rectangle, representing an invalid value.
34
40
public static var null : Rect {
35
41
Rect ( x: . greatestFiniteMagnitude, y: . greatestFiniteMagnitude,
@@ -41,6 +47,11 @@ public struct Rect {
41
47
Rect ( x: 0 , y: 0 , width: 0 , height: 0 )
42
48
}
43
49
50
+ /// Creates a rectangle with origin (0,0) and size (0,0).
51
+ public init ( ) {
52
+ self = . zero
53
+ }
54
+
44
55
// MARK - Basic Geometric Properties
45
56
46
57
/// A point that specifies the coordinates of the rectangle’s origin.
@@ -171,6 +182,11 @@ public struct Rect {
171
182
return self . size. height == 0 || self . size. width == 0 || self . isNull
172
183
}
173
184
185
+ /// Returns whether a rectangle is infinite.
186
+ public var isInfinite : Bool {
187
+ return self == . infinite
188
+ }
189
+
174
190
/// Returns whether the rectangle is equal to the null rectangle.
175
191
public var isNull : Bool {
176
192
return self == . null
0 commit comments