GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2017-06-06 17:36:46

xot
Administrator
Registered: 2007-08-18
Posts: 1,240

merge_colors(col1,col2,...,amount)

This is an extension of the built-in merge_color() for more than two colors.

Expand/// merge_colors(col1,col2,...,amount)
//  
//  Returns a color merged from a series of two or more colors
//  controlled by the given amount. A value of 0 returns the
//  first color, a value of 1 returns the last color, and values
//  in-between return a blend of two adjacent colors in the series.
//
//      col1        first color
//      col2        next color
//      amount      blend factor, 0 to 1
//
/// GMLscripts.com/license
{
    var colors = argument_count-1;
    var amount = clamp(argument[colors], 0, 1);
    var n = amount * (colors-1);
    var col1 = floor(n);
    var col2 = col1 + 1;
    return merge_color(argument[col1], argument[col2], frac(n));
}

xdsq7t9.png


Abusing forum power since 1986.

Offline

#2 2017-06-21 05:24:43

gnysek
Member
Registered: 2011-12-29
Posts: 36

Re: merge_colors(col1,col2,...,amount)

it can be nice for day-night cycle, thanks!

Offline

Board footer

Powered by FluxBB