g.snapToGrid(val, gridSize)

Snap the value val to a grid of size gridSize.