Scale numbers to be <= 255?

前端 未结 13 2368
生来不讨喜
生来不讨喜 2021-02-05 18:39

I have cells for whom the numeric value can be anything between 0 and Integer.MAX_VALUE. I would like to color code these cells correspondingly.

If the val

13条回答
  •  半阙折子戏
    2021-02-05 19:23

    Ask yourself the question, "What value should map to 128?" If the answer is about a billion (I doubt that it is) then use linear. If the answer is in the range of 10-100 thousand, then consider square root or log.

    Another answer suggested this (I can't comment or vote yet). I agree.

    r = log(value)/log(pow(2,32))*256

提交回复
热议问题