Widgets/Transformer

Range Map

Range Map

A "Transformer" type widget. Range Map Widget converts a number from one scale to another. This is essential for normalizing sensor data, scaling UI values, converting units, or inverting ranges. It ensures your data fits the scale you need, with optional clamping to keep outputs within bounds.

 

How It Works

The widget uses the following formula to map an input value from its original range to a new range:

output = ((input - fromMin) * (toMax - toMin)) / (fromMax - fromMin) + toMin

This formula linearly scales the input value to the new range. If clamping is enabled, outputs are never less than to Min or greater than to Max.


Inputs

  • in (DataType: Number) The numeric value to be mapped from the source range to the target range.

Outputs

  • out (DataType: Number) The mapped numeric value in the target range.

Custom Settings

  • Min — The minimum value of the input range.
  • Max — The maximum value of the input range.
  • To Min — The minimum value of the output range.
  • To Max — The maximum value of the output range.
  • Limit Values — If enabled, output values are clamped to the target range. If disabled, values can exceed the target range.

Range Map Settings

 

📌 Important Notes

  • Only numeric input values are mapped; non-numeric values are ignored.
  • If any of the range values are missing or invalid, the widget will not output a value.
  • Clamping (limit values) ensures outputs stay within your desired range.
  • Clamping is important for safety and predictable outputs, especially when working with sensors or actuators.

 

Examples

Slider to Color Intensity

Map a UI slider (0–100) to an RGB color channel (0–255):


Drag the example onto the workspace to explore and experiment!



In this example:

  1. The Slider widget is set to output a values from 0 to 100
  2. The Range Map widget is set with a "Max input" = 100 and "To Max" output = 255
  3. The Range Map widget receives a value and maps it to the 0–255 rang
  4. The mapped value is sent to the Display widget, showing the corresponding RGB channel value

 

Clamping Example

Map 0–100 to 0–1, with clamping enabled:


Drag the example onto the workspace to explore and experiment!



In this example:

  1. The Slider widget is set to output values from -10 to 110 (try moving it above 100 or below 0)
  2. The Range Map widget is set with "Max" input = 100 and "To Max" output = 1.
  3. With the clamp enabled, The Range Map widget receives a value and maps it to the 0–1 range
  4. If the Slider is set:
  • Below 0, the output is clamped to 0
  • Above 100, the output is clamped to 1
  1. The mapped and clamped (Limited value) value is sent to thea Display widget

 

Negative Values Example

Map a temperature sensor from -40–60°C to a 0–100% scale:


Drag the example onto the workspace to explore and experiment!



In this example:

  1. The Slider widget simulating a temperature sensor and is set to output values between -40°C to 60°C
  2. The Range Map widget is set with "Min" input = -140, "Max" input = 60 and "To Max" output = 100
  3. With the clamp enabled, the Range Map widget receives a value and maps it to a 0–100% scale. If the slider is set:
    • Below -40, the output is clamped to 0%
    • If above 60, the output is clamped to 100%
  4. The mapped and clamped value is sent to theDisplay widget

 

Inverted Mapping Example

Map 0–10 to 100–0 (inverted):


Drag the example onto the workspace to explore and experiment!



In this example:

  1. The Slider widget is set to output values from 0 to 10
  2. The Range Map widget is set with "Max input" = 10 and "To Min output" = 100
  3. With the clamp enabled, The Range Map widget receives a value and maps it to the inverted range 100–0. If the slider is set:
    • to 0, the output is 100
    • to 10, the output is 0
    • Intermediate values are mapped proportionally
  4. The mapped value is sent to the Display widget

 

📌 Additional Notes

  • The Range Map widget is a universal tool for converting numbers from one scale to another.
  • Especially useful in automation, data normalization, UI, and sensor processing.
  • You set the input and output ranges, and the widget does the math for you.
  • Negative input ranges are common in real-world sensors (e.g., temperature, voltage). The Range Map widget handles these seamlessly.
  • Inverted mapping is useful for countdowns, reverse controls, and visual effects.
  • Useful for sensor normalization, UI scaling, and unit conversions.

 

Glossary

  • Clamping

    Restricting an output value to stay within a defined minimum and maximum range.

  • Scaling UI Values

    Adjusting numerical inputs or outputs so UI elements (like sliders or displays) match a different target range for consistent visual behavior.