Function snapToIntegerRange

Function Documentation

int64_t snapToIntegerRange(int64_t value, int64_t from_value, int64_t to_value, uint64_t step)

Snaps and clamps an integer value to a given range and step.

Note: The value is snapped to the nearest integer number of steps from the ‘from_value’ or clamped to the ‘to_value’.

The magnitude of ‘step’ is used and the sign is ignored.

If ‘step’ == 0, the step size is considered 1.

Parameters:
  • value – Input value.

  • from_value – Range minimum.

  • to_value – Range maximum.

  • step – Step size.