title: Generate color list between two colors in HSV
body: <p>Lets say i have two RGB colors (255,0,0) and (0,0,255), I also require 100 colors that are between them. How would i generate a list of HSV color values based on a number of required steps?</p>
  
  <p>Currently using python 3 i created this code:</p>
  
  <pre><code>def lerpcolourhsv(rgb1, rgb2, steps):
  #convert rgb to hsv
  hsv1 = colorsys.rgb_to_hsv(rgb1[0], rgb1[1], rgb1[2])
  hsv2 = colorsys.rgb_to_hsv(rgb2[0], rgb2[1], rgb2[2])
  
  # calculate distance between two hue numbers, divide by number of steps. then loop to generate
  rgb_colour_list = []
  dist = cachefunc.numdistance(hsv1[0], hsv2[0])
  step_value = dist / steps
  hue = hsv1[0]
  
  for x in range(steps):
      hsv_tupel = (hue, 1, 1)
      hue += step_value
      rgb = colorsys.hsv_to_rgb(hsv_tupel[0], hsv_tupel[1], hsv_tupel[2])
      rgb = (round(rgb[0] * 255), round(rgb[1] * 255), round(rgb[2] * 255), round(255)) #0-1 to 0-255
      rgb_colour_list.append(rgb)
  
  return rgb_colour_list
  </code></pre>
  
  <p>The only problem with the code above is that it loops through multiple different colors for example: red -> orange -> yellow -> green -> cyan -> blue</p>
  
  <p>I would like a function that instead produces results more similar to this:
  <a href="https://i.stack.imgur.com/2QzXC.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2QzXC.jpg" alt="red to blue color gradient"></a></p>
  
  <p>As can be seen, this gradient produces a more expected result of red -> purple -> blue </p>
  
  <p>I tried making a function that interpolates using individual rgb channel values, this gave a more similar result however the perceived brightness and saturation of the colors were off so i am trying to do this in hsv color space.</p>
  
  <p>Can anyone create a function or explain how to achieve the gradient above using the hsv color space?</p>