Scale numbers to be <= 255?

前端 未结 13 2230
生来不讨喜
生来不讨喜 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:18

    The value you're looking for is: r = 255 * (value / Integer.MAX_VALUE). So you'd have to turn this into a double, then cast back to an int.

提交回复
热议问题