/// <summary> /// Gets the wrapped uv. /// </summary> /// <returns>The wrapped uv.</returns> /// <param name="uV">U v.</param> private Vector2 GetWrappedUv(Vector2 uV) { float u = uV.x; float v = uV.y; switch (m_Wrap) { case Wrap.Clamp: u = HydraMathUtils.Clamp(u, 0.0f, 1.0f); v = HydraMathUtils.Clamp(v, 0.0f, 1.0f); break; case Wrap.Repeat: u = Mathf.Repeat(u, 1.0f); v = Mathf.Repeat(v, 1.0f); break; case Wrap.PingPong: u = HydraMathUtils.PingPong(u, 1.0f); v = HydraMathUtils.PingPong(v, 1.0f); break; default: throw new ArgumentOutOfRangeException(); } return(new Vector2(u, v)); }
/// <summary> /// Returns the color at the specified time, using the given wrap mode. /// </summary> /// <param name="extends">Extends.</param> /// <param name="time">Time.</param> /// <param name="wrapMode">Wrap mode.</param> public static Color Evaluate(this Gradient extends, float time, GradientWrapMode wrapMode) { switch (wrapMode) { case GradientWrapMode.Clamp: return(extends.Evaluate(time)); case GradientWrapMode.Loop: return(extends.Evaluate(Mathf.Repeat(time, 1.0f))); case GradientWrapMode.PingPong: return(extends.Evaluate(HydraMathUtils.PingPong(time, 1.0f))); default: throw new ArgumentOutOfRangeException(); } }