|
/*********************************************************************
*
* _DrawGradientRoundBar
*
* Function description
* Draws a vertical gradient in form of a rounded bar
*/
static void _DrawGradientRoundBar(int xPos0, int yPos0, int xPos1, int yPos1, GUI_COLOR Color0, GUI_COLOR Color1)
{
GUI_COLOR Color;
unsigned r;
unsigned g;
U32 b;
double rd;
double rr;
double x;
double y;
int Add;
int r0;
int g0;
int b0;
int r1;
int g1;
int b1;
int d;
int i;
r0 = (Color0 >> 0) & 0x000000ff;
g0 = (Color0 >> 8) & 0x000000ff;
b0 = (Color0 >> 16) & 0x000000ff;
r1 = (Color1 >> 0) & 0x000000ff;
g1 = (Color1 >> 8) & 0x000000ff;
b1 = (Color1 >> 16) & 0x000000ff;
Add = -1;
d = yPos1 - yPos0 + 1;
rd = (yPos1 - yPos0) / 2.0;
rr = rd * rd;
y = rd;
for (i = yPos0; i <= yPos1; i++)
{
x = sqrt(rr - y * y);
r = r0 + (r1 - r0) * (i - yPos0) / d;
g = g0 + (g1 - g0) * (i - yPos0) / d;
b = b0 + (b1 - b0) * (i - yPos0) / d;
Color = r | (g << 8) | (b << 16);
GUI_SetColor(Color);
GUI_DrawHLine(i, (int)(xPos0 + rd - x), (int)(xPos0 + rd));
GUI_DrawHLine(i, (int)(xPos0 + rd), (int)(xPos1 - rd));
GUI_DrawHLine(i, (int)(xPos1 - rd), (int)(xPos1 - rd + x));
y += Add;
if (y < 0)
{
Add = -Add;
y = -y;
}
}
} |
|