// 3顏色等比線性變換 int startColor = COLORS[colorType][0]; int endColor = COLORS[colorType][1]; int delaR = [AColor getRed:endColor] - [AColor getRed:startColor]; int delaG = [AColor getGreen:endColor] - [AColor getGreen:startColor]; int delaB = [AColor getBlue:endColor] - [AColor getBlue:startColor]; LONG delaTime = SYS_TIME - publicVoiceTimeCount; float rate = delaTime * 1.0f / (PublicVoice_TIME); // 0 - 1 int curColor = [AColor getRGB:[AColor getRed:startColor] + delaR * rate g:[AColor getGreen:startColor] + delaG * rate b:[AColor getBlue:startColor] + delaB * rate]; 原來准備用這個做喇叭喊話的,但是由於漸變過度太平滑,效果不好,后來改成6顏色閃爍效果。 [cpp] view plain copy // 閃爍效果 int colors[6] = { COLORS[colorType][0], COLORS[colorType][1], COLORS[colorType][2], COLORS[colorType][3], COLORS[colorType][2], COLORS[colorType][1]}; int _colorCount = (SYS_TIME - publicVoiceTimeCount) / 100; // 1000/100s一變 if (_colorCount > colorCount) { colorCount = _colorCount; int index = _colorCount % 6; int curColor = colors[index]; }