How do I draw a gradient? For example in CSS:
Code: Select all
background-image: linear-gradient(#000000,#FFFFFF);
Code: Select all
background-image: linear-gradient(#000000,#FFFFFF);
Code: Select all
void DrawGradientRectandgle(int XS, int YS, int XE, int YE, int C1, int C2)
{
int x, y;
int r1 = (C1 & 0xFF0000) >> 16;
int r2 = (C2 & 0xFF0000) >> 16;
int g1 = (C1 & 0x00FF00) >> 8;
int g2 = (C2 & 0x00FF00) >> 8;
int b1 = C1 & 0x0000FF;
int b2 = C2 & 0x0000FF;
int h = abs(YE - YS);
double d_r = (double)(r2 - r1) / h;
double d_g = (double)(g2 - g1) / h;
double d_b = (double)(b2 - b1) / h;
double cur_r = r1, cur_g = g1, cur_b = b1;
for(y = YS; y <= YE; y++)
{
for(x = XS; x <= XE; x++)
SetPixel(x, y, RGB((int)cur_r, (int)cur_g, (int)cur_b));
cur_r += d_r;
cur_g += d_g;
cur_b += d_b;
}
}