开发者

drawing rainbow palettes

I have a 8-bit color palette, therefore I am having 256 colors.

The palette is basically an array of [256 * 3] {r, g, b} values, Now I need to draw a color spectrum out of it. So basically I have to select 256 out of total 256*256*256 values possible which would enable me to draw the开发者_Python百科 rainbow as closely as possible.

Similar questions here on SO point to HSV based approach, but I am looking for an RGB implementation coz I have APIs defined that way.

Any help is much appreciated.


The HSV solution is still correct, because that pretty much captures your problem. A "rainbow" is by definition a series of colors with constant S and V, but varying H.


It really is easiest to use HSV, because that's what you'll end up implementing anyway. Keep S and V fixed (both at 1) and let H vary from 0° to 360°.

The recipe for converting HSV to RGB is described on Wikipedia.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜