2013-06-13 25 views

回答

1

我想,你的意思是這樣的:

測量時間,在我的例子具體的模塊, 上只得到的餘數,我使用的模塊= 10000 = 10秒,所以每10秒集合顏色會反覆

int module = 10000; 
long time = SystemClock.uptimeMillis() % module; 

而且,當時只要你想,你可以使用這個值, - 我創建的下一個情景,但你可以修改它獲得最好的結果:

int shift = module/5; 
Color c = new Color(); 
int red = (int)((float)time/module)*256, 
    green =(int)(((float)time+shift)/module)*256, 
    blue = (int)(((float)time+2*shift)/module)*256; 
c.rgb(red, green, blue); 

如果你會找到更好的方法,請告訴我!