Show / Hide Table of Contents

Class FloatExtensions

Offers some extensions and helper-methods for the work with floats.

Inheritance
object
FloatExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: RGB.NET.Core
Assembly: RGB.NET.Core.dll
Syntax
public static class FloatExtensions

Fields

| Edit this page View Source

TOLERANCE

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 Source

Clamp(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.

| Edit this page View Source

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.

| Edit this page View Source

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

true if the difference is smaller than the TOLERANCE; otherwise, false.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX