mirror of https://github.com/SixLabors/ImageSharp
3 changed files with 36 additions and 7 deletions
@ -0,0 +1,29 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System.Runtime.CompilerServices; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Utility methods for numeric primitives.
|
||||
|
/// </summary>
|
||||
|
internal static class NumberUtils |
||||
|
{ |
||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)] |
||||
|
public static float ClampFloat(float value, float min, float max) |
||||
|
{ |
||||
|
if (value >= max) |
||||
|
{ |
||||
|
return max; |
||||
|
} |
||||
|
|
||||
|
if (value <= min) |
||||
|
{ |
||||
|
return min; |
||||
|
} |
||||
|
|
||||
|
return value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue