Esempio n. 1
0
        // Helper for integer map extensions
        private static decimal MapAndRound(decimal value, decimal sourceMin, decimal sourceMax, decimal targetMin, decimal targetMax, MidpointRounding mode)
        {
            var mappedValue  = MapImplementations.MapImpl(value, sourceMin, sourceMax, targetMin, targetMax);
            var roundedValue = Math.Round(mappedValue, mode);

            return(roundedValue);
        }
Esempio n. 2
0
 /// <summary>
 /// Map a value contained in a source range to value in a target range.
 /// </summary>
 /// <param name="value">Value to map</param>
 /// <param name="sourceMin">From range min value</param>
 /// <param name="sourceMax">From range max value</param>
 /// <param name="targetMin">To range min value</param>
 /// <param name="targetMax">To range max value</param>
 /// <returns>Returns the mapped value</returns>
 public static double Map(this double value, double sourceMin, double sourceMax, double targetMin, double targetMax)
 {
     return(MapImplementations.MapImpl(value, sourceMin, sourceMax, targetMin, targetMax));
 }
Esempio n. 3
0
 /// <summary>
 /// Map a value contained in a source range to value in a target range.
 /// </summary>
 /// <param name="value">Value to map</param>
 /// <param name="sourceMin">From range min value</param>
 /// <param name="sourceMax">From range max value</param>
 /// <param name="targetMin">To range min value</param>
 /// <param name="targetMax">To range max value</param>
 /// <returns>Returns the mapped value</returns>
 public static float Map(this float value, float sourceMin, float sourceMax, float targetMin, float targetMax)
 {
     return(MapImplementations.MapImpl(value, sourceMin, sourceMax, targetMin, targetMax));
 }
Esempio n. 4
0
 /// <summary>
 /// Map a value contained in a source range to value in a target range.
 /// </summary>
 /// <param name="value">Value to map</param>
 /// <param name="sourceMin">From range min value</param>
 /// <param name="sourceMax">From range max value</param>
 /// <param name="targetMin">To range min value</param>
 /// <param name="targetMax">To range max value</param>
 /// <returns>Returns the mapped value</returns>
 public static decimal Map(this decimal value, decimal sourceMin, decimal sourceMax, decimal targetMin, decimal targetMax)
 {
     return(MapImplementations.MapImpl(value, sourceMin, sourceMax, targetMin, targetMax));
 }