So in my program colors are defined like this for example
//R, G, B, A
float red[4] = { 1, 0, 0, 1 };
float green[4] = { 0, 1, 0, 0.5 };//green[3] = 0.5; this mean opacity is at 50%
float blue[4] = { 0, 0, 1, 0.2 };blue[3] = 0.2; this mean opacity is at 20%
My question is, how could I make a color smoothly pulsate/flash? I am VERY confused with the math involved in accomplishing what I want.
For example, if I wanted to fade a color in and out I would do this
float color[4] = { 1, 0, 0, 1 };
void fadeColorInAndOut(float * Colorin)
{
for(float i = 1; i > 0; i-= 0.01f)
{
Colorin[3] = i;
sleep(10);//10 milliseconds
}
for(float i = 0; i < 1; i+= 0.01f)
{
Colorin[3] = i;
sleep(10);//10 milliseconds
}
}
But when it comes to actually Pulsating / Flashing the colors I really wouldn't even know where to start.
To hopefully help you understand more, this is the kind of effect I am looking for. Here is a GIF I found which pretty much perfectly demonstrates my desired effect