Rits
Rits

Reputation: 5175

Drawing a color map with Core Graphics

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 functions 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?

Upvotes: 0

Views: 790

Answers (1)

Cory Powers
Cory Powers

Reputation: 1140

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.

Upvotes: 1

Related Questions