 0, 255)
    g = r
    b = r

  -- Else, calculate color
  else
    -- Calculate subvalues
    H = math.abs(H) % 360 -- Put H in range [0, 360)
    Hi = math.floor(H/60)
    f = H/60.0 - Hi
    p = V*(1-S)
    q = V*(1-f*S)
    t = V*(1-(1-f)*S)

    -- Do math based on hue index
    if Hi == 0
      r = V*255.0
      g = t*255.0
      b = p*255.0
    elseif Hi == 1
      r = q*255.0
      g = V*255.0
      b = p*255.0
    elseif Hi == 2
      r = p*255.0
      g = V*255.0
      b = t*255.0
    elseif Hi == 3
      r = p*255.0
      g = q*255.0
      b = V*255.0
    elseif Hi == 4
      r = t*255.0
      g = p*255.0
      b = V*255.0
<FILL-HERE>(H % 360 / 60) should be [0, 6), is #{Hi}?"

  return r, g, b

-- Convert HSL (Hue, Saturation, Luminance) to RGB
-- Contributed by Gundamn
HSL_to_RGB = (H, S, L) ->
  local r, g, b

  -- Make sure input is in range
  H = math.abs(H) % 360
  S = clamp(S, 0, 1)
  L = clamp(L, 0
<fim-prefix> 0, 255)
    g = r
    b = r

  -- Else, calculate color
  else
    -- Calculate subvalues
    H = math.abs(H) % 360 -- Put H in range [0, 360)
    Hi = math.floor(H/60)
    f = H/60.0 - Hi
    p = V*(1-S)
    q = V*(1-f*S)
    t = V*(1-(1-f)*S)

    -- Do math based on hue index
    if Hi == 0
      r = V*255.0
      g = t*255.0
      b = p*255.0
    elseif Hi == 1
      r = q*255.0
      g = V*255.0
      b = p*255.0
    elseif Hi == 2
      r = p*255.0
      g = V*255.0
      b = t*255.0
    elseif Hi == 3
      r = p*255.0
      g = q*255.0
      b = V*255.0
    elseif Hi == 4
      r = t*255.0
      g = p*255.0
      b = V*255.0
<fim-suffix>(H % 360 / 60) should be [0, 6), is #{Hi}?"

  return r, g, b

-- Convert HSL (Hue, Saturation, Luminance) to RGB
-- Contributed by Gundamn
HSL_to_RGB = (H, S, L) ->
  local r, g, b

  -- Make sure input is in range
  H = math.abs(H) % 360
  S = clamp(S, 0, 1)
  L = clamp(L, 0<fim-middle>    elseif Hi == 5
      r = V*255.0
      g = p*255.0
      b = q*255.0
    else
      error "math.floor
    elseif Hi == 5
      r = V*255.0
      g = p*255.0
      b = q*255.0

  -- Return RGB
  return r, g, b

-- Convert RGB to HSL
-- Contributed by Gundamn
RGB_to_HSL = (R, G, B) ->
  local r, g, b
  r, g, b = R, G, B
  r, g, b = r/255.0, g/255.0, b/255.0
  min = min(r, g, b)
  max = max(r, g, b)
  delta = max - min
  if delta == 0:
    h = 0
  else:
    if r == max:
      h = (60 * (g - b) / delta) % 360
    elif g == max:
      h = (60 * (b - r) / delta) + 120
    else:
      h = (60 * (r - g) / delta) + 240

  h = clamp(h, 0, 360)
  s = delta / max
  l = (min + max) / 2

  return h, s, l

-- Convert HSL to RGB
-- Contributed by Gundamn
HSL_to_RGB = (H, S, L) ->
  local r, g, b

  -- Make sure input is in range
  H = math.abs(H) % 360
  S = clamp(S, 0, 1)
  L = clamp(L, 0, 1)

  -- Calculate RGB
  if S == 0
    r = g = b = L*255
  else:
    if L < 0.5
      s = delta / (L * (1 + S))
      r = L * s
      g = L * s
      b = L * s
    else:
      s = delta / (2 - L * S)
      r = L * s
      g = (L + S) * s
      b = (L + S) * s

  r = clamp(r, 0, 255)
  g = clamp(g, 0, 255)
  