title: How to draw a gradient color wheel using CAGradientLayer?
body: <p>I got some reference from these links- </p>
  
  <ul>
  <li><p><a href="https://stackoverflow.com/questions/4897181/what-is-the-algorithm-behind-a-color-wheel">What is the Algorithm behind a color wheel?</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/4235072/math-behind-the-colour-wheel">Math behind the Colour Wheel</a></p></li>
  <li><p><a href="http://www.tigercolor.com/color-lab/color-theory/color-theory-intro.htm" rel="nofollow noreferrer">Basic color schemes</a></p></li>
  <li><p><a href="https://stackoverflow.com/questions/41437581/how-to-fill-a-bezier-path-with-gradient-color">How to fill a bezier path with gradient color</a></p></li>
  </ul>
  
  <p>I have gone through the concept of "HSV colour space". But I want to draw a color wheel using RGB with the help of <code>CAGradientLayer</code>.</p>
  
  <p>Here is the code snippet of making a color wheel by using simple RGB color array and <code>UIBezierPath</code> - </p>
  
  <pre><code>func drawColorWheel()
  {
      context?.saveGState()
  
      range = CGFloat(100.00 / CGFloat(colorArray.count))
  
      for k in 0 ..&lt; colorArray.count
      {
  
          drawSlice(startPercent: CGFloat(k) * range, endPercent: CGFloat(CGFloat(k + 1) * range), color: colorArray.object(at: k) as! UIColor)
      }
  
      context?.restoreGState()
  }
  
  func drawSlice(startPercent: CGFloat, endPercent: CGFloat, color: UIColor)
  {        
      let startAngle = getAngleAt(percentage: startPercent)
      let endAngle = getAngleAt(percentage: endPercent)
  
      let path =  getArcPath(startAngle: startAngle, endAngle: endAngle)
      color.setFill()
      path.fill()
  }
  </code></pre>
  
  <p>Where <code>getAngleAt()</code> and <code>getArcPath()</code> are the private functions to draw the path with an angle.</p>
  
  <p>Here is the final output of my code -<a href="https://i.stack.imgur.com/0KuPr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0KuPr.png" alt="color wheel"></a></p>
  
  <p>Now, my question is the how to give these colors a gradient effect so that each colors mix up with gradient color layer?</p>