20.03.2015, 04:10
I looked into this issue for you and came up with a solution you can set the start and end colors to anything you want and also specify how many color gradients you want in between.
Method source: http://www.exorithm.com/algorithm/view/create_gradient
Method source: http://www.exorithm.com/algorithm/view/create_gradient
pawn Код:
// Example CreateGradient(colors, 100, 0xFF0000, 0x00FF00);
// Red to Green
#define RGBA(%0,%1,%2,%3) ((((%0) & 0xFF) << 24) | (((%1) & 0xFF) << 16) | (((%2) & 0xFF) << 8) | (((%3) & 0xFF) << 0))
CreateGradient(colors[], size, start_color, end_color)
{
new red, green, blue, Float:start_r, Float:start_g, Float:start_b, Float:end_r, Float:end_g, Float:end_b;
start_r = float(((start_color >> 16) & 0xFF));
start_g = float(((start_color >> 8) & 0xFF));
start_b = float(((start_color) & 0xFF));
end_r = float(((end_color >> 16) & 0xFF));
end_g = float(((end_color >> 8) & 0xFF));
end_b = float(((end_color) & 0xFF));
for(new i=0; i < size; i++)
{
red = floatround(start_r - (start_r-end_r) * (float(i) / (float(size-1))));
green = floatround(start_g - (start_g-end_g) * (float(i) / (float(size-1))));
blue = floatround(start_b - (start_b-end_b) * (float(i) / (float(size-1))));
colors[i] = RGBA(red, green, blue, 0xFF);
}
return 1;
}