Snap grid ported to Swift