Exemple #1
0
        public static (double StartProgress, double EndProgress) SplitProgress(this double progress, double firstStart, double firstEnd, double lastStart, double lastEnd)
        {
            var equation1 = LinearEquation.FromPoints(new Point(firstStart, 0), new Point(firstEnd, 1));
            var equation2 = LinearEquation.FromPoints(new Point(lastStart, 0), new Point(lastEnd, 1));

            return(equation1.Y(progress), equation2.Y(progress));
        }
Exemple #2
0
        public static (double StartProgress, double EndProgress) SplitProgress(this double progress, double splitLocation)
        {
            var equation1 = LinearEquation.FromPoints(new Point(0, 0), new Point(splitLocation, 1));
            var equation2 = LinearEquation.FromPoints(new Point(splitLocation, 0), new Point(1, 1));

            return(equation1.Y(progress), equation2.Y(progress));
        }
Exemple #3
0
        public static IEnumerable <double> SplitProgress(this double progress, params double[] splitLocations)
        {
            double previous = 0;

            for (int i = 0; i < splitLocations.Length; i++)
            {
                double location = splitLocations[i];
                yield return(LinearEquation.FromPoints(new Point(previous, 0), new Point(location, 1)).Y(progress));

                previous = location;
            }
            yield return(LinearEquation.FromPoints(new Point(previous, 0), new Point(1, 1)).Y(progress));
        }
Exemple #4
0
        public static double GetProgressAfterSplitting(this double progress, params double[] splitLocations)
        {
            double previous = 0;

            for (int i = 0; i < splitLocations.Length; i++)
            {
                double location = splitLocations[i];
                if (previous <= progress && location >= progress)
                {
                    return(LinearEquation.FromPoints(new Point(previous, 0), new Point(location, 1)).Y(progress));
                }
                else
                {
                    previous = location;
                }
            }
            return(LinearEquation.FromPoints(new Point(previous, 0), new Point(1, 1)).Y(progress));
        }