colorGradient generates a color gradient based on a numeric input x.
The original version (named 'color.gradient') was written by David Hoop in a 2016 stack.overflow response to question (online). The function was
modified slightly for adaptability of inputs. Note that the full color gradient is used if possible,
which can exaggerate small differences in x. This function is applied by optimFPM when generating color-based
optimization matrix graphics (i.e., when optimizing both alpha and FN_crit).