ColorGradient

Converts a percent value into a gradient from 2 or more RGB percent values (0.0-1.0). If more than 2 colors are passed, the gradient will be between the two colors which perc lies in an evenly divided range.

(Note that if you will always be generating a gradient between the same number of colors, you will see *significantly* greater performance if you customize this function to take a fixed number of arguments.)

The same function, changed to accept only 3 colors and optimize speed.

Example
For this example we'll use 3 colors: red, yellow and green. For a percent value of 0.75 we'd expect to get back a color that's halfway between yellow and green. 0.5 would yield pure yellow, 0.25 would yield an orange.