+ // Find first component with position greater than f
+ unsigned i;
+ for ( i = 0; i < stops.count; i++ )
+ {
+ if (stops.comps[i].pos > f)
+ break;
+ }
+
+ // Interpolated between stops
+ CGFloat diff = (f - stops.comps[i-1].pos);
+ CGFloat range = (stops.comps[i].pos - stops.comps[i-1].pos);
+ CGFloat fact = diff / range;
+
+ out[0] = stops.comps[i - 1].red + (stops.comps[i].red - stops.comps[i - 1].red) * fact;
+ out[1] = stops.comps[i - 1].green + (stops.comps[i].green - stops.comps[i - 1].green) * fact;
+ out[2] = stops.comps[i - 1].blue + (stops.comps[i].blue - stops.comps[i - 1].blue) * fact;
+ out[3] = stops.comps[i - 1].alpha + (stops.comps[i].alpha - stops.comps[i - 1].alpha) * fact;