使用 Core Graphics 绘制彩色图
我试图弄清楚如何绘制这样的彩色图: http://www.ritsplasman .com/images/colormap.png
我知道 Core Graphics 有两个处理渐变的函数:CGContextDrawLinearGradient
和 CGContextDrawRadialGradient
。径向渐变不是我想要的,所以我想我被迫使用另一种。但我无法仅使用线性渐变来完成示例图像。
颜色图基本上是一个渐变,其中色调水平变化,饱和度垂直变化。我怎样才能实现这个目标?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
顾名思义,线性渐变仅在一个轴上进行。理论上,您可以将多个渐变堆叠在一起,以创建与该图像类似的效果,但我怀疑这是否是解决该问题的一种非常有效的解决方案。我需要在我的一个 iOS 应用程序中使用类似的颜色图,我最终使用了该图像,因为它比尝试重新创建它要高效得多。
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.