range
A utility node that defines a numerical range by bundling a minimum and a maximum value. It's primarily used as a configuration object for other nodes, especially `remap`.
Core Advantages
It greatly improves code organization and reusability by encapsulating a range's boundaries into a single, logical object. This simplifies parameter passing and allows a single range definition to be reused across multiple operations.
Common Uses
Defining the input and output boundaries for the `remap` node to perform value remapping.
Specifying the target interval for generating random numbers.
Marking the segments for procedural gradients or piecewise functions.
How to adjust
Adjusting the `min` and `max` properties of a `range` node has no direct visual effect. It indirectly controls the behavior of nodes that use it, like `remap`. For example, narrowing the output range from `range(0, 1)` to `range(0.2, 0.8)` will reduce the contrast of the final effect. Incorrectly setting the input range can cause the mapping to be clamped, altering the character of an animation.
Code Examples
1// Define the input range of a sin wave [-1, 1]
2const fromRange = TSL.range( -1, 1 );
3
4// Define the desired output range [0, 1]
5const toRange = TSL.range( 0, 1 );
6
7// Remap the value from the input range to the output range
8const remappedValue = TSL.remap( inputValue, fromRange, toRange );