rect.snapToGrid(gx, gy)
Adjust the position and dimensions of the rectangle such that its edges are on the nearest increment of gx on the x-axis and gy on the y-axis.
gx
gy