开发者

Render temperature map without using range values

I'd like to render a map such as:

Render temperature map without using range values

with different color, not just gradients, with a map that has 0...1 value of temperature, without using ranged values, this is, if t = 0...0.2 use red*t, if t > 0.2 and t < 0.4 use orange * t, etc.

Any tip?

EDIT: example code of "ranges":

    else if (layerType == "temperature") {

     if (value <= 0.2) {
        r = Math.round(value * 200)+100;
        g = Math.round(value * 200)+100;
        b = Math.round(value * 250)+150;
        a = 1;
    } else if (value > 0.2 && value <= 1) {
        r = Math.round(value * 250);
        g = Math.round(value * 250);
        b = Math.round(value * 200);
开发者_如何学运维        a = 1;
    }


You can map temperatures to colors using smooth continuous functions with the HSB color space (hue, saturation and brightness).

Hue maps the spectrum of visible colors like this:

Render temperature map without using range values

(http://en.wikipedia.org/wiki/File:HueScale.svg)

In your example image, it looks like saturation and brightness might be constant, so your function could simply translate temperature to hue:

hue = f(t)

Depending on your needs, f could be a linear function, logarithmic, exponential or whatever looks best.

For a discussion on how to translate HSB to the RGB color space, look for example at the answer accepted to this StackOverflow topic: Algorithm For Generating Unique Colors

For a general discussion about hue, see for example this WikiPedia article: http://en.wikipedia.org/wiki/Hue

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜