gmlscripts

merge_colors

Jun 6th, 2017
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// merge_colors(col1,col2,...,amount)
  2. //  
  3. //  Returns a color merged from a series of two or more colors
  4. //  controlled by the given amount. A value of 0 returns the
  5. //  first color, a value of 1 returns the last color, and values
  6. //  in between return a blend of two adjacent colors in the series.
  7. //
  8. //      col1        first color
  9. //      col2        next color
  10. //      amount      blend factor, 0 to 1
  11. //
  12. /// GMLscripts.com/license
  13. {
  14.     var colors = argument_count-1;
  15.     var amount = clamp(argument[colors], 0, 1);
  16.     var n = amount * (colors-1);
  17.     var col1 = floor(n);
  18.     var col2 = col1 + 1;
  19.     return merge_color(argument[col1], argument[col2], frac(n));
  20. }
Advertisement
Add Comment
Please, Sign In to add comment