mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-12 11:32:33 +02:00
5fdac82dd6
* (Add) Settings & Issues: Enable or disable Empty Layers * (Add) PrusaSlicer Printer: Nova Bene4 Mono * (Add) CWS: Support the GRAY2RGB and RBG2GRAY encoding for Bene Mono * (Add) Layer issue Z map paired with layer navigation tracker bar * (Change) Shortcuts: + and - to go up and down on layers were change to W and S keys. Reason: + and - are bound to zoom and can lead to problems * (Upgrade) OpenCV from 4.2 to 4.3 * (Fix) CWS: Add missing Platform X,Y,Z size when converting from SL1 * (Fix) CWS: Invert XY resolution when converting from SL1
66 lines
1.9 KiB
C#
66 lines
1.9 KiB
C#
/*
|
|
* GNU AFFERO GENERAL PUBLIC LICENSE
|
|
* Version 3, 19 November 2007
|
|
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
* of this license document, but changing it is not allowed.
|
|
*/
|
|
|
|
using System;
|
|
|
|
namespace UVtools.Core.Extensions
|
|
{
|
|
public static class MathExtensions
|
|
{
|
|
public static byte Clamp(this byte value, byte min, byte max)
|
|
{
|
|
return value <= min ? min : value >= max ? max : value;
|
|
}
|
|
|
|
public static sbyte Clamp(this sbyte value, sbyte min, sbyte max)
|
|
{
|
|
return value <= min ? min : value >= max ? max : value;
|
|
}
|
|
|
|
public static ushort Clamp(this ushort value, ushort min, ushort max)
|
|
{
|
|
return value <= min ? min : value >= max ? max : value;
|
|
}
|
|
|
|
public static short Clamp(this short value, short min, short max)
|
|
{
|
|
return value <= min ? min : value >= max ? max : value;
|
|
}
|
|
|
|
public static uint Clamp(this uint value, uint min, uint max)
|
|
{
|
|
return value <= min ? min : value >= max ? max : value;
|
|
}
|
|
|
|
public static int Clamp(this int value, int min, int max)
|
|
{
|
|
return value <= min ? min : value >= max ? max : value;
|
|
}
|
|
|
|
public static ulong Clamp(this ulong value, ulong min, ulong max)
|
|
{
|
|
return value <= min ? min : value >= max ? max : value;
|
|
}
|
|
|
|
public static long Clamp(this long value, long min, long max)
|
|
{
|
|
return value <= min ? min : value >= max ? max : value;
|
|
}
|
|
|
|
public static T Clamp<T>(T value, T min, T max) where T : IComparable<T>
|
|
{
|
|
if (value.CompareTo(min) < 0)
|
|
return min;
|
|
if (value.CompareTo(max) > 0)
|
|
return max;
|
|
|
|
return value;
|
|
}
|
|
}
|
|
}
|