Pan gestures can easily register multiple touches. In this case, we’re going to attach the gesture’s touch points to the four corners of a shape. You can access the touch points of a gesture via its locations variable:
Center v. Locations
For a single-touch gestures (e.g. pan, longpress, etc.) there is no difference between center and locations. However, for multiple touch gestures the center represents the geometric center (aka. centroid) of all the touches.
We want a set of points equally distributed around the canvas’ center. So, to do this we create two Vector objects that represent the displacement of x, and y respectively.
Then, with those displacement vectors we can calculate the points of our shape. Using this handy technique: