API Reference › Math › Math.snapped
method

Math.snapped

Math.snapped(v, step) -> fixed

Rounds v to the nearest multiple of step (both fixed) — for snapping a position to a grid, quantizing an angle to 8 directions, or rounding a value to a tidy increment. Math.snapped(x, 16.0) snaps x to a 16-unit grid.

Example

program Demo {
  handler Step phase Update {
    let gx = Math.snapped(world_x, 16.0)
  }
}
← All symbols