| File: NumericExtensions.cs | Web Access |
| Project: src\src\Graphics\src\Graphics\Graphics.csproj (Microsoft.Maui.Graphics) |
using System; using System.ComponentModel; using System.Runtime.CompilerServices; namespace Microsoft.Maui.Graphics { [EditorBrowsable(EditorBrowsableState.Never)] internal static class NumericExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float Clamp(this float self, float min, float max) { if (max < min) { return max; } else if (self < min) { return min; } else if (self > max) { return max; } return self; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double Clamp(this double self, double min, double max) { if (max < min) { return max; } else if (self < min) { return min; } else if (self > max) { return max; } return self; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Clamp(this int self, int min, int max) { if (max < min) { return max; } else if (self < min) { return min; } else if (self > max) { return max; } return self; } } }