Color scaling function

后端 未结 8 1526
北荒
北荒 2020-12-08 11:40

I am trying to visualize some values on a form. They range from 0 to 200 and I would like the ones around 0 be green and turn bright red as they go to 200.

Basicall

8条回答
  •  孤城傲影
    2020-12-08 12:13

    You don't say in what environment you're doing this. If you can work with HSV colors, this would be pretty easy to do by setting S = 100 and V = 100, and determining H by:

    H = 0.4 * value + 120
    

    Converting from HSV to RGB is also reasonably easy.

    [EDIT] Note: in contrast to some other proposed solutions, this will change color green -> yellow -> orange -> red.

提交回复
热议问题