code: def hls(self):
          
          (r, g, b) = self.rgb
          maxc = max(r, g, b)
          minc = min(r, g, b)
          l = (minc+maxc)/2.0
  
          if minc == maxc:
              return 0.0, l, 0.0
  
          if l <= 0.5:
              s = (maxc-minc) / (maxc+minc)
          else:
              if 2.0-maxc-minc == 0:
                  s = 0
              else:
                  s = (maxc-minc) / (2.0-maxc-minc)
  
          rc = (maxc-r) / (maxc-minc)
          gc = (maxc-g) / (maxc-minc)
          bc = (maxc-b) / (maxc-minc)
  
          if r == maxc:
              h = bc-gc
          elif g == maxc:
              h = 2.0+rc-bc
          else:
              h = 4.0+gc-rc
  
          h = (h/6.0) % 1.0
  
          return (h, l, s)
docs: HLS: Hue, Luminance, Saturation
          H: position in the spectrum
          L: color lightness
          S: color saturation