Math#snapToFloor()

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

Snap a value to nearest grid slice, using floor.

Example: if you have an interval gap of 5 and a position of 12... you will snap to 10.
As will 14 snap to 10... but 16 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 181)
doc_phaser
2017-02-14 10:55:06
Comments
Leave a Comment

Please login to continue.