BooksGrid.App/Utilities/RgbGradientGenerator.cs
/// <summary>
/// Returns a percentage in the range
/// If min equals max, return middle range
/// </summary>
/// <param name="value">Value to find in range</param>
/// <param name="minValue">0% of the range</param>
/// <param name="maxValue">100% of the range</param>
/// <returns>Percent for the value</returns>
Returns a percentage in the range
If min equals max, return middle range
Returns a percentage in the range If min equals max return middle range
public double CalculatePercent(double value, double minValue, double maxValue)
        {
            if (minValue == maxValue)
            {
                return 0.5;
            }
            double rangeRebased = maxValue - minValue;
            double valueRebased = value - minValue;
            return valueRebased / rangeRebased;
        }
public double CalculatePercent ( double value , double minValue , double maxValue ) { if ( minValue == maxValue ) { return 0.5 ; } double rangeRebased = maxValue - minValue ; double valueRebased = value - minValue ; return valueRebased / rangeRebased ; }
Returns a percentage in the range
If min equals max, return middle range
Returns a percentage in the range If min equals max return middle range
// Avoid division / 0
Percent for the value
Percent for the value
value
double
Value to find in range
Value to find in range
minValue
double
0% of the range
0% of the range
maxValue
double
100% of the range
100% of the range