今天阅读代码的时候看到了一个实现颜色渐变的效果,不同于以往使用函数实现的颜色渐变,这个是规律的递增rgba里面的几个参数完成的,看起来就像是等差数列一样。没想到还能这样来,简单的了解了一下
rgba的前几位分别代表红/绿/蓝,最后一位a(alpha)一般用作不透明参数。范围是0到1,其他三位的范围是0-255
颜色是这样来控制的:
rgba = (0, 1 - self.value / (self.data_count * 2), self.value / (self.data_count * 2) + 0.5, 1)
#不是是何原因,这里的rgba只支持0-1的范围