Generating an array of colors (ColorBetween related)
#2

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

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;
}
Reply


Messages In This Thread
Generating an array of colors (ColorBetween related) - by Crayder - 20.03.2015, 02:17
Re: Generating an array of colors (ColorBetween related) - by Pottus - 20.03.2015, 04:10
Re: Generating an array of colors (ColorBetween related) - by Crayder - 20.03.2015, 05:38
Re: Generating an array of colors (ColorBetween related) - by Pottus - 20.03.2015, 14:13
Re: Generating an array of colors (ColorBetween related) - by Crayder - 20.03.2015, 14:37
Re: Generating an array of colors (ColorBetween related) - by Misiur - 20.03.2015, 15:26

Forum Jump:


Users browsing this thread: 1 Guest(s)