GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 Script Submission » merge_color_squared » 2017-06-06 17:50:17

DragonCoke
Replies: 1
Expand/// merge_color_squared(col1,col2,amount);
//
// Returns a color merged from two colors by the specified amount. The values
// are squared to make a more natural blend.
//
//		col1 		the first color
//		col2 		the second color
//		amount	amount of blend, 0 - 1
//
//
/// GMLscripts.com/license
{
	var _col1 = argument0;
	var _col2 = argument1;
	var _amount = argument2;

	var _col;
	_col[1,2] = colour_get_blue(_col2);
	_col[1,1] = colour_get_green(_col2);
	_col[1,0] = colour_get_red(_col2);

	_col[0,2] = colour_get_blue(_col1);
	_col[0,1] = colour_get_green(_col1);
	_col[0,0] = colour_get_red(_col1);


	for (var i=0;i<3;i++) {
		_col[0,i] = sqrt(
			lerp(
				sqr(_col[0,i]),
				sqr(_col[1,i]),
				_amount
			)
		);
	}


	return make_colour_rgb(_col[0,0],_col[0,1],_col[0,2]);
}

Board footer

Powered by FluxBB