Class FloatExtensions
Offers some extensions and helper-methods for the work with floats.
Inherited Members
Namespace: RGB.NET.Core
Assembly: RGB.NET.Core.dll
Syntax
public static class FloatExtensions
Fields
| Edit this page View SourceTOLERANCE
Defines the precision RGB.NET processes floating point comparisons in.
Declaration
public const float TOLERANCE = 1E-07
Field Value
Type | Description |
---|---|
float |
Methods
| Edit this page View SourceClamp(int, int, int)
Clamps the provided value to be bigger or equal min and smaller or equal max.
Declaration
public static int Clamp(this int value, int min, int max)
Parameters
Type | Name | Description |
---|---|---|
int | value | The value to clamp. |
int | min | The lower value of the range the value is clamped to. |
int | max | The higher value of the range the value is clamped to. |
Returns
Type | Description |
---|---|
int | The clamped value. |
Clamp(float, float, float)
Clamps the provided value to be bigger or equal min and smaller or equal max.
Declaration
public static float Clamp(this float value, float min, float max)
Parameters
Type | Name | Description |
---|---|---|
float | value | The value to clamp. |
float | min | The lower value of the range the value is clamped to. |
float | max | The higher value of the range the value is clamped to. |
Returns
Type | Description |
---|---|
float | The clamped value. |
EqualsInTolerance(float, float)
Checks if two values are equal respecting the TOLERANCE.
Declaration
public static bool EqualsInTolerance(this float value1, float value2)
Parameters
Type | Name | Description |
---|---|---|
float | value1 | The first value to compare. |
float | value2 | The first value to compare. |
Returns
Type | Description |
---|---|
bool |
|
GetByteValueFromPercentage(float)
Converts a normalized float value in the range [0..1] to a byte [0..255].
Declaration
public static byte GetByteValueFromPercentage(this float percentage)
Parameters
Type | Name | Description |
---|---|---|
float | percentage | The normalized float value to convert. |
Returns
Type | Description |
---|---|
byte | The byte value. |
GetPercentageFromByteValue(byte)
Converts a byte value [0..255] to a normalized float value in the range [0..1].
Declaration
public static float GetPercentageFromByteValue(this byte value)
Parameters
Type | Name | Description |
---|---|---|
byte | value | The byte value to convert. |
Returns
Type | Description |
---|---|
float | The normalized float value. |
Wrap(float, float, float)
Enforces the provided value to be in the specified range by wrapping it around the edges if it exceeds them.
Declaration
public static float Wrap(this float value, float min, float max)
Parameters
Type | Name | Description |
---|---|---|
float | value | The value to wrap. |
float | min | The lower value of the range the value is wrapped into. |
float | max | The higher value of the range the value is wrapped into. |
Returns
Type | Description |
---|---|
float | The wrapped value. |