, 1)

  if S == 0 -- Simple case if saturation is 0, all grey
    r = L
    g = L
    b = L
  else
    -- More common case, saturated colour
    Q = if L < 0.5
      L * (1.0 + S)
    else
      L + S - (L * S)

    P = 2.0 * L - Q

    Hk = H / 360

    local Tr, Tg, Tb
    if Hk < 1/3
      Tr = Hk + 1/3
      Tg = Hk
      Tb = Hk + 2/3
    elseif Hk > 2/3
      Tr = Hk - 2/3
      Tg = Hk
      Tb = Hk - 1/3
    else
      Tr = Hk + 1/3
      Tg = Hk
      Tb = Hk - 1/3

    get_component = (T) ->
      if T < 1/6
        P + ((Q - P)<FILL-HERE>5+0.5), math.floor(g*255+0.5), math.floor(b*255+0.5)

-- Removes spaces at the start and end of string
trim = (s) -> s\gsub '^%s*(.-)%s*$', '%1'

-- Get the 'head' and 'tail' of a string, treating it as a sequence of words se
<fim-prefix>, 1)

  if S == 0 -- Simple case if saturation is 0, all grey
    r = L
    g = L
    b = L
  else
    -- More common case, saturated colour
    Q = if L < 0.5
      L * (1.0 + S)
    else
      L + S - (L * S)

    P = 2.0 * L - Q

    Hk = H / 360

    local Tr, Tg, Tb
    if Hk < 1/3
      Tr = Hk + 1/3
      Tg = Hk
      Tb = Hk + 2/3
    elseif Hk > 2/3
      Tr = Hk - 2/3
      Tg = Hk
      Tb = Hk - 1/3
    else
      Tr = Hk + 1/3
      Tg = Hk
      Tb = Hk - 1/3

    get_component = (T) ->
      if T < 1/6
        P + ((Q - P)<fim-suffix>5+0.5), math.floor(g*255+0.5), math.floor(b*255+0.5)

-- Removes spaces at the start and end of string
trim = (s) -> s\gsub '^%s*(.-)%s*$', '%1'

-- Get the 'head' and 'tail' of a string, treating it as a sequence of words se<fim-middle> * 6.0 * T)
      elseif 1/6 <= T and T < 1/2
        Q
      elseif 1/2 <= T and T < 2/3
        P + ((Q - P) * (2/3 - T) * 6.0)
      else
        P

    r = get_component(Tr)
    g = get_component(Tg)
    b = get_component(Tb)

  return math.floor(r*25
 * 6 * Tr)
      elseif T < 1/2
      P
      elseif T < 2/3
      Q + ((P - Q) * 6 * (2/3 - Tr))
      else
        P

    r = get_component(Tr)
    g = get_component(Tg)
    b = get_component(Tb)

  return math.floor(r*25