code: def constrain_rgb(r, g, b):
      """
      If the requested RGB shade contains a negative weight for
      one of the primaries, it lies outside the colour gamut
      accessible from the given triple of primaries.  Desaturate
      it by adding white, equal quantities of R, G, and B, enough
      to make RGB all positive.  The function returns 1 if the
      components were modified, zero otherwise.
      """
      # Amount of white needed is w = - min(0, *r, *g, *b)
      w = -min([0, r, g, b])  # I think?
  
      # Add just enough white to make r, g, b all positive.
      if w > 0:
          r += w
          g += w
          b += w
      return (r, g, b)
  
file_path: vispy/examples/demo/gloo/galaxy/galaxy_specrend.py
imports: import math
label_desc: Use image node_id 5 for calling a global function with example usage: constrain_rgb(r, g, b) and returns: r,  g,  b