@@ -23,9 +23,22 @@ class ViewController: UIViewController, MetaballDataSource {
2323 let recognizer = UIPanGestureRecognizer(target: self, action: "handlePan:")
2424 view.addGestureRecognizer(recognizer)
2525
26− let metaballs = [CGPoint(x: 70, y: 70), CGPoint(x: 270, y: 70), CGPoint(x: 270, y: 470), CGPoint(x: 70, y: 470)].map {
27− Metaball(position: $0)
28− }
26+ let lowX = screenWidth / 3
27+ let highX = screenWidth - lowX
28+ let lowY = screenHeight / 4
29+ let highY = screenHeight - lowY
30+ let positions =
31+ [CGPoint(x: lowX, y: lowY),
32+ CGPoint(x: highX, y: lowY),
33+ CGPoint(x: highX, y: highY),
34+ CGPoint(x: lowX, y: highY)]
35+ let colors =
36+ [UIColor(red255: 90, green: 170, blue: 170, alpha: 1.0),
37+ UIColor(red255: 90, green: 170, blue: 170, alpha: 1.0),
38+ UIColor(red255: 110, green: 220, blue: 220, alpha: 1.0),
39+ UIColor(red255: 250, green: 235, blue: 50, alpha: 1.0)]
40+ let metaballs = zip(positions, colors).map { Metaball(position: $0.0, color: $0.1) }
41+
2942 metaballGraph = Graph(vertices: metaballs)
3043 metaballGraph.addEdge(0, 1)
3144 metaballGraph.addEdge(0, 3)
@@ -104,18 +117,3 @@ class ViewController: UIViewController, MetaballDataSource {
104117 }
105118
106119}
107−
108−class Metaball: UIView {
109−
110− init(position: CGPoint) {
111− super.init(frame: CGRect.zero)
112−
113− size = CGSize(50)
114− middle = position
115− backgroundColor = UIColor(randomFlatColorOfShadeStyle: .Light)
116− }
117−
118− required init?(coder aDecoder: NSCoder) {
119− super.init(coder: aDecoder)
120− }
121−}