def shade_rgb(colour, percent):
  """
  Lighten or darken an (R, G, B) colour
  percent of -1 is maximum darkening (black)
  percent of 1 is maximum lightening (white)

  Adapted from http://stackoverflow.com/questions/5560248/programmatically-lighten-or-darken-a-hex-color-or-rgb-and-blend-colors
  """
  t = 0.0 if percent < 0.0 else 255.0
  p = percent * -1.0 if percent < 0.0 else percent
  r, g, b = colour
  r = ((t - r) * p) + r
  g = ((t - g) * p) + g
  b = ((t - b) * p) + b
  return (int(r), int(g), int(b))