[MetaballsKit] Make Field.size public and filter balls that lie outside the size when it changed

This commit is contained in:
Eryn Wells 2017-07-30 15:53:10 -07:00
parent ee7bd497cc
commit fc57f865f2

View file

@ -29,7 +29,13 @@ public struct Ball {
}
public struct Field {
var size: CGSize
public var size: CGSize {
didSet {
// Remove balls that fall outside the new bounds.
balls = balls.filter { bounds.contains($0.bounds) }
}
}
private(set) var balls = [Ball]()
internal var bounds: CGRect {