I'm trying to figure out how to draw a color map like this: http://www.ritsplasman.com/images/colormap.png
I know Core Graphics has two f开发者_开发技巧unctions that deal with gradients: CGContextDrawLinearGradient
and CGContextDrawRadialGradient
. A radial gradient is not what I want so I guess I'm forced to use the other one. But I cannot accomplish the example image using just a linear gradient.
The color map is basically a gradient where the hue changes horizontally and saturation vertically. How can I achieve this?
As its name implies, the linear gradient only goes on one axis. In theory you could stack multiple gradients on top of one another to create a similar effect as that image but I doubt that would be a very efficient solution to the problem. I needed a similar color map in one of my iOS apps, I ended up using the image because it was far more efficient then trying to recreate it.
精彩评论