math docs
    Preparing search index...

    Function wrap

    • Wraps value into the range [min, max), looping around at either end. repeat is the min = 0 special case. Expects min < max.

      A value already inside the range is returned unchanged, bit for bit.

      Parameters

      • value: number
      • min: number
      • max: number

      Returns number

      wrap(370, 0, 360)          // 10
      wrap(-10, 0, 360) // 350
      wrap(4, -Math.PI, Math.PI) // 4 - 2π

      Inspired by Godot's wrapf: https://godot-rust.github.io/docs/gdext/master/godot/global/fn.wrapf.html