[app] Set initial values of parameters based on what's in UserDefaults

This commit is contained in:
Eryn Wells 2017-08-16 21:56:41 -07:00
parent 88c97d4bf5
commit 6c0342fb78

View file

@ -13,9 +13,13 @@ import MetaballsKit
class ViewController: NSViewController, RendererDelegate { class ViewController: NSViewController, RendererDelegate {
private static func defaultParameters() -> Parameters { private static func defaultParameters() -> Parameters {
var p = Parameters() var p = Parameters()
p.colorStyle = .gradient2Horizontal let defaults = UserDefaults.standard
p.color0 = Float4(0.50, 0.79, 1, 1) let style = defaults.colorStyle ?? .gradient2Horizontal
p.color1 = Float4(0.88, 0.50, 1, 1) p.colorStyle = style
let color0 = defaults.color0 ?? Float4(0.50, 0.79, 1, 1)
p.color0 = color0
let color1 = defaults.color1 ?? Float4(0.88, 0.50, 1, 1)
p.color1 = color1
return p return p
} }