sud03r
sud03r

Reputation: 19759

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 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.

Upvotes: 1

Views: 3246

Answers (2)

MSalters
MSalters

Reputation: 179819

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.

Upvotes: 4

Thomas
Thomas

Reputation: 181745

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.

Upvotes: 1

Related Questions