Math#snapTo()

snapTo(input, gap, start) → {number}

Snap a value to nearest grid slice, using rounding.

Example: if you have an interval gap of 5 and a position of 12... you will snap to 10 whereas 14 will snap to 15.

Parameters
Name Type Argument Default Description
input number

The value to snap.

gap number

The interval gap of the grid.

start number <optional>
0

Optional starting offset for gap.

Returns
number -

The snapped value.

Source code: math/Math.js (Line 155)
doc_phaser
2017-02-14 10:55:05
Comments
Leave a Comment

Please login to continue.