Advertisement
Muk99

MultColorLerp

Sep 2nd, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.38 KB | None | 0 0
  1. public static Color MultColorLerp(float t, params Color[] colors) {
  2.     if(colors.Length < 2)
  3.         throw new System.ArgumentException("Need at least 2 colors");
  4.  
  5.     if(t < 0f)
  6.         return colors[0];
  7.     else if(t >= 1f)
  8.         return colors[colors.Length - 1];
  9.  
  10.     var i = (int)(t * (colors.Length - 1));
  11.     return Color.Lerp(colors[i++], colors[i], Mathf.Repeat(t * (colors.Length - 1f), 1f));
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement