code: def _constrain(value, lb=0, ub=1):
      
      if value < lb:
          return lb
      elif value > ub:
          return ub
      else:
          return value
docs: Helper for Color constructors.  Constrains a value to a range.