import math


def hsv_to_rgb (h, s, v, a = 1):
  """
  Convert hue, saturation, value (0..1) to RGBA.
  """
  f,i = math.modf(h * 6)
  p = v * (1-s)
  q = v * (1-f*s)
  t = v * (1-(1-f)*s)
  i %= 6
  if i == 0:   r,g,b = v,t,p 
  elif i == 1: r,g,b = q,v,p 
  elif i == 2: r,g,b = p,v,t 
  elif i == 3: r,g,b = p,q,v 
  elif i == 4: r,g,b = t,p,v 
  else: r,g,b = v,p,q 

  return [r,g,b,a]