title: How to get index in an array from random rotation degrees?
body: <p>I'm new to SwiftUI and I'm still working on my spinning wheel. For now I wanna show people the results on screen by Text(&quot;(Array[index])&quot;). the question is i know the random rotation degrees but i don't know how to transfer it to that &quot;result angles&quot; index :P ,Any help I will appreciate it !
  <a href="https://i.stack.imgur.com/CMmc5.png" rel="nofollow noreferrer">enter image description here</a></p>
  <p>I use Path to draw the wheel:</p>
  <pre><code>var slices: Array&lt;OneChance.OneChanceData&gt; {
  
      let sum = Double(newChoices.count)
  
      var endDeg: Double = 0.0
  
      var tempSlices: [OneChance.OneChanceData] = []
  
      for (color, text) in zip(colors, newChoices) {
  
          let degrees: Double = Double(360 / sum)
  
          
  
          tempSlices.append(OneChance.OneChanceData(startAngle: Angle(degrees: endDeg), endAngle: Angle(degrees: endDeg + degrees), text: text, color: color))
  
          endDeg += degrees
  
      }
  
      return tempSlices
  
  }
  </code></pre>
  <p>The wheel view like:</p>
  <pre><code>ForEach(0..&lt;chanceVM.newChoices.count) { i in
  
                      EachSliceView(chanceData: self.chanceVM.slices[i])
  
                  }
  </code></pre>
  <p>I use onTapGesture to get random wheel spinning degrees:</p>
  <pre><code>.onTapGesture {
  
                          self.chanceVM.showResult = false
  
                          self.chanceVM.rotateDegree = 0.0
  
                          playSound(sound: &quot;wheelSpinning13s&quot;, type: &quot;mp3&quot;)
  
                          self.chanceVM.allowToTapAgain = false
  
                          withAnimation(Animation.easeOut(duration: 13.0)) {
  
                              self.chanceVM.rotateDegree = Double.random(in: 5400.0...7200.0)
  
                          }
  
                          print(&quot;\(chanceVM.rotateDegree)&quot;)
  
                          print(&quot;\((Int(chanceVM.rotateDegree) % 360))&quot;)
  
                          print(&quot;\((Int(chanceVM.rotateDegree) % 360)/(360/chanceVM.newChoices.count))&quot;)
  
                          self.chanceVM.delayText()
  
                          self.chanceVM.delayTap()
  
                      }
  </code></pre>
  <p>So how can i get the index after random spinning degrees?</p>