开发者

Creating a linear color palette

I am painting a FFT and want better colors. I have values between X and Y and want to represent them in a power spectrum (higher value=brighter color). Currently I'm just using black/white (0-255 on RGB), but I would like it to be multiple colors with higher (color) resolution than 255 (65k?).

I need the colors to fade nicely between them, so if 0 is black and 100 is white I need 50 to be 50% white (grey). But I want multiple colors in sequence and not just RGB primary colors (red, green or blue).

Preferrably I would like to be able 开发者_StackOverflow中文版to select at what point the colors are (not evenly spaced). So for example [0]="#00000", [99]="#44000", [149]="#FF0000", [199]="#FFFF00", etc.

Now my question is what would the calculations look like? I'm guessing there is some simple/smart way I'm not thinking of.

I vaguely remember something about some other color calculation method than RGB that will work for this? Or is the best way to use some sort of brush on a picture, then sample the color values?

I'm using C# .Net, but I don't need a fully working code (I can make that) - so any sample/hints will be good.


You can use the HSL color space.

Creating a linear color palette

When L is 0 you get black, and when L is 1 you get white. You can vary H from say 0 to 1 to change the hue (or color). This is for maximum saturation (S = 1).

Here is an example of a mapping. To use the HSL color you need to convert it RGB.

// Assume x is a double in the interval [0; 1]
var l = x;
var h = x;
var s = 1D;
var rgb = ConvertHslToRgb(h, s, l);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜