@@ -27,7 +27,7 @@ class GameScene: SKScene {
2727// removeAllChildren()
2828 let totalPath = UIBezierPath ( )
2929
30- DispatchQueue . global ( qos: . userInteractive) . async { [ unowned self] in
30+ // DispatchQueue.global(qos: .userInteractive).async { [unowned self] in
3131 self . diagram. clear ( )
3232 self . fs. compute (
3333 sites: sites,
@@ -42,11 +42,11 @@ class GameScene: SKScene {
4242 var finish = false
4343 while !finish {
4444
45- if he!. toSegment ( ) !. length ( ) < 1.0 {
46- he = he? . next
47- finish = he === cell. outerComponent
48- continue
49- }
45+ // if he!.toSegment()!.length() < 1.0 {
46+ // he = he?.next
47+ // finish = he === cell.outerComponent
48+ // continue
49+ // }
5050
5151 let o = he!. origin!
5252 points. append ( o)
@@ -56,21 +56,30 @@ class GameScene: SKScene {
5656 finish = he === cell. outerComponent
5757 }
5858
59+ // let hullVertices = points.map { $0.cgPoint }
60+ // for i in 0..<hullVertices.count {
61+ // if i == 0 {
62+ // totalPath.move(to: hullVertices[i])
63+ // } else { totalPath.addLine(to: hullVertices[i])}
64+ // }
65+ // totalPath.close()
66+
5967 let hullVertices = points. map { $0. cgPoint }
60- for i in 0 ..< hullVertices. count {
61- if i == 0 {
62- totalPath. move ( to: hullVertices [ i] )
63- } else { totalPath. addLine ( to: hullVertices [ i] ) }
68+
69+ for i in 0 ..< 1 {
70+ let paddedHull = paddedPolygon ( hullVertices, padding: CGFloat ( - i) * 10 )
71+ if let path = UIBezierPath . roundedCornersPath ( paddedHull, 10 ) {
72+ totalPath. append ( path)
73+ }
6474 }
65- totalPath. close ( )
6675 }
6776
68- DispatchQueue . main. async {
77+ // DispatchQueue.main.async {
6978 self . diagramNode. path = totalPath. cgPath
7079 self . diagramNode. strokeColor = UIColor . black
7180 self . diagramNode. fillColor = . clear
72- }
73- }
81+ // }
82+ // }
7483 }
7584
7685 override func didMove( to view: SKView ) {
@@ -128,17 +137,18 @@ class GameScene: SKScene {
128137
129138
130139 var hexLike : [ Site ] {
131- var num = 5
140+ let num = 5
132141 let step : Double = 50
133142 var res = [ Site] ( )
134143 for i in 0 ..< num {
135- for j in 0 ..< num {
144+ for j in 0 ..< 3 {
136145 res. append (
137146 Site (
138147 x: Double ( i) * step + Double( j) * step / 2 + 200 ,
139148 y: Double ( j) * step + 200
140149 )
141150 )
151+ print ( res. last!)
142152 }
143153 }
144154 return res
@@ -150,8 +160,9 @@ class GameScene: SKScene {
150160 func touchMoved( toPoint pos : CGPoint ) {
151161 let spriteAtPoint = atPoint ( pos)
152162 if spriteAtPoint != diagramNode {
153- atPoint ( pos) . position = pos
163+ atPoint ( pos) . position = CGPoint ( x : pos. x . rounded ( ) , y : pos . y . rounded ( ) )
154164 }
165+ redraw ( Set < Site > ( balls. map { $0. position. point } ) )
155166 }
156167
157168 func touchUp( atPoint pos : CGPoint ) {
@@ -179,7 +190,7 @@ class GameScene: SKScene {
179190 }
180191
181192 override func update( _ currentTime: TimeInterval ) {
182- redraw ( Set < Site > ( balls. map { $0. position. point } ) )
193+ // redraw(Set<Site>(balls.map { $0.position.point }))
183194 }
184195}
185196
0 commit comments