- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
int spectrumColor(float magn)
{
if (magn != magn) return 0xFF000000;
if ((magn <= -FLT_MAX && magn >= FLT_MAX)) return 0xFF000000;
const float minRange = -95.0f;
if (magn > minRange && magn <= (minRange + 10.0f))
return blendColor(0, 0x00004f, (magn - minRange) / 10.0f);
if (magn > (minRange + 10.0f) && magn <= (minRange + 20.0f))
return blendColor(0x00004f, 0x50007b, (magn - (minRange + 10.0f)) / 10.0f);
if (magn > (minRange + 20.0f) && magn <= (minRange + 30.0f))
return blendColor(0x50007b, 0x990076, (magn - (minRange + 20.0f)) / 10.0f);
if (magn > (minRange + 30.0f) && magn <= (minRange + 40.0f))
return blendColor(0x990076, 0xd20040, (magn - (minRange + 30.0f)) / 10.0f);
if (magn > (minRange + 40.0f) && magn <= (minRange + 50.0f))
return blendColor(0xd20040, 0xf51f00, (magn - (minRange + 40.0f)) / 10.0f);
if (magn > (minRange + 50.0f) && magn <= (minRange + 60.0f))
return blendColor(0xf51f00, 0xffaa00, (magn - (minRange + 50.0f)) / 10.0f);
if (magn > (minRange + 60.0f) && magn <= (minRange + 70.0f))
return blendColor(0xffaa00, 0xfff966, (magn - (minRange + 60.0f)) / 10.0f);
if (magn > (minRange + 70.0f) && magn <= (minRange + 80.0f))
return blendColor(0xfff966, 0xffffff, (magn - (minRange + 70.0f)) / 10.0f);
if (magn < minRange) return 0xFF000000;
if (magn >= (minRange + 80.0f)) return 0xFFFFFFFF;
return 0xFF000000;
}
Вот так в одной говноподелке считается цвет столбцов спектра для визуализации аудио.