[saver] Add balls to the field
This commit is contained in:
parent
bdf0d0b7c5
commit
c171011c96
1 changed files with 14 additions and 0 deletions
|
@ -63,6 +63,11 @@ public class MetaballsSaverView: ScreenSaverView, RendererDelegate {
|
|||
])
|
||||
renderer.delegate = self
|
||||
}
|
||||
|
||||
for _ in 1...10 {
|
||||
addBallWithRandomRadius()
|
||||
}
|
||||
|
||||
super.startAnimation()
|
||||
}
|
||||
|
||||
|
@ -80,6 +85,15 @@ public class MetaballsSaverView: ScreenSaverView, RendererDelegate {
|
|||
return window
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func addBallWithRandomRadius() {
|
||||
let base = UInt32(bounds.width * 0.05)
|
||||
let variance = UInt32(base * 2)
|
||||
let r = Float(base + arc4random_uniform(variance))
|
||||
field.add(ballWithRadius: r)
|
||||
}
|
||||
|
||||
// MARK: - RendererDelegate
|
||||
|
||||
public var renderSize: Size {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue