So this is essentially the method I would like to write (in Objective-C/Cocoa, using
+ (UIColor *)colorBetweenColor:(UIColor *)startColor andColor:(UIColor *)endColor atLocation:(CGFloat)location;
UIColor *resultingColor = [UIColor colorBetweenColor:[UIColor redColor] andColor:[UIColor blueColor] atLocation:0.33f];
You simply linearly interpolate the red, the green, and the blue channels like this:
double resultRed = color1.red + percent * (color2.red - color1.red); double resultGreen = color1.green + percent * (color2.green - color1.green); double resultBlue = color1.blue + percent * (color2.blue - color1.blue);
percent is a value between 0 and 1 (
location in your first method prototype).