/// <summary>
		/// Returns the path progress from specified time progress which interpolates between start and end time.
		/// </summary>
		public static float GetProgress(this IHasCurve context, float progress)
		{
			float p = progress * context.SpanCount() % 1;
			// If is a repeat and is reversing back, invert progress towards end to start.
			if(context.GetSpan(progress) % 2 == 1)
				return 1 - p;
			return p;
		}
Beispiel #2
0
        /// <summary>
        /// Computes the progress along the curve relative to how much of the <see cref="HitObject"/> has been completed.
        /// </summary>
        /// <param name="obj">The curve.</param>
        /// <param name="progress">[0, 1] where 0 is the start time of the <see cref="HitObject"/> and 1 is the end time of the <see cref="HitObject"/>.</param>
        /// <returns>[0, 1] where 0 is the beginning of the curve and 1 is the end of the curve.</returns>
        public static double ProgressAt(this IHasCurve obj, double progress)
        {
            var p = progress * obj.SpanCount() % 1;

            if (obj.SpanAt(progress) % 2 == 1)
            {
                p = 1 - p;
            }
            return(p);
        }
Beispiel #3
0
 /// <summary>
 /// Determines which span of the curve the progress point is on.
 /// </summary>
 /// <param name="obj">The curve.</param>
 /// <param name="progress">[0, 1] where 0 is the beginning of the curve and 1 is the end of the curve.</param>
 /// <returns>[0, SpanCount) where 0 is the first run.</returns>
 public static int SpanAt(this IHasCurve obj, double progress)
 => (int)(progress * obj.SpanCount());
		/// <summary>
		/// Returns the path span index at specified path progress.
		/// </summary>
		public static int GetSpan(this IHasCurve context, float progress)
		{
			return (int)(progress * context.SpanCount());
		}