code: def clamp(color, min_v, max_v):
      
      h, s, v = rgb_to_hsv(*map(down_scale, color))
      min_v, max_v = map(down_scale, (min_v, max_v))
      v = min(max(min_v, v), max_v)
      return tuple(map(up_scale, hsv_to_rgb(h, s, v)))
docs: Clamps a color such that the value is between min_v and max_v.