CGRect
has a very convenient built-in constant: CGRect.null
let aRect = ... //get rect from somewhere
CGRect.null.union(aRect) //is aRect
CGRect.null.intersection(aRect) //is CGRect.null
CGPath
doesn’t have anything like this, meaning you can’t do something like:
let bunchOfPaths = [...] //array of CGPaths
let unionPath = bunchOfPaths.reduce(CGPath.null, { $0.union($1) }) //union of all the paths
Nor can you use CGRect.null
to create the equivalent:
let nullRectPath = CGPath(rect: .null, transform: nil)
nullRectPath.isEmpty //false (?!)
let zeroRectPath = CGPath(rect: .zero, transform: nil)
nullRectPath.union(zeroRectPath) == zeroRectPath //false
Creating an empty path isn’t helpful either:
let emptyPath = zeroRectPath.subtracting(zeroRectPath)
emptyPath.isEmpty //true
emptyPath.union(zeroRectPath) == zeroRectPath //false (!!)
Does a CGPath
with the properties described (its union with any CGPath
is the other path, its intersection with any CGPath
is itself) exist, and if so, how can it be created?