Utility class for remapping numeric values between ranges, with optional clamping and exponential skewing.
More...
|
| static float | Remap (float value, float from1, float to1, float from2, float to2, bool clamp=false, float skew=1f, SkewMode mode=SkewMode.Cabbage) |
| | Remaps a float value from one range to another with optional clamping and skewing. There are two possible modes for skewing: Cabbage and Normalized.
|
| static float | RemapTo0to1 (float value, float from, float to, float skew=1f) |
| | Remaps a value from the given range to a normalised 0–1 value, with an optional power-curve skew. A skew of 1 gives a linear mapping; values below 1 compress the lower end (exponential feel).
|
| static float | RemapFrom0to1 (float value, float from, float to, float skew=1f) |
| | Remaps a normalised 0–1 value to the given output range, with an optional power-curve skew. A skew of 1 gives a linear mapping; values below 1 compress the lower end (exponential feel).
|
Utility class for remapping numeric values between ranges, with optional clamping and exponential skewing.
◆ SkewMode
Controls how the skew factor is interpreted when remapping values.
| Enumerator |
|---|
| Cabbage | Skew factor has no upper bound. Values below 1 produce exponential mapping, 1 produces linear mapping, and values above 1 produce logarithmic mapping.
|
| Normalized | Skew factor is normalised to the 0–1 range. Values below 0.5 produce exponential mapping, 0.5 produces linear mapping, and values above 0.5 produce logarithmic mapping.
|
◆ Remap()
| float Csound.Unity.Utilities.RemapUtils.Remap |
( |
float | value, |
|
|
float | from1, |
|
|
float | to1, |
|
|
float | from2, |
|
|
float | to2, |
|
|
bool | clamp = false, |
|
|
float | skew = 1f, |
|
|
SkewMode | mode = SkewMode::Cabbage ) |
|
inlinestatic |
Remaps a float value from one range to another with optional clamping and skewing. There are two possible modes for skewing: Cabbage and Normalized.
In Cabbage mode, the skew factor has no upper limit and the mapping behaves as follows:
- Exponential mapping for values above 0 to 1
- Linear mapping at 1
- Logarithmic mapping for values above 1
In Normalized mode, the skew factor is bound between 0 and 1, and the mapping behaves as follows:
- Exponential mapping from values above 0 to 0.5
- Linear mapping at 0.5
- Logarithmic mapping for values above 0.5 to 1
Both modes return the lower target bound (from2) when the skew is 0 or below. The Normalized mode returns the upper target bound (to2) when the skew is 1 or above.
- Parameters
-
| value | The input value to be remapped. |
| from1 | The lower bound of the source range. |
| to1 | The upper bound of the source range. |
| from2 | The lower bound of the target range. |
| to2 | The upper bound of the target range. |
| clamp | Determines whether the mapped value should be clamped within the target range. Default is false. |
| skew | A skew factor that controls the mapping behavior. Default is 1 |
| mode | The mode for skewing the mapping behavior. Default is Cabbage |
- Returns
- The remapped value within the target range.
◆ RemapFrom0to1()
| float Csound.Unity.Utilities.RemapUtils.RemapFrom0to1 |
( |
float | value, |
|
|
float | from, |
|
|
float | to, |
|
|
float | skew = 1f ) |
|
inlinestatic |
Remaps a normalised 0–1 value to the given output range, with an optional power-curve skew. A skew of 1 gives a linear mapping; values below 1 compress the lower end (exponential feel).
- Parameters
-
| value | The normalised input value (0–1). Values outside this range are clamped. |
| from | The lower bound of the output range. |
| to | The upper bound of the output range. |
| skew | Power-curve exponent applied before scaling. Defaults to 1 (linear). |
- Returns
- A float in the range [from , to ] corresponding to the remapped input.
◆ RemapTo0to1()
| float Csound.Unity.Utilities.RemapUtils.RemapTo0to1 |
( |
float | value, |
|
|
float | from, |
|
|
float | to, |
|
|
float | skew = 1f ) |
|
inlinestatic |
Remaps a value from the given range to a normalised 0–1 value, with an optional power-curve skew. A skew of 1 gives a linear mapping; values below 1 compress the lower end (exponential feel).
- Parameters
-
| value | The input value to remap. |
| from | The lower bound of the input range. |
| to | The upper bound of the input range. |
| skew | Power-curve exponent applied after normalisation. Defaults to 1 (linear). |
- Returns
- A 0–1 float representing the remapped position of value within [from , to ].
The documentation for this class was generated from the following file: