Python通过动画的百分比生成彩虹rgb

时间:2017-02-07 20:02:24

标签: python algorithm

我想通过使用所有彩虹颜色改变颜色来为文本添加动画效果。

我有一个数组

COLORS = [255, 0, 0]

我只需要改变这三个整数。现在我有了这个功能

def getRGB(percentage):
    global COLORS
    COLORS[0] = ...
    COLORS[1] = ...
    COLORS[2] = ...

参数percentage是一个从0到1的浮点数,表示当前循环的位置。

getRGB函数将被调用n次,并且应将COLORS值设置为生成的RGB值。

结果应如何显示:

getRGB(0) -> [255, 0, 0]
getRGB(1) -> [255, 0, 0]
getRGB(0.5) -> [0, 255, 255]

0 个答案:

没有答案