wrap function

Wrap coordinates or pixels in a torus-like fashion